From b6498d8580d056817981dedbaa0ea5d82e9dccc2 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:52:29 -0800 Subject: [PATCH] feat: Trusted Private Cloud support, use the universeDomain parameter (#5022) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: Trusted Private Cloud support, use the universeDomain parameter PiperOrigin-RevId: 604765466 Source-Link: https://github.com/googleapis/googleapis/commit/40203ca1880849480bbff7b8715491060bbccdf1 Source-Link: https://github.com/googleapis/googleapis-gen/commit/07b7f3dad8aa1912d4acdcfd6365bb4236e4b54b Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWFpLWdlbmVyYXRpdmVsYW5ndWFnZS8uT3dsQm90LnlhbWwiLCJoIjoiMDdiN2YzZGFkOGFhMTkxMmQ0YWNkY2ZkNjM2NWJiNDIzNmU0YjU0YiJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWFuYWx5dGljcy1hZG1pbi8uT3dsQm90LnlhbWwiLCJoIjoiMDdiN2YzZGFkOGFhMTkxMmQ0YWNkY2ZkNjM2NWJiNDIzNmU0YjU0YiJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWFuYWx5dGljcy1kYXRhLy5Pd2xCb3QueWFtbCIsImgiOiIwN2I3ZjNkYWQ4YWExOTEyZDRhY2RjZmQ2MzY1YmI0MjM2ZTRiNTRiIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWFwaS1hcGlrZXlzLy5Pd2xCb3QueWFtbCIsImgiOiIwN2I3ZjNkYWQ4YWExOTEyZDRhY2RjZmQ2MzY1YmI0MjM2ZTRiNTRiIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWFwaS1jbG91ZHF1b3Rhcy8uT3dsQm90LnlhbWwiLCJoIjoiMDdiN2YzZGFkOGFhMTkxMmQ0YWNkY2ZkNjM2NWJiNDIzNmU0YjU0YiJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWFwaS1zZXJ2aWNlY29udHJvbC8uT3dsQm90LnlhbWwiLCJoIjoiMDdiN2YzZGFkOGFhMTkxMmQ0YWNkY2ZkNjM2NWJiNDIzNmU0YjU0YiJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWFwaS1zZXJ2aWNlbWFuYWdlbWVudC8uT3dsQm90LnlhbWwiLCJoIjoiMDdiN2YzZGFkOGFhMTkxMmQ0YWNkY2ZkNjM2NWJiNDIzNmU0YjU0YiJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWFwaS1zZXJ2aWNldXNhZ2UvLk93bEJvdC55YW1sIiwiaCI6IjA3YjdmM2RhZDhhYTE5MTJkNGFjZGNmZDYzNjViYjQyMzZlNGI1NGIifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWFwcGVuZ2luZS8uT3dsQm90LnlhbWwiLCJoIjoiMDdiN2YzZGFkOGFhMTkxMmQ0YWNkY2ZkNjM2NWJiNDIzNmU0YjU0YiJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWFyZWExMjAtdGFibGVzLy5Pd2xCb3QueWFtbCIsImgiOiIwN2I3ZjNkYWQ4YWExOTEyZDRhY2RjZmQ2MzY1YmI0MjM2ZTRiNTRiIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWFjY2Vzc2FwcHJvdmFsLy5Pd2xCb3QueWFtbCIsImgiOiIwN2I3ZjNkYWQ4YWExOTEyZDRhY2RjZmQ2MzY1YmI0MjM2ZTRiNTRiIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWFkdmlzb3J5bm90aWZpY2F0aW9ucy8uT3dsQm90LnlhbWwiLCJoIjoiMDdiN2YzZGFkOGFhMTkxMmQ0YWNkY2ZkNjM2NWJiNDIzNmU0YjU0YiJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWFsbG95ZGIvLk93bEJvdC55YW1sIiwiaCI6IjA3YjdmM2RhZDhhYTE5MTJkNGFjZGNmZDYzNjViYjQyMzZlNGI1NGIifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWFwaWdhdGV3YXkvLk93bEJvdC55YW1sIiwiaCI6IjA3YjdmM2RhZDhhYTE5MTJkNGFjZGNmZDYzNjViYjQyMzZlNGI1NGIifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWFwaWdlZWNvbm5lY3QvLk93bEJvdC55YW1sIiwiaCI6IjA3YjdmM2RhZDhhYTE5MTJkNGFjZGNmZDYzNjViYjQyMzZlNGI1NGIifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWFwaWdlZXJlZ2lzdHJ5Ly5Pd2xCb3QueWFtbCIsImgiOiIwN2I3ZjNkYWQ4YWExOTEyZDRhY2RjZmQ2MzY1YmI0MjM2ZTRiNTRiIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWFzc3VyZWR3b3JrbG9hZHMvLk93bEJvdC55YW1sIiwiaCI6IjA3YjdmM2RhZDhhYTE5MTJkNGFjZGNmZDYzNjViYjQyMzZlNGI1NGIifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWF1dG9tbC8uT3dsQm90LnlhbWwiLCJoIjoiMDdiN2YzZGFkOGFhMTkxMmQ0YWNkY2ZkNjM2NWJiNDIzNmU0YjU0YiJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJhcmVtZXRhbHNvbHV0aW9uLy5Pd2xCb3QueWFtbCIsImgiOiIwN2I3ZjNkYWQ4YWExOTEyZDRhY2RjZmQ2MzY1YmI0MjM2ZTRiNTRiIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJhdGNoLy5Pd2xCb3QueWFtbCIsImgiOiIwN2I3ZjNkYWQ4YWExOTEyZDRhY2RjZmQ2MzY1YmI0MjM2ZTRiNTRiIn0= * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot --- .../generated/v1/model_service.list_models.js | 2 +- .../v1beta/model_service.list_models.js | 2 +- .../v1beta/model_service.list_tuned_models.js | 2 +- .../permission_service.list_permissions.js | 2 +- .../v1beta/retriever_service.list_chunks.js | 2 +- .../v1beta/retriever_service.list_corpora.js | 2 +- .../retriever_service.list_documents.js | 2 +- .../v1beta2/model_service.list_models.js | 2 +- .../v1beta3/model_service.list_models.js | 2 +- .../model_service.list_tuned_models.js | 2 +- .../permission_service.list_permissions.js | 2 +- .../src/v1/generative_service_client.ts | 60 ++++++++++++++-- .../src/v1/model_service_client.ts | 58 +++++++++++++-- .../src/v1beta/discuss_service_client.ts | 58 +++++++++++++-- .../src/v1beta/generative_service_client.ts | 60 ++++++++++++++-- .../src/v1beta/model_service_client.ts | 58 +++++++++++++-- .../src/v1beta/permission_service_client.ts | 58 +++++++++++++-- .../src/v1beta/retriever_service_client.ts | 58 +++++++++++++-- .../src/v1beta/text_service_client.ts | 58 +++++++++++++-- .../src/v1beta2/discuss_service_client.ts | 58 +++++++++++++-- .../src/v1beta2/model_service_client.ts | 58 +++++++++++++-- .../src/v1beta2/text_service_client.ts | 58 +++++++++++++-- .../src/v1beta3/discuss_service_client.ts | 58 +++++++++++++-- .../src/v1beta3/model_service_client.ts | 58 +++++++++++++-- .../src/v1beta3/permission_service_client.ts | 58 +++++++++++++-- .../src/v1beta3/text_service_client.ts | 58 +++++++++++++-- .../test/gapic_discuss_service_v1beta.ts | 62 +++++++++++++--- .../test/gapic_discuss_service_v1beta2.ts | 62 +++++++++++++--- .../test/gapic_discuss_service_v1beta3.ts | 62 +++++++++++++--- .../test/gapic_generative_service_v1.ts | 68 ++++++++++++++---- .../test/gapic_generative_service_v1beta.ts | 70 +++++++++++++++---- .../test/gapic_model_service_v1.ts | 60 ++++++++++++++-- .../test/gapic_model_service_v1beta.ts | 62 +++++++++++++--- .../test/gapic_model_service_v1beta2.ts | 62 +++++++++++++--- .../test/gapic_model_service_v1beta3.ts | 62 +++++++++++++--- .../test/gapic_permission_service_v1beta.ts | 64 ++++++++++++++--- .../test/gapic_permission_service_v1beta3.ts | 66 ++++++++++++++--- .../test/gapic_retriever_service_v1beta.ts | 62 +++++++++++++--- .../test/gapic_text_service_v1beta.ts | 62 +++++++++++++--- .../test/gapic_text_service_v1beta2.ts | 62 +++++++++++++--- .../test/gapic_text_service_v1beta3.ts | 62 +++++++++++++--- ...tics_admin_service.list_access_bindings.js | 2 +- ...cs_admin_service.list_account_summaries.js | 2 +- .../analytics_admin_service.list_accounts.js | 2 +- ...ytics_admin_service.list_ad_sense_links.js | 2 +- .../analytics_admin_service.list_audiences.js | 2 +- ...tics_admin_service.list_big_query_links.js | 2 +- ...s_admin_service.list_calculated_metrics.js | 2 +- ...ytics_admin_service.list_channel_groups.js | 2 +- ...cs_admin_service.list_conversion_events.js | 2 +- ...cs_admin_service.list_custom_dimensions.js | 2 +- ...ytics_admin_service.list_custom_metrics.js | 2 +- ...alytics_admin_service.list_data_streams.js | 2 +- ...play_video360_advertiser_link_proposals.js | 2 +- ....list_display_video360_advertiser_links.js | 2 +- ...s_admin_service.list_event_create_rules.js | 2 +- ...s_admin_service.list_expanded_data_sets.js | 2 +- ...ytics_admin_service.list_firebase_links.js | 2 +- ...ics_admin_service.list_google_ads_links.js | 2 +- ...rvice.list_measurement_protocol_secrets.js | 2 +- ...analytics_admin_service.list_properties.js | 2 +- ...rvice.list_rollup_property_source_links.js | 2 +- ...s_k_ad_network_conversion_value_schemas.js | 2 +- ..._admin_service.list_search_ads360_links.js | 2 +- ..._service.list_subproperty_event_filters.js | 2 +- ...in_service.search_change_history_events.js | 2 +- ...cs_admin_service.list_account_summaries.js | 2 +- .../analytics_admin_service.list_accounts.js | 2 +- ...cs_admin_service.list_conversion_events.js | 2 +- ...cs_admin_service.list_custom_dimensions.js | 2 +- ...ytics_admin_service.list_custom_metrics.js | 2 +- ...alytics_admin_service.list_data_streams.js | 2 +- ...ytics_admin_service.list_firebase_links.js | 2 +- ...ics_admin_service.list_google_ads_links.js | 2 +- ...rvice.list_measurement_protocol_secrets.js | 2 +- ...analytics_admin_service.list_properties.js | 2 +- ...in_service.search_change_history_events.js | 2 +- .../v1alpha/analytics_admin_service_client.ts | 58 +++++++++++++-- .../v1beta/analytics_admin_service_client.ts | 58 +++++++++++++-- .../gapic_analytics_admin_service_v1alpha.ts | 70 ++++++++++++++++--- .../gapic_analytics_admin_service_v1beta.ts | 70 ++++++++++++++++--- ...lpha_analytics_data.list_audience_lists.js | 2 +- ...tics_data.list_recurring_audience_lists.js | 2 +- ...ta_analytics_data.list_audience_exports.js | 2 +- .../v1alpha/alpha_analytics_data_client.ts | 58 +++++++++++++-- .../src/v1beta/beta_analytics_data_client.ts | 58 +++++++++++++-- .../gapic_alpha_analytics_data_v1alpha.ts | 66 ++++++++++++++--- .../test/gapic_beta_analytics_data_v1beta.ts | 64 ++++++++++++++--- .../generated/v2/api_keys.list_keys.js | 2 +- .../src/v2/api_keys_client.ts | 58 +++++++++++++-- .../test/gapic_api_keys_v2.ts | 58 +++++++++++++-- .../v1/cloud_quotas.list_quota_infos.js | 2 +- .../v1/cloud_quotas.list_quota_preferences.js | 2 +- .../src/v1/cloud_quotas_client.ts | 58 +++++++++++++-- .../test/gapic_cloud_quotas_v1.ts | 58 +++++++++++++-- .../src/v1/quota_controller_client.ts | 58 +++++++++++++-- .../src/v1/service_controller_client.ts | 58 +++++++++++++-- .../src/v2/service_controller_client.ts | 58 +++++++++++++-- .../test/gapic_quota_controller_v1.ts | 62 +++++++++++++--- .../test/gapic_service_controller_v1.ts | 62 +++++++++++++--- .../test/gapic_service_controller_v2.ts | 62 +++++++++++++--- .../service_manager.list_service_configs.js | 2 +- .../service_manager.list_service_rollouts.js | 2 +- .../v1/service_manager.list_services.js | 2 +- .../src/v1/service_manager_client.ts | 58 +++++++++++++-- .../test/gapic_service_manager_v1.ts | 62 +++++++++++++--- .../v1/service_usage.list_services.js | 2 +- .../service_usage.list_admin_overrides.js | 2 +- .../service_usage.list_consumer_overrides.js | 2 +- ...rvice_usage.list_consumer_quota_metrics.js | 2 +- .../v1beta1/service_usage.list_services.js | 2 +- .../src/v1/service_usage_client.ts | 58 +++++++++++++-- .../src/v1beta1/service_usage_client.ts | 58 +++++++++++++-- .../test/gapic_service_usage_v1.ts | 60 ++++++++++++++-- .../test/gapic_service_usage_v1beta1.ts | 62 +++++++++++++--- ...rtificates.list_authorized_certificates.js | 2 +- ...horized_domains.list_authorized_domains.js | 2 +- .../domain_mappings.list_domain_mappings.js | 2 +- .../v1/firewall.list_ingress_rules.js | 2 +- .../generated/v1/instances.list_instances.js | 2 +- .../generated/v1/services.list_services.js | 2 +- .../generated/v1/versions.list_versions.js | 2 +- .../src/v1/applications_client.ts | 58 +++++++++++++-- .../src/v1/authorized_certificates_client.ts | 58 +++++++++++++-- .../src/v1/authorized_domains_client.ts | 58 +++++++++++++-- .../src/v1/domain_mappings_client.ts | 58 +++++++++++++-- .../src/v1/firewall_client.ts | 58 +++++++++++++-- .../src/v1/instances_client.ts | 58 +++++++++++++-- .../src/v1/services_client.ts | 58 +++++++++++++-- .../src/v1/versions_client.ts | 58 +++++++++++++-- .../test/gapic_applications_v1.ts | 60 ++++++++++++++-- .../test/gapic_authorized_certificates_v1.ts | 70 ++++++++++++++++--- .../test/gapic_authorized_domains_v1.ts | 62 +++++++++++++--- .../test/gapic_domain_mappings_v1.ts | 62 +++++++++++++--- .../test/gapic_firewall_v1.ts | 58 +++++++++++++-- .../test/gapic_instances_v1.ts | 58 +++++++++++++-- .../test/gapic_services_v1.ts | 58 +++++++++++++-- .../test/gapic_versions_v1.ts | 58 +++++++++++++-- .../v1alpha1/tables_service.list_rows.js | 2 +- .../v1alpha1/tables_service.list_tables.js | 2 +- .../tables_service.list_workspaces.js | 2 +- .../src/v1alpha1/tables_service_client.ts | 58 +++++++++++++-- .../test/gapic_tables_service_v1alpha1.ts | 62 +++++++++++++--- .../access_approval.list_approval_requests.js | 2 +- .../src/v1/access_approval_client.ts | 58 +++++++++++++-- .../test/gapic_access_approval_v1.ts | 62 +++++++++++++--- ...otifications_service.list_notifications.js | 2 +- .../advisory_notifications_service_client.ts | 58 +++++++++++++-- ...gapic_advisory_notifications_service_v1.ts | 69 +++++++++++++++--- .../v1/alloy_d_b_admin.list_backups.js | 2 +- .../v1/alloy_d_b_admin.list_clusters.js | 2 +- .../v1/alloy_d_b_admin.list_instances.js | 2 +- ...d_b_admin.list_supported_database_flags.js | 2 +- .../v1/alloy_d_b_admin.list_users.js | 2 +- .../v1alpha/alloy_d_b_admin.list_backups.js | 2 +- .../v1alpha/alloy_d_b_admin.list_clusters.js | 2 +- .../v1alpha/alloy_d_b_admin.list_databases.js | 2 +- .../v1alpha/alloy_d_b_admin.list_instances.js | 2 +- ...d_b_admin.list_supported_database_flags.js | 2 +- .../v1alpha/alloy_d_b_admin.list_users.js | 2 +- .../v1beta/alloy_d_b_admin.list_backups.js | 2 +- .../v1beta/alloy_d_b_admin.list_clusters.js | 2 +- .../v1beta/alloy_d_b_admin.list_instances.js | 2 +- ...d_b_admin.list_supported_database_flags.js | 2 +- .../v1beta/alloy_d_b_admin.list_users.js | 2 +- .../src/v1/alloy_d_b_admin_client.ts | 58 +++++++++++++-- .../src/v1alpha/alloy_d_b_admin_client.ts | 58 +++++++++++++-- .../src/v1beta/alloy_d_b_admin_client.ts | 58 +++++++++++++-- .../test/gapic_alloy_d_b_admin_v1.ts | 60 ++++++++++++++-- .../test/gapic_alloy_d_b_admin_v1alpha.ts | 62 +++++++++++++--- .../test/gapic_alloy_d_b_admin_v1beta.ts | 62 +++++++++++++--- .../api_gateway_service.list_api_configs.js | 2 +- .../v1/api_gateway_service.list_apis.js | 2 +- .../v1/api_gateway_service.list_gateways.js | 2 +- .../src/v1/api_gateway_service_client.ts | 58 +++++++++++++-- .../test/gapic_api_gateway_service_v1.ts | 62 +++++++++++++--- .../v1/connection_service.list_connections.js | 2 +- .../samples/generated/v1/tether.egress.js | 2 +- .../src/v1/connection_service_client.ts | 58 +++++++++++++-- .../src/v1/tether_client.ts | 60 ++++++++++++++-- .../test/gapic_connection_service_v1.ts | 62 +++++++++++++--- .../test/gapic_tether_v1.ts | 58 +++++++++++++-- .../registry.list_api_deployment_revisions.js | 2 +- .../v1/registry.list_api_deployments.js | 2 +- .../v1/registry.list_api_spec_revisions.js | 2 +- .../generated/v1/registry.list_api_specs.js | 2 +- .../v1/registry.list_api_versions.js | 2 +- .../generated/v1/registry.list_apis.js | 2 +- .../generated/v1/registry.list_artifacts.js | 2 +- .../src/v1/provisioning_client.ts | 58 +++++++++++++-- .../src/v1/registry_client.ts | 58 +++++++++++++-- .../test/gapic_provisioning_v1.ts | 60 ++++++++++++++-- .../test/gapic_registry_v1.ts | 58 +++++++++++++-- ...sured_workloads_service.list_violations.js | 2 +- ...ssured_workloads_service.list_workloads.js | 2 +- ...ssured_workloads_service.list_workloads.js | 2 +- .../v1/assured_workloads_service_client.ts | 58 +++++++++++++-- .../assured_workloads_service_client.ts | 58 +++++++++++++-- .../gapic_assured_workloads_service_v1.ts | 70 ++++++++++++++++--- ...gapic_assured_workloads_service_v1beta1.ts | 69 +++++++++++++++--- .../generated/v1/auto_ml.list_datasets.js | 2 +- .../v1/auto_ml.list_model_evaluations.js | 2 +- .../generated/v1/auto_ml.list_models.js | 2 +- .../v1beta1/auto_ml.list_column_specs.js | 2 +- .../v1beta1/auto_ml.list_datasets.js | 2 +- .../v1beta1/auto_ml.list_model_evaluations.js | 2 +- .../generated/v1beta1/auto_ml.list_models.js | 2 +- .../v1beta1/auto_ml.list_table_specs.js | 2 +- .../src/v1/auto_ml_client.ts | 58 +++++++++++++-- .../src/v1/prediction_service_client.ts | 58 +++++++++++++-- .../src/v1beta1/auto_ml_client.ts | 58 +++++++++++++-- .../src/v1beta1/prediction_service_client.ts | 58 +++++++++++++-- .../test/gapic_auto_ml_v1.ts | 58 +++++++++++++-- .../test/gapic_auto_ml_v1beta1.ts | 58 +++++++++++++-- .../test/gapic_prediction_service_v1.ts | 62 +++++++++++++--- .../test/gapic_prediction_service_v1beta1.ts | 66 ++++++++++++++--- .../v2/bare_metal_solution.list_instances.js | 2 +- .../v2/bare_metal_solution.list_luns.js | 2 +- .../v2/bare_metal_solution.list_networks.js | 2 +- .../v2/bare_metal_solution.list_nfs_shares.js | 2 +- .../v2/bare_metal_solution.list_o_s_images.js | 2 +- ...metal_solution.list_provisioning_quotas.js | 2 +- .../v2/bare_metal_solution.list_s_s_h_keys.js | 2 +- ...re_metal_solution.list_volume_snapshots.js | 2 +- .../v2/bare_metal_solution.list_volumes.js | 2 +- .../src/v2/bare_metal_solution_client.ts | 58 +++++++++++++-- .../test/gapic_bare_metal_solution_v2.ts | 62 +++++++++++++--- .../generated/v1/batch_service.list_jobs.js | 2 +- .../generated/v1/batch_service.list_tasks.js | 2 +- .../v1alpha/batch_service.list_jobs.js | 2 +- .../v1alpha/batch_service.list_tasks.js | 2 +- .../src/v1/batch_service_client.ts | 58 +++++++++++++-- .../src/v1alpha/batch_service_client.ts | 58 +++++++++++++-- .../test/gapic_batch_service_v1.ts | 60 ++++++++++++++-- .../test/gapic_batch_service_v1alpha.ts | 62 +++++++++++++--- 235 files changed, 5992 insertions(+), 888 deletions(-) diff --git a/packages/google-ai-generativelanguage/samples/generated/v1/model_service.list_models.js b/packages/google-ai-generativelanguage/samples/generated/v1/model_service.list_models.js index ae10790851f..cbce8369557 100644 --- a/packages/google-ai-generativelanguage/samples/generated/v1/model_service.list_models.js +++ b/packages/google-ai-generativelanguage/samples/generated/v1/model_service.list_models.js @@ -57,7 +57,7 @@ function main() { }; // Run request - const iterable = await generativelanguageClient.listModelsAsync(request); + const iterable = generativelanguageClient.listModelsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-ai-generativelanguage/samples/generated/v1beta/model_service.list_models.js b/packages/google-ai-generativelanguage/samples/generated/v1beta/model_service.list_models.js index 16ecf10e285..ec328391664 100644 --- a/packages/google-ai-generativelanguage/samples/generated/v1beta/model_service.list_models.js +++ b/packages/google-ai-generativelanguage/samples/generated/v1beta/model_service.list_models.js @@ -57,7 +57,7 @@ function main() { }; // Run request - const iterable = await generativelanguageClient.listModelsAsync(request); + const iterable = generativelanguageClient.listModelsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-ai-generativelanguage/samples/generated/v1beta/model_service.list_tuned_models.js b/packages/google-ai-generativelanguage/samples/generated/v1beta/model_service.list_tuned_models.js index 5422ba65e01..80f76807b22 100644 --- a/packages/google-ai-generativelanguage/samples/generated/v1beta/model_service.list_tuned_models.js +++ b/packages/google-ai-generativelanguage/samples/generated/v1beta/model_service.list_tuned_models.js @@ -72,7 +72,7 @@ function main() { }; // Run request - const iterable = await generativelanguageClient.listTunedModelsAsync(request); + const iterable = generativelanguageClient.listTunedModelsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-ai-generativelanguage/samples/generated/v1beta/permission_service.list_permissions.js b/packages/google-ai-generativelanguage/samples/generated/v1beta/permission_service.list_permissions.js index a98c377e6cf..fe7d19d1c02 100644 --- a/packages/google-ai-generativelanguage/samples/generated/v1beta/permission_service.list_permissions.js +++ b/packages/google-ai-generativelanguage/samples/generated/v1beta/permission_service.list_permissions.js @@ -65,7 +65,7 @@ function main(parent) { }; // Run request - const iterable = await generativelanguageClient.listPermissionsAsync(request); + const iterable = generativelanguageClient.listPermissionsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-ai-generativelanguage/samples/generated/v1beta/retriever_service.list_chunks.js b/packages/google-ai-generativelanguage/samples/generated/v1beta/retriever_service.list_chunks.js index 0451974b6ae..709bebca820 100644 --- a/packages/google-ai-generativelanguage/samples/generated/v1beta/retriever_service.list_chunks.js +++ b/packages/google-ai-generativelanguage/samples/generated/v1beta/retriever_service.list_chunks.js @@ -62,7 +62,7 @@ function main(parent) { }; // Run request - const iterable = await generativelanguageClient.listChunksAsync(request); + const iterable = generativelanguageClient.listChunksAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-ai-generativelanguage/samples/generated/v1beta/retriever_service.list_corpora.js b/packages/google-ai-generativelanguage/samples/generated/v1beta/retriever_service.list_corpora.js index 4e745745009..d6fc39efced 100644 --- a/packages/google-ai-generativelanguage/samples/generated/v1beta/retriever_service.list_corpora.js +++ b/packages/google-ai-generativelanguage/samples/generated/v1beta/retriever_service.list_corpora.js @@ -56,7 +56,7 @@ function main() { }; // Run request - const iterable = await generativelanguageClient.listCorporaAsync(request); + const iterable = generativelanguageClient.listCorporaAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-ai-generativelanguage/samples/generated/v1beta/retriever_service.list_documents.js b/packages/google-ai-generativelanguage/samples/generated/v1beta/retriever_service.list_documents.js index 37f557f0826..54be19e81f6 100644 --- a/packages/google-ai-generativelanguage/samples/generated/v1beta/retriever_service.list_documents.js +++ b/packages/google-ai-generativelanguage/samples/generated/v1beta/retriever_service.list_documents.js @@ -62,7 +62,7 @@ function main(parent) { }; // Run request - const iterable = await generativelanguageClient.listDocumentsAsync(request); + const iterable = generativelanguageClient.listDocumentsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-ai-generativelanguage/samples/generated/v1beta2/model_service.list_models.js b/packages/google-ai-generativelanguage/samples/generated/v1beta2/model_service.list_models.js index 6d4e05efc40..98958387152 100644 --- a/packages/google-ai-generativelanguage/samples/generated/v1beta2/model_service.list_models.js +++ b/packages/google-ai-generativelanguage/samples/generated/v1beta2/model_service.list_models.js @@ -57,7 +57,7 @@ function main() { }; // Run request - const iterable = await generativelanguageClient.listModelsAsync(request); + const iterable = generativelanguageClient.listModelsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-ai-generativelanguage/samples/generated/v1beta3/model_service.list_models.js b/packages/google-ai-generativelanguage/samples/generated/v1beta3/model_service.list_models.js index 20debc818fe..f69bcdbe153 100644 --- a/packages/google-ai-generativelanguage/samples/generated/v1beta3/model_service.list_models.js +++ b/packages/google-ai-generativelanguage/samples/generated/v1beta3/model_service.list_models.js @@ -57,7 +57,7 @@ function main() { }; // Run request - const iterable = await generativelanguageClient.listModelsAsync(request); + const iterable = generativelanguageClient.listModelsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-ai-generativelanguage/samples/generated/v1beta3/model_service.list_tuned_models.js b/packages/google-ai-generativelanguage/samples/generated/v1beta3/model_service.list_tuned_models.js index 9d02de5052d..0dcc202d450 100644 --- a/packages/google-ai-generativelanguage/samples/generated/v1beta3/model_service.list_tuned_models.js +++ b/packages/google-ai-generativelanguage/samples/generated/v1beta3/model_service.list_tuned_models.js @@ -57,7 +57,7 @@ function main() { }; // Run request - const iterable = await generativelanguageClient.listTunedModelsAsync(request); + const iterable = generativelanguageClient.listTunedModelsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-ai-generativelanguage/samples/generated/v1beta3/permission_service.list_permissions.js b/packages/google-ai-generativelanguage/samples/generated/v1beta3/permission_service.list_permissions.js index 0c2e22bf4c2..8b9c5971884 100644 --- a/packages/google-ai-generativelanguage/samples/generated/v1beta3/permission_service.list_permissions.js +++ b/packages/google-ai-generativelanguage/samples/generated/v1beta3/permission_service.list_permissions.js @@ -63,7 +63,7 @@ function main(parent) { }; // Run request - const iterable = await generativelanguageClient.listPermissionsAsync(request); + const iterable = generativelanguageClient.listPermissionsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-ai-generativelanguage/src/v1/generative_service_client.ts b/packages/google-ai-generativelanguage/src/v1/generative_service_client.ts index 57973e14664..e72b8a6f54b 100644 --- a/packages/google-ai-generativelanguage/src/v1/generative_service_client.ts +++ b/packages/google-ai-generativelanguage/src/v1/generative_service_client.ts @@ -27,6 +27,7 @@ import type { import {PassThrough} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/generative_service_client_config.json`. @@ -49,6 +50,8 @@ export class GenerativeServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -106,8 +109,20 @@ export class GenerativeServiceClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof GenerativeServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'generativelanguage.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -122,7 +137,7 @@ export class GenerativeServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -147,10 +162,10 @@ export class GenerativeServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -185,7 +200,7 @@ export class GenerativeServiceClient { streamGenerateContent: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, - /* gaxStreamingRetries: */ true + /* gaxStreamingRetries: */ false ), }; @@ -289,21 +304,52 @@ export class GenerativeServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-ai-generativelanguage/src/v1/model_service_client.ts b/packages/google-ai-generativelanguage/src/v1/model_service_client.ts index 6769d9a948b..9776304b2d5 100644 --- a/packages/google-ai-generativelanguage/src/v1/model_service_client.ts +++ b/packages/google-ai-generativelanguage/src/v1/model_service_client.ts @@ -29,6 +29,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/model_service_client_config.json`. @@ -50,6 +51,8 @@ export class ModelServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -107,8 +110,20 @@ export class ModelServiceClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof ModelServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'generativelanguage.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -123,7 +138,7 @@ export class ModelServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -148,10 +163,10 @@ export class ModelServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -272,21 +287,52 @@ export class ModelServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-ai-generativelanguage/src/v1beta/discuss_service_client.ts b/packages/google-ai-generativelanguage/src/v1beta/discuss_service_client.ts index c06f9e58237..cc9f1160ed4 100644 --- a/packages/google-ai-generativelanguage/src/v1beta/discuss_service_client.ts +++ b/packages/google-ai-generativelanguage/src/v1beta/discuss_service_client.ts @@ -27,6 +27,7 @@ import type { import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1beta/discuss_service_client_config.json`. @@ -51,6 +52,8 @@ export class DiscussServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -108,8 +111,20 @@ export class DiscussServiceClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof DiscussServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'generativelanguage.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -124,7 +139,7 @@ export class DiscussServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -149,10 +164,10 @@ export class DiscussServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -279,21 +294,52 @@ export class DiscussServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-ai-generativelanguage/src/v1beta/generative_service_client.ts b/packages/google-ai-generativelanguage/src/v1beta/generative_service_client.ts index 7ca2879b377..3c20f64038b 100644 --- a/packages/google-ai-generativelanguage/src/v1beta/generative_service_client.ts +++ b/packages/google-ai-generativelanguage/src/v1beta/generative_service_client.ts @@ -27,6 +27,7 @@ import type { import {PassThrough} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1beta/generative_service_client_config.json`. @@ -49,6 +50,8 @@ export class GenerativeServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -106,8 +109,20 @@ export class GenerativeServiceClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof GenerativeServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'generativelanguage.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -122,7 +137,7 @@ export class GenerativeServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -147,10 +162,10 @@ export class GenerativeServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -201,7 +216,7 @@ export class GenerativeServiceClient { streamGenerateContent: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, - /* gaxStreamingRetries: */ true + /* gaxStreamingRetries: */ false ), }; @@ -306,21 +321,52 @@ export class GenerativeServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-ai-generativelanguage/src/v1beta/model_service_client.ts b/packages/google-ai-generativelanguage/src/v1beta/model_service_client.ts index e7fff3d14f5..3b0eaf2ae92 100644 --- a/packages/google-ai-generativelanguage/src/v1beta/model_service_client.ts +++ b/packages/google-ai-generativelanguage/src/v1beta/model_service_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1beta/model_service_client_config.json`. @@ -52,6 +53,8 @@ export class ModelServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -110,8 +113,20 @@ export class ModelServiceClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof ModelServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'generativelanguage.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -126,7 +141,7 @@ export class ModelServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -151,10 +166,10 @@ export class ModelServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -338,21 +353,52 @@ export class ModelServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-ai-generativelanguage/src/v1beta/permission_service_client.ts b/packages/google-ai-generativelanguage/src/v1beta/permission_service_client.ts index 97d3d591d12..02a70be3372 100644 --- a/packages/google-ai-generativelanguage/src/v1beta/permission_service_client.ts +++ b/packages/google-ai-generativelanguage/src/v1beta/permission_service_client.ts @@ -29,6 +29,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1beta/permission_service_client_config.json`. @@ -50,6 +51,8 @@ export class PermissionServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -107,8 +110,20 @@ export class PermissionServiceClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof PermissionServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'generativelanguage.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -123,7 +138,7 @@ export class PermissionServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -148,10 +163,10 @@ export class PermissionServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -296,21 +311,52 @@ export class PermissionServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-ai-generativelanguage/src/v1beta/retriever_service_client.ts b/packages/google-ai-generativelanguage/src/v1beta/retriever_service_client.ts index eca2d3bb8c6..7d34cc46514 100644 --- a/packages/google-ai-generativelanguage/src/v1beta/retriever_service_client.ts +++ b/packages/google-ai-generativelanguage/src/v1beta/retriever_service_client.ts @@ -29,6 +29,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1beta/retriever_service_client_config.json`. @@ -50,6 +51,8 @@ export class RetrieverServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -107,8 +110,20 @@ export class RetrieverServiceClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof RetrieverServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'generativelanguage.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -123,7 +138,7 @@ export class RetrieverServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -148,10 +163,10 @@ export class RetrieverServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -320,21 +335,52 @@ export class RetrieverServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-ai-generativelanguage/src/v1beta/text_service_client.ts b/packages/google-ai-generativelanguage/src/v1beta/text_service_client.ts index 6632016793d..61e2b87ac03 100644 --- a/packages/google-ai-generativelanguage/src/v1beta/text_service_client.ts +++ b/packages/google-ai-generativelanguage/src/v1beta/text_service_client.ts @@ -27,6 +27,7 @@ import type { import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1beta/text_service_client_config.json`. @@ -51,6 +52,8 @@ export class TextServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -108,8 +111,20 @@ export class TextServiceClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof TextServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'generativelanguage.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -124,7 +139,7 @@ export class TextServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -149,10 +164,10 @@ export class TextServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -283,21 +298,52 @@ export class TextServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-ai-generativelanguage/src/v1beta2/discuss_service_client.ts b/packages/google-ai-generativelanguage/src/v1beta2/discuss_service_client.ts index 262fc42afeb..c12252ad575 100644 --- a/packages/google-ai-generativelanguage/src/v1beta2/discuss_service_client.ts +++ b/packages/google-ai-generativelanguage/src/v1beta2/discuss_service_client.ts @@ -27,6 +27,7 @@ import type { import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1beta2/discuss_service_client_config.json`. @@ -51,6 +52,8 @@ export class DiscussServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -108,8 +111,20 @@ export class DiscussServiceClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof DiscussServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'generativelanguage.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -124,7 +139,7 @@ export class DiscussServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -149,10 +164,10 @@ export class DiscussServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -263,21 +278,52 @@ export class DiscussServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-ai-generativelanguage/src/v1beta2/model_service_client.ts b/packages/google-ai-generativelanguage/src/v1beta2/model_service_client.ts index b44af7e5bb8..530f1aa13ce 100644 --- a/packages/google-ai-generativelanguage/src/v1beta2/model_service_client.ts +++ b/packages/google-ai-generativelanguage/src/v1beta2/model_service_client.ts @@ -29,6 +29,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1beta2/model_service_client_config.json`. @@ -50,6 +51,8 @@ export class ModelServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -107,8 +110,20 @@ export class ModelServiceClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof ModelServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'generativelanguage.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -123,7 +138,7 @@ export class ModelServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -148,10 +163,10 @@ export class ModelServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -273,21 +288,52 @@ export class ModelServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-ai-generativelanguage/src/v1beta2/text_service_client.ts b/packages/google-ai-generativelanguage/src/v1beta2/text_service_client.ts index 3e57082e618..38566455bd4 100644 --- a/packages/google-ai-generativelanguage/src/v1beta2/text_service_client.ts +++ b/packages/google-ai-generativelanguage/src/v1beta2/text_service_client.ts @@ -27,6 +27,7 @@ import type { import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1beta2/text_service_client_config.json`. @@ -51,6 +52,8 @@ export class TextServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -108,8 +111,20 @@ export class TextServiceClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof TextServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'generativelanguage.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -124,7 +139,7 @@ export class TextServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -149,10 +164,10 @@ export class TextServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -263,21 +278,52 @@ export class TextServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-ai-generativelanguage/src/v1beta3/discuss_service_client.ts b/packages/google-ai-generativelanguage/src/v1beta3/discuss_service_client.ts index 58e1365c208..37cbc89fb32 100644 --- a/packages/google-ai-generativelanguage/src/v1beta3/discuss_service_client.ts +++ b/packages/google-ai-generativelanguage/src/v1beta3/discuss_service_client.ts @@ -27,6 +27,7 @@ import type { import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1beta3/discuss_service_client_config.json`. @@ -51,6 +52,8 @@ export class DiscussServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -108,8 +111,20 @@ export class DiscussServiceClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof DiscussServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'generativelanguage.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -124,7 +139,7 @@ export class DiscussServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -149,10 +164,10 @@ export class DiscussServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -269,21 +284,52 @@ export class DiscussServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-ai-generativelanguage/src/v1beta3/model_service_client.ts b/packages/google-ai-generativelanguage/src/v1beta3/model_service_client.ts index aa843fd41a4..a750b8ecbab 100644 --- a/packages/google-ai-generativelanguage/src/v1beta3/model_service_client.ts +++ b/packages/google-ai-generativelanguage/src/v1beta3/model_service_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1beta3/model_service_client_config.json`. @@ -52,6 +53,8 @@ export class ModelServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -110,8 +113,20 @@ export class ModelServiceClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof ModelServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'generativelanguage.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -126,7 +141,7 @@ export class ModelServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -151,10 +166,10 @@ export class ModelServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -328,21 +343,52 @@ export class ModelServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-ai-generativelanguage/src/v1beta3/permission_service_client.ts b/packages/google-ai-generativelanguage/src/v1beta3/permission_service_client.ts index 0b7d5dbac94..a222ae60f16 100644 --- a/packages/google-ai-generativelanguage/src/v1beta3/permission_service_client.ts +++ b/packages/google-ai-generativelanguage/src/v1beta3/permission_service_client.ts @@ -29,6 +29,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1beta3/permission_service_client_config.json`. @@ -50,6 +51,8 @@ export class PermissionServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -107,8 +110,20 @@ export class PermissionServiceClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof PermissionServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'generativelanguage.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -123,7 +138,7 @@ export class PermissionServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -148,10 +163,10 @@ export class PermissionServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -286,21 +301,52 @@ export class PermissionServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-ai-generativelanguage/src/v1beta3/text_service_client.ts b/packages/google-ai-generativelanguage/src/v1beta3/text_service_client.ts index d03b3b74042..0a851945f0e 100644 --- a/packages/google-ai-generativelanguage/src/v1beta3/text_service_client.ts +++ b/packages/google-ai-generativelanguage/src/v1beta3/text_service_client.ts @@ -27,6 +27,7 @@ import type { import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1beta3/text_service_client_config.json`. @@ -51,6 +52,8 @@ export class TextServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -108,8 +111,20 @@ export class TextServiceClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof TextServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'generativelanguage.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -124,7 +139,7 @@ export class TextServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -149,10 +164,10 @@ export class TextServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -274,21 +289,52 @@ export class TextServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'generativelanguage.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-ai-generativelanguage/test/gapic_discuss_service_v1beta.ts b/packages/google-ai-generativelanguage/test/gapic_discuss_service_v1beta.ts index b5b753c7982..b4ff3dcd9d9 100644 --- a/packages/google-ai-generativelanguage/test/gapic_discuss_service_v1beta.ts +++ b/packages/google-ai-generativelanguage/test/gapic_discuss_service_v1beta.ts @@ -66,16 +66,62 @@ function stubSimpleCallWithCallback( describe('v1beta.DiscussServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - discussserviceModule.v1beta.DiscussServiceClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new discussserviceModule.v1beta.DiscussServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - discussserviceModule.v1beta.DiscussServiceClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new discussserviceModule.v1beta.DiscussServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + discussserviceModule.v1beta.DiscussServiceClient.servicePath; + assert.strictEqual(servicePath, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + discussserviceModule.v1beta.DiscussServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new discussserviceModule.v1beta.DiscussServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new discussserviceModule.v1beta.DiscussServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new discussserviceModule.v1beta.DiscussServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-ai-generativelanguage/test/gapic_discuss_service_v1beta2.ts b/packages/google-ai-generativelanguage/test/gapic_discuss_service_v1beta2.ts index a10a1ea154f..b3b8b311f2c 100644 --- a/packages/google-ai-generativelanguage/test/gapic_discuss_service_v1beta2.ts +++ b/packages/google-ai-generativelanguage/test/gapic_discuss_service_v1beta2.ts @@ -66,16 +66,62 @@ function stubSimpleCallWithCallback( describe('v1beta2.DiscussServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - discussserviceModule.v1beta2.DiscussServiceClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new discussserviceModule.v1beta2.DiscussServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - discussserviceModule.v1beta2.DiscussServiceClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new discussserviceModule.v1beta2.DiscussServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + discussserviceModule.v1beta2.DiscussServiceClient.servicePath; + assert.strictEqual(servicePath, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + discussserviceModule.v1beta2.DiscussServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new discussserviceModule.v1beta2.DiscussServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new discussserviceModule.v1beta2.DiscussServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new discussserviceModule.v1beta2.DiscussServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-ai-generativelanguage/test/gapic_discuss_service_v1beta3.ts b/packages/google-ai-generativelanguage/test/gapic_discuss_service_v1beta3.ts index a68a8706d06..205317de376 100644 --- a/packages/google-ai-generativelanguage/test/gapic_discuss_service_v1beta3.ts +++ b/packages/google-ai-generativelanguage/test/gapic_discuss_service_v1beta3.ts @@ -66,16 +66,62 @@ function stubSimpleCallWithCallback( describe('v1beta3.DiscussServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - discussserviceModule.v1beta3.DiscussServiceClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new discussserviceModule.v1beta3.DiscussServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - discussserviceModule.v1beta3.DiscussServiceClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new discussserviceModule.v1beta3.DiscussServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + discussserviceModule.v1beta3.DiscussServiceClient.servicePath; + assert.strictEqual(servicePath, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + discussserviceModule.v1beta3.DiscussServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new discussserviceModule.v1beta3.DiscussServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new discussserviceModule.v1beta3.DiscussServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new discussserviceModule.v1beta3.DiscussServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-ai-generativelanguage/test/gapic_generative_service_v1.ts b/packages/google-ai-generativelanguage/test/gapic_generative_service_v1.ts index 6e22f721f7b..ca71bbba001 100644 --- a/packages/google-ai-generativelanguage/test/gapic_generative_service_v1.ts +++ b/packages/google-ai-generativelanguage/test/gapic_generative_service_v1.ts @@ -89,16 +89,62 @@ function stubServerStreamingCall( describe('v1.GenerativeServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - generativeserviceModule.v1.GenerativeServiceClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new generativeserviceModule.v1.GenerativeServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - generativeserviceModule.v1.GenerativeServiceClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new generativeserviceModule.v1.GenerativeServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + generativeserviceModule.v1.GenerativeServiceClient.servicePath; + assert.strictEqual(servicePath, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + generativeserviceModule.v1.GenerativeServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new generativeserviceModule.v1.GenerativeServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new generativeserviceModule.v1.GenerativeServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new generativeserviceModule.v1.GenerativeServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { @@ -817,11 +863,7 @@ describe('v1.GenerativeServiceClient', () => { const expectedError = new Error('The client has already been closed.'); client.close(); const stream = client.streamGenerateContent(request, { - retry: { - shouldRetryFn: () => { - return false; - }, - }, + retryRequestOptions: {noResponseRetries: 0}, }); const promise = new Promise((resolve, reject) => { stream.on( diff --git a/packages/google-ai-generativelanguage/test/gapic_generative_service_v1beta.ts b/packages/google-ai-generativelanguage/test/gapic_generative_service_v1beta.ts index 1ed3f5a6bbd..72f554e0150 100644 --- a/packages/google-ai-generativelanguage/test/gapic_generative_service_v1beta.ts +++ b/packages/google-ai-generativelanguage/test/gapic_generative_service_v1beta.ts @@ -89,16 +89,64 @@ function stubServerStreamingCall( describe('v1beta.GenerativeServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - generativeserviceModule.v1beta.GenerativeServiceClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = + new generativeserviceModule.v1beta.GenerativeServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - generativeserviceModule.v1beta.GenerativeServiceClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = + new generativeserviceModule.v1beta.GenerativeServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + generativeserviceModule.v1beta.GenerativeServiceClient.servicePath; + assert.strictEqual(servicePath, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + generativeserviceModule.v1beta.GenerativeServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new generativeserviceModule.v1beta.GenerativeServiceClient( + {universeDomain: 'example.com'} + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new generativeserviceModule.v1beta.GenerativeServiceClient( + {universe_domain: 'example.com'} + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new generativeserviceModule.v1beta.GenerativeServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { @@ -1006,11 +1054,7 @@ describe('v1beta.GenerativeServiceClient', () => { const expectedError = new Error('The client has already been closed.'); client.close(); const stream = client.streamGenerateContent(request, { - retry: { - shouldRetryFn: () => { - return false; - }, - }, + retryRequestOptions: {noResponseRetries: 0}, }); const promise = new Promise((resolve, reject) => { stream.on( diff --git a/packages/google-ai-generativelanguage/test/gapic_model_service_v1.ts b/packages/google-ai-generativelanguage/test/gapic_model_service_v1.ts index 137b24a38b1..3d24ff7bf5a 100644 --- a/packages/google-ai-generativelanguage/test/gapic_model_service_v1.ts +++ b/packages/google-ai-generativelanguage/test/gapic_model_service_v1.ts @@ -129,14 +129,62 @@ function stubAsyncIterationCall( describe('v1.ModelServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = modelserviceModule.v1.ModelServiceClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new modelserviceModule.v1.ModelServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = modelserviceModule.v1.ModelServiceClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new modelserviceModule.v1.ModelServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + modelserviceModule.v1.ModelServiceClient.servicePath; + assert.strictEqual(servicePath, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + modelserviceModule.v1.ModelServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new modelserviceModule.v1.ModelServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new modelserviceModule.v1.ModelServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new modelserviceModule.v1.ModelServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-ai-generativelanguage/test/gapic_model_service_v1beta.ts b/packages/google-ai-generativelanguage/test/gapic_model_service_v1beta.ts index 24b19152a47..7c90c751224 100644 --- a/packages/google-ai-generativelanguage/test/gapic_model_service_v1beta.ts +++ b/packages/google-ai-generativelanguage/test/gapic_model_service_v1beta.ts @@ -161,16 +161,62 @@ function stubAsyncIterationCall( describe('v1beta.ModelServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - modelserviceModule.v1beta.ModelServiceClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new modelserviceModule.v1beta.ModelServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - modelserviceModule.v1beta.ModelServiceClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new modelserviceModule.v1beta.ModelServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + modelserviceModule.v1beta.ModelServiceClient.servicePath; + assert.strictEqual(servicePath, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + modelserviceModule.v1beta.ModelServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new modelserviceModule.v1beta.ModelServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new modelserviceModule.v1beta.ModelServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new modelserviceModule.v1beta.ModelServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-ai-generativelanguage/test/gapic_model_service_v1beta2.ts b/packages/google-ai-generativelanguage/test/gapic_model_service_v1beta2.ts index bca354a2142..3fa0c6a3ada 100644 --- a/packages/google-ai-generativelanguage/test/gapic_model_service_v1beta2.ts +++ b/packages/google-ai-generativelanguage/test/gapic_model_service_v1beta2.ts @@ -129,16 +129,62 @@ function stubAsyncIterationCall( describe('v1beta2.ModelServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - modelserviceModule.v1beta2.ModelServiceClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new modelserviceModule.v1beta2.ModelServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - modelserviceModule.v1beta2.ModelServiceClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new modelserviceModule.v1beta2.ModelServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + modelserviceModule.v1beta2.ModelServiceClient.servicePath; + assert.strictEqual(servicePath, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + modelserviceModule.v1beta2.ModelServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new modelserviceModule.v1beta2.ModelServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new modelserviceModule.v1beta2.ModelServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new modelserviceModule.v1beta2.ModelServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-ai-generativelanguage/test/gapic_model_service_v1beta3.ts b/packages/google-ai-generativelanguage/test/gapic_model_service_v1beta3.ts index 7164188f9d5..0c789bd8fa3 100644 --- a/packages/google-ai-generativelanguage/test/gapic_model_service_v1beta3.ts +++ b/packages/google-ai-generativelanguage/test/gapic_model_service_v1beta3.ts @@ -161,16 +161,62 @@ function stubAsyncIterationCall( describe('v1beta3.ModelServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - modelserviceModule.v1beta3.ModelServiceClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new modelserviceModule.v1beta3.ModelServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - modelserviceModule.v1beta3.ModelServiceClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new modelserviceModule.v1beta3.ModelServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + modelserviceModule.v1beta3.ModelServiceClient.servicePath; + assert.strictEqual(servicePath, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + modelserviceModule.v1beta3.ModelServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new modelserviceModule.v1beta3.ModelServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new modelserviceModule.v1beta3.ModelServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new modelserviceModule.v1beta3.ModelServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-ai-generativelanguage/test/gapic_permission_service_v1beta.ts b/packages/google-ai-generativelanguage/test/gapic_permission_service_v1beta.ts index ec363d6ec83..bdb28deaa3d 100644 --- a/packages/google-ai-generativelanguage/test/gapic_permission_service_v1beta.ts +++ b/packages/google-ai-generativelanguage/test/gapic_permission_service_v1beta.ts @@ -129,16 +129,64 @@ function stubAsyncIterationCall( describe('v1beta.PermissionServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - permissionserviceModule.v1beta.PermissionServiceClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = + new permissionserviceModule.v1beta.PermissionServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - permissionserviceModule.v1beta.PermissionServiceClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = + new permissionserviceModule.v1beta.PermissionServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + permissionserviceModule.v1beta.PermissionServiceClient.servicePath; + assert.strictEqual(servicePath, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + permissionserviceModule.v1beta.PermissionServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new permissionserviceModule.v1beta.PermissionServiceClient( + {universeDomain: 'example.com'} + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new permissionserviceModule.v1beta.PermissionServiceClient( + {universe_domain: 'example.com'} + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new permissionserviceModule.v1beta.PermissionServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-ai-generativelanguage/test/gapic_permission_service_v1beta3.ts b/packages/google-ai-generativelanguage/test/gapic_permission_service_v1beta3.ts index 91dab807eca..e7f6e4d924c 100644 --- a/packages/google-ai-generativelanguage/test/gapic_permission_service_v1beta3.ts +++ b/packages/google-ai-generativelanguage/test/gapic_permission_service_v1beta3.ts @@ -129,16 +129,66 @@ function stubAsyncIterationCall( describe('v1beta3.PermissionServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - permissionserviceModule.v1beta3.PermissionServiceClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = + new permissionserviceModule.v1beta3.PermissionServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - permissionserviceModule.v1beta3.PermissionServiceClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = + new permissionserviceModule.v1beta3.PermissionServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + permissionserviceModule.v1beta3.PermissionServiceClient.servicePath; + assert.strictEqual(servicePath, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + permissionserviceModule.v1beta3.PermissionServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new permissionserviceModule.v1beta3.PermissionServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new permissionserviceModule.v1beta3.PermissionServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new permissionserviceModule.v1beta3.PermissionServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-ai-generativelanguage/test/gapic_retriever_service_v1beta.ts b/packages/google-ai-generativelanguage/test/gapic_retriever_service_v1beta.ts index b803ac39b67..39d5ca31086 100644 --- a/packages/google-ai-generativelanguage/test/gapic_retriever_service_v1beta.ts +++ b/packages/google-ai-generativelanguage/test/gapic_retriever_service_v1beta.ts @@ -129,16 +129,62 @@ function stubAsyncIterationCall( describe('v1beta.RetrieverServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - retrieverserviceModule.v1beta.RetrieverServiceClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new retrieverserviceModule.v1beta.RetrieverServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - retrieverserviceModule.v1beta.RetrieverServiceClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new retrieverserviceModule.v1beta.RetrieverServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + retrieverserviceModule.v1beta.RetrieverServiceClient.servicePath; + assert.strictEqual(servicePath, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + retrieverserviceModule.v1beta.RetrieverServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new retrieverserviceModule.v1beta.RetrieverServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new retrieverserviceModule.v1beta.RetrieverServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new retrieverserviceModule.v1beta.RetrieverServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-ai-generativelanguage/test/gapic_text_service_v1beta.ts b/packages/google-ai-generativelanguage/test/gapic_text_service_v1beta.ts index 643f49fbe29..be51cca2f84 100644 --- a/packages/google-ai-generativelanguage/test/gapic_text_service_v1beta.ts +++ b/packages/google-ai-generativelanguage/test/gapic_text_service_v1beta.ts @@ -66,16 +66,62 @@ function stubSimpleCallWithCallback( describe('v1beta.TextServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - textserviceModule.v1beta.TextServiceClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new textserviceModule.v1beta.TextServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - textserviceModule.v1beta.TextServiceClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new textserviceModule.v1beta.TextServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + textserviceModule.v1beta.TextServiceClient.servicePath; + assert.strictEqual(servicePath, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + textserviceModule.v1beta.TextServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new textserviceModule.v1beta.TextServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new textserviceModule.v1beta.TextServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new textserviceModule.v1beta.TextServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-ai-generativelanguage/test/gapic_text_service_v1beta2.ts b/packages/google-ai-generativelanguage/test/gapic_text_service_v1beta2.ts index 8e9e9457412..99818d9069c 100644 --- a/packages/google-ai-generativelanguage/test/gapic_text_service_v1beta2.ts +++ b/packages/google-ai-generativelanguage/test/gapic_text_service_v1beta2.ts @@ -66,16 +66,62 @@ function stubSimpleCallWithCallback( describe('v1beta2.TextServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - textserviceModule.v1beta2.TextServiceClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new textserviceModule.v1beta2.TextServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - textserviceModule.v1beta2.TextServiceClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new textserviceModule.v1beta2.TextServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + textserviceModule.v1beta2.TextServiceClient.servicePath; + assert.strictEqual(servicePath, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + textserviceModule.v1beta2.TextServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new textserviceModule.v1beta2.TextServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new textserviceModule.v1beta2.TextServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new textserviceModule.v1beta2.TextServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-ai-generativelanguage/test/gapic_text_service_v1beta3.ts b/packages/google-ai-generativelanguage/test/gapic_text_service_v1beta3.ts index 53d172e348a..a1bde2e7cd9 100644 --- a/packages/google-ai-generativelanguage/test/gapic_text_service_v1beta3.ts +++ b/packages/google-ai-generativelanguage/test/gapic_text_service_v1beta3.ts @@ -66,16 +66,62 @@ function stubSimpleCallWithCallback( describe('v1beta3.TextServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - textserviceModule.v1beta3.TextServiceClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new textserviceModule.v1beta3.TextServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - textserviceModule.v1beta3.TextServiceClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new textserviceModule.v1beta3.TextServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + textserviceModule.v1beta3.TextServiceClient.servicePath; + assert.strictEqual(servicePath, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + textserviceModule.v1beta3.TextServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new textserviceModule.v1beta3.TextServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new textserviceModule.v1beta3.TextServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new textserviceModule.v1beta3.TextServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_access_bindings.js b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_access_bindings.js index 43883f1e59b..8fdf9e7bb02 100644 --- a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_access_bindings.js +++ b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_access_bindings.js @@ -62,7 +62,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listAccessBindingsAsync(request); + const iterable = adminClient.listAccessBindingsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_account_summaries.js b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_account_summaries.js index 9cb53060bdd..eb086ae9250 100644 --- a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_account_summaries.js +++ b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_account_summaries.js @@ -55,7 +55,7 @@ function main() { }; // Run request - const iterable = await adminClient.listAccountSummariesAsync(request); + const iterable = adminClient.listAccountSummariesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_accounts.js b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_accounts.js index ef257e6c55c..8af94754892 100644 --- a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_accounts.js +++ b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_accounts.js @@ -61,7 +61,7 @@ function main() { }; // Run request - const iterable = await adminClient.listAccountsAsync(request); + const iterable = adminClient.listAccountsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_ad_sense_links.js b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_ad_sense_links.js index c82f940b9e1..d19a93e62f4 100644 --- a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_ad_sense_links.js +++ b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_ad_sense_links.js @@ -61,7 +61,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listAdSenseLinksAsync(request); + const iterable = adminClient.listAdSenseLinksAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_audiences.js b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_audiences.js index cf15c01a198..e3e1a864022 100644 --- a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_audiences.js +++ b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_audiences.js @@ -59,7 +59,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listAudiencesAsync(request); + const iterable = adminClient.listAudiencesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_big_query_links.js b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_big_query_links.js index 5d1df889b27..35b0c4f2d8c 100644 --- a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_big_query_links.js +++ b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_big_query_links.js @@ -62,7 +62,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listBigQueryLinksAsync(request); + const iterable = adminClient.listBigQueryLinksAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_calculated_metrics.js b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_calculated_metrics.js index ead50de6915..341e1968800 100644 --- a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_calculated_metrics.js +++ b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_calculated_metrics.js @@ -59,7 +59,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listCalculatedMetricsAsync(request); + const iterable = adminClient.listCalculatedMetricsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_channel_groups.js b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_channel_groups.js index 4c6d6c5dfc4..6a04088af21 100644 --- a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_channel_groups.js +++ b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_channel_groups.js @@ -60,7 +60,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listChannelGroupsAsync(request); + const iterable = adminClient.listChannelGroupsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_conversion_events.js b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_conversion_events.js index 74c90ab5dbd..68e7a76d189 100644 --- a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_conversion_events.js +++ b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_conversion_events.js @@ -60,7 +60,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listConversionEventsAsync(request); + const iterable = adminClient.listConversionEventsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_custom_dimensions.js b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_custom_dimensions.js index 73ebdb11897..bd2ba3cd967 100644 --- a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_custom_dimensions.js +++ b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_custom_dimensions.js @@ -59,7 +59,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listCustomDimensionsAsync(request); + const iterable = adminClient.listCustomDimensionsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_custom_metrics.js b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_custom_metrics.js index e629bf8a3ef..5522c38c22f 100644 --- a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_custom_metrics.js +++ b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_custom_metrics.js @@ -59,7 +59,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listCustomMetricsAsync(request); + const iterable = adminClient.listCustomMetricsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_data_streams.js b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_data_streams.js index 5636388e556..3dfc479a79e 100644 --- a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_data_streams.js +++ b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_data_streams.js @@ -59,7 +59,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listDataStreamsAsync(request); + const iterable = adminClient.listDataStreamsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_display_video360_advertiser_link_proposals.js b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_display_video360_advertiser_link_proposals.js index f768a258226..d7633279609 100644 --- a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_display_video360_advertiser_link_proposals.js +++ b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_display_video360_advertiser_link_proposals.js @@ -61,7 +61,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listDisplayVideo360AdvertiserLinkProposalsAsync(request); + const iterable = adminClient.listDisplayVideo360AdvertiserLinkProposalsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_display_video360_advertiser_links.js b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_display_video360_advertiser_links.js index 4815c866876..f95ae8b6afd 100644 --- a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_display_video360_advertiser_links.js +++ b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_display_video360_advertiser_links.js @@ -60,7 +60,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listDisplayVideo360AdvertiserLinksAsync(request); + const iterable = adminClient.listDisplayVideo360AdvertiserLinksAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_event_create_rules.js b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_event_create_rules.js index f2c649ac762..4709d5cdff4 100644 --- a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_event_create_rules.js +++ b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_event_create_rules.js @@ -59,7 +59,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listEventCreateRulesAsync(request); + const iterable = adminClient.listEventCreateRulesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_expanded_data_sets.js b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_expanded_data_sets.js index 169b02d24ac..9f6c0dbe6a0 100644 --- a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_expanded_data_sets.js +++ b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_expanded_data_sets.js @@ -59,7 +59,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listExpandedDataSetsAsync(request); + const iterable = adminClient.listExpandedDataSetsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_firebase_links.js b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_firebase_links.js index 06d0dc99301..4de65515b9c 100644 --- a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_firebase_links.js +++ b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_firebase_links.js @@ -61,7 +61,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listFirebaseLinksAsync(request); + const iterable = adminClient.listFirebaseLinksAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_google_ads_links.js b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_google_ads_links.js index d7d1a416aae..fd721e6264f 100644 --- a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_google_ads_links.js +++ b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_google_ads_links.js @@ -59,7 +59,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listGoogleAdsLinksAsync(request); + const iterable = adminClient.listGoogleAdsLinksAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_measurement_protocol_secrets.js b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_measurement_protocol_secrets.js index a83ac891acd..dd39e19b213 100644 --- a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_measurement_protocol_secrets.js +++ b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_measurement_protocol_secrets.js @@ -61,7 +61,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listMeasurementProtocolSecretsAsync(request); + const iterable = adminClient.listMeasurementProtocolSecretsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_properties.js b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_properties.js index 906648052e0..f3d6c57dcb9 100644 --- a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_properties.js +++ b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_properties.js @@ -80,7 +80,7 @@ function main(filter) { }; // Run request - const iterable = await adminClient.listPropertiesAsync(request); + const iterable = adminClient.listPropertiesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_rollup_property_source_links.js b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_rollup_property_source_links.js index 5fdb0589791..319698e1779 100644 --- a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_rollup_property_source_links.js +++ b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_rollup_property_source_links.js @@ -62,7 +62,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listRollupPropertySourceLinksAsync(request); + const iterable = adminClient.listRollupPropertySourceLinksAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_s_k_ad_network_conversion_value_schemas.js b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_s_k_ad_network_conversion_value_schemas.js index 7bb64448474..7b7ce7d5838 100644 --- a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_s_k_ad_network_conversion_value_schemas.js +++ b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_s_k_ad_network_conversion_value_schemas.js @@ -64,7 +64,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listSKAdNetworkConversionValueSchemasAsync(request); + const iterable = adminClient.listSKAdNetworkConversionValueSchemasAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_search_ads360_links.js b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_search_ads360_links.js index 360e08c01a3..1ee2eb61ef4 100644 --- a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_search_ads360_links.js +++ b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_search_ads360_links.js @@ -60,7 +60,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listSearchAds360LinksAsync(request); + const iterable = adminClient.listSearchAds360LinksAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_subproperty_event_filters.js b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_subproperty_event_filters.js index 77494cf0e2b..ad6fba451ef 100644 --- a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_subproperty_event_filters.js +++ b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.list_subproperty_event_filters.js @@ -63,7 +63,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listSubpropertyEventFiltersAsync(request); + const iterable = adminClient.listSubpropertyEventFiltersAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.search_change_history_events.js b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.search_change_history_events.js index 40ccc6f380c..b575bee2ea2 100644 --- a/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.search_change_history_events.js +++ b/packages/google-analytics-admin/samples/generated/v1alpha/analytics_admin_service.search_change_history_events.js @@ -92,7 +92,7 @@ function main(account) { }; // Run request - const iterable = await adminClient.searchChangeHistoryEventsAsync(request); + const iterable = adminClient.searchChangeHistoryEventsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_account_summaries.js b/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_account_summaries.js index 11c784feb12..8b0c6f308c2 100644 --- a/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_account_summaries.js +++ b/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_account_summaries.js @@ -55,7 +55,7 @@ function main() { }; // Run request - const iterable = await adminClient.listAccountSummariesAsync(request); + const iterable = adminClient.listAccountSummariesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_accounts.js b/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_accounts.js index 7771180461a..1a0c000d391 100644 --- a/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_accounts.js +++ b/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_accounts.js @@ -61,7 +61,7 @@ function main() { }; // Run request - const iterable = await adminClient.listAccountsAsync(request); + const iterable = adminClient.listAccountsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_conversion_events.js b/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_conversion_events.js index ced0f46e8dd..55acf483498 100644 --- a/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_conversion_events.js +++ b/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_conversion_events.js @@ -60,7 +60,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listConversionEventsAsync(request); + const iterable = adminClient.listConversionEventsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_custom_dimensions.js b/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_custom_dimensions.js index cac88cc1f30..04c65cb8b9a 100644 --- a/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_custom_dimensions.js +++ b/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_custom_dimensions.js @@ -59,7 +59,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listCustomDimensionsAsync(request); + const iterable = adminClient.listCustomDimensionsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_custom_metrics.js b/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_custom_metrics.js index 384f12c6a40..7b040d6bf50 100644 --- a/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_custom_metrics.js +++ b/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_custom_metrics.js @@ -59,7 +59,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listCustomMetricsAsync(request); + const iterable = adminClient.listCustomMetricsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_data_streams.js b/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_data_streams.js index 6897ebf9ccb..3eeeb1cab8f 100644 --- a/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_data_streams.js +++ b/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_data_streams.js @@ -59,7 +59,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listDataStreamsAsync(request); + const iterable = adminClient.listDataStreamsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_firebase_links.js b/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_firebase_links.js index 746059c84ef..459967a2337 100644 --- a/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_firebase_links.js +++ b/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_firebase_links.js @@ -61,7 +61,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listFirebaseLinksAsync(request); + const iterable = adminClient.listFirebaseLinksAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_google_ads_links.js b/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_google_ads_links.js index 18540c58af8..30432a701f1 100644 --- a/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_google_ads_links.js +++ b/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_google_ads_links.js @@ -59,7 +59,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listGoogleAdsLinksAsync(request); + const iterable = adminClient.listGoogleAdsLinksAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_measurement_protocol_secrets.js b/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_measurement_protocol_secrets.js index f61a1500126..206510c5e70 100644 --- a/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_measurement_protocol_secrets.js +++ b/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_measurement_protocol_secrets.js @@ -61,7 +61,7 @@ function main(parent) { }; // Run request - const iterable = await adminClient.listMeasurementProtocolSecretsAsync(request); + const iterable = adminClient.listMeasurementProtocolSecretsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_properties.js b/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_properties.js index a55b465f6b1..834a47ad359 100644 --- a/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_properties.js +++ b/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.list_properties.js @@ -80,7 +80,7 @@ function main(filter) { }; // Run request - const iterable = await adminClient.listPropertiesAsync(request); + const iterable = adminClient.listPropertiesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.search_change_history_events.js b/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.search_change_history_events.js index a30738cdb55..477b54b0be7 100644 --- a/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.search_change_history_events.js +++ b/packages/google-analytics-admin/samples/generated/v1beta/analytics_admin_service.search_change_history_events.js @@ -90,7 +90,7 @@ function main(account) { }; // Run request - const iterable = await adminClient.searchChangeHistoryEventsAsync(request); + const iterable = adminClient.searchChangeHistoryEventsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-admin/src/v1alpha/analytics_admin_service_client.ts b/packages/google-analytics-admin/src/v1alpha/analytics_admin_service_client.ts index 3458261e25a..80efe6cfa7f 100644 --- a/packages/google-analytics-admin/src/v1alpha/analytics_admin_service_client.ts +++ b/packages/google-analytics-admin/src/v1alpha/analytics_admin_service_client.ts @@ -29,6 +29,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1alpha/analytics_admin_service_client_config.json`. @@ -50,6 +51,8 @@ export class AnalyticsAdminServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -108,8 +111,20 @@ export class AnalyticsAdminServiceClient { // Ensure that options include all the required fields. const staticMembers = this .constructor as typeof AnalyticsAdminServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'analyticsadmin.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -124,7 +139,7 @@ export class AnalyticsAdminServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -149,10 +164,10 @@ export class AnalyticsAdminServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -630,21 +645,52 @@ export class AnalyticsAdminServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'analyticsadmin.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'analyticsadmin.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-analytics-admin/src/v1beta/analytics_admin_service_client.ts b/packages/google-analytics-admin/src/v1beta/analytics_admin_service_client.ts index b291e5d6411..6bd4a93a8c9 100644 --- a/packages/google-analytics-admin/src/v1beta/analytics_admin_service_client.ts +++ b/packages/google-analytics-admin/src/v1beta/analytics_admin_service_client.ts @@ -29,6 +29,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1beta/analytics_admin_service_client_config.json`. @@ -50,6 +51,8 @@ export class AnalyticsAdminServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -108,8 +111,20 @@ export class AnalyticsAdminServiceClient { // Ensure that options include all the required fields. const staticMembers = this .constructor as typeof AnalyticsAdminServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'analyticsadmin.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -124,7 +139,7 @@ export class AnalyticsAdminServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -149,10 +164,10 @@ export class AnalyticsAdminServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -409,21 +424,52 @@ export class AnalyticsAdminServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'analyticsadmin.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'analyticsadmin.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-analytics-admin/test/gapic_analytics_admin_service_v1alpha.ts b/packages/google-analytics-admin/test/gapic_analytics_admin_service_v1alpha.ts index eec5d2b7eea..a845cf85e3b 100644 --- a/packages/google-analytics-admin/test/gapic_analytics_admin_service_v1alpha.ts +++ b/packages/google-analytics-admin/test/gapic_analytics_admin_service_v1alpha.ts @@ -129,18 +129,68 @@ function stubAsyncIterationCall( describe('v1alpha.AnalyticsAdminServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - analyticsadminserviceModule.v1alpha.AnalyticsAdminServiceClient - .servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = + new analyticsadminserviceModule.v1alpha.AnalyticsAdminServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'analyticsadmin.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - analyticsadminserviceModule.v1alpha.AnalyticsAdminServiceClient - .apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = + new analyticsadminserviceModule.v1alpha.AnalyticsAdminServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + analyticsadminserviceModule.v1alpha.AnalyticsAdminServiceClient + .servicePath; + assert.strictEqual(servicePath, 'analyticsadmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + analyticsadminserviceModule.v1alpha.AnalyticsAdminServiceClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'analyticsadmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new analyticsadminserviceModule.v1alpha.AnalyticsAdminServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'analyticsadmin.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new analyticsadminserviceModule.v1alpha.AnalyticsAdminServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'analyticsadmin.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new analyticsadminserviceModule.v1alpha.AnalyticsAdminServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-analytics-admin/test/gapic_analytics_admin_service_v1beta.ts b/packages/google-analytics-admin/test/gapic_analytics_admin_service_v1beta.ts index 794d8c76f19..f4176611ec3 100644 --- a/packages/google-analytics-admin/test/gapic_analytics_admin_service_v1beta.ts +++ b/packages/google-analytics-admin/test/gapic_analytics_admin_service_v1beta.ts @@ -129,18 +129,68 @@ function stubAsyncIterationCall( describe('v1beta.AnalyticsAdminServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - analyticsadminserviceModule.v1beta.AnalyticsAdminServiceClient - .servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = + new analyticsadminserviceModule.v1beta.AnalyticsAdminServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'analyticsadmin.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - analyticsadminserviceModule.v1beta.AnalyticsAdminServiceClient - .apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = + new analyticsadminserviceModule.v1beta.AnalyticsAdminServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + analyticsadminserviceModule.v1beta.AnalyticsAdminServiceClient + .servicePath; + assert.strictEqual(servicePath, 'analyticsadmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + analyticsadminserviceModule.v1beta.AnalyticsAdminServiceClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'analyticsadmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new analyticsadminserviceModule.v1beta.AnalyticsAdminServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'analyticsadmin.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new analyticsadminserviceModule.v1beta.AnalyticsAdminServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'analyticsadmin.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new analyticsadminserviceModule.v1beta.AnalyticsAdminServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-analytics-data/samples/generated/v1alpha/alpha_analytics_data.list_audience_lists.js b/packages/google-analytics-data/samples/generated/v1alpha/alpha_analytics_data.list_audience_lists.js index ca21140e9b9..b7d8e205836 100644 --- a/packages/google-analytics-data/samples/generated/v1alpha/alpha_analytics_data.list_audience_lists.js +++ b/packages/google-analytics-data/samples/generated/v1alpha/alpha_analytics_data.list_audience_lists.js @@ -61,7 +61,7 @@ function main(parent) { }; // Run request - const iterable = await dataClient.listAudienceListsAsync(request); + const iterable = dataClient.listAudienceListsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-data/samples/generated/v1alpha/alpha_analytics_data.list_recurring_audience_lists.js b/packages/google-analytics-data/samples/generated/v1alpha/alpha_analytics_data.list_recurring_audience_lists.js index f16474853b1..6ecaf7ac355 100644 --- a/packages/google-analytics-data/samples/generated/v1alpha/alpha_analytics_data.list_recurring_audience_lists.js +++ b/packages/google-analytics-data/samples/generated/v1alpha/alpha_analytics_data.list_recurring_audience_lists.js @@ -63,7 +63,7 @@ function main(parent) { }; // Run request - const iterable = await dataClient.listRecurringAudienceListsAsync(request); + const iterable = dataClient.listRecurringAudienceListsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-data/samples/generated/v1beta/beta_analytics_data.list_audience_exports.js b/packages/google-analytics-data/samples/generated/v1beta/beta_analytics_data.list_audience_exports.js index c31e6442169..598a06944b0 100644 --- a/packages/google-analytics-data/samples/generated/v1beta/beta_analytics_data.list_audience_exports.js +++ b/packages/google-analytics-data/samples/generated/v1beta/beta_analytics_data.list_audience_exports.js @@ -61,7 +61,7 @@ function main(parent) { }; // Run request - const iterable = await dataClient.listAudienceExportsAsync(request); + const iterable = dataClient.listAudienceExportsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-analytics-data/src/v1alpha/alpha_analytics_data_client.ts b/packages/google-analytics-data/src/v1alpha/alpha_analytics_data_client.ts index 8a58860b327..15b3a65c407 100644 --- a/packages/google-analytics-data/src/v1alpha/alpha_analytics_data_client.ts +++ b/packages/google-analytics-data/src/v1alpha/alpha_analytics_data_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1alpha/alpha_analytics_data_client_config.json`. @@ -52,6 +53,8 @@ export class AlphaAnalyticsDataClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -110,8 +113,20 @@ export class AlphaAnalyticsDataClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof AlphaAnalyticsDataClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'analyticsdata.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -126,7 +141,7 @@ export class AlphaAnalyticsDataClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -151,10 +166,10 @@ export class AlphaAnalyticsDataClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -332,21 +347,52 @@ export class AlphaAnalyticsDataClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'analyticsdata.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'analyticsdata.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-analytics-data/src/v1beta/beta_analytics_data_client.ts b/packages/google-analytics-data/src/v1beta/beta_analytics_data_client.ts index 0d35baf34c6..a1337b57125 100644 --- a/packages/google-analytics-data/src/v1beta/beta_analytics_data_client.ts +++ b/packages/google-analytics-data/src/v1beta/beta_analytics_data_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1beta/beta_analytics_data_client_config.json`. @@ -52,6 +53,8 @@ export class BetaAnalyticsDataClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -110,8 +113,20 @@ export class BetaAnalyticsDataClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof BetaAnalyticsDataClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'analyticsdata.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -126,7 +141,7 @@ export class BetaAnalyticsDataClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -151,10 +166,10 @@ export class BetaAnalyticsDataClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -328,21 +343,52 @@ export class BetaAnalyticsDataClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'analyticsdata.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'analyticsdata.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-analytics-data/test/gapic_alpha_analytics_data_v1alpha.ts b/packages/google-analytics-data/test/gapic_alpha_analytics_data_v1alpha.ts index 2be37502fa5..5d8df0675db 100644 --- a/packages/google-analytics-data/test/gapic_alpha_analytics_data_v1alpha.ts +++ b/packages/google-analytics-data/test/gapic_alpha_analytics_data_v1alpha.ts @@ -161,16 +161,66 @@ function stubAsyncIterationCall( describe('v1alpha.AlphaAnalyticsDataClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - alphaanalyticsdataModule.v1alpha.AlphaAnalyticsDataClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = + new alphaanalyticsdataModule.v1alpha.AlphaAnalyticsDataClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'analyticsdata.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - alphaanalyticsdataModule.v1alpha.AlphaAnalyticsDataClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = + new alphaanalyticsdataModule.v1alpha.AlphaAnalyticsDataClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + alphaanalyticsdataModule.v1alpha.AlphaAnalyticsDataClient.servicePath; + assert.strictEqual(servicePath, 'analyticsdata.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + alphaanalyticsdataModule.v1alpha.AlphaAnalyticsDataClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'analyticsdata.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new alphaanalyticsdataModule.v1alpha.AlphaAnalyticsDataClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'analyticsdata.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new alphaanalyticsdataModule.v1alpha.AlphaAnalyticsDataClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'analyticsdata.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new alphaanalyticsdataModule.v1alpha.AlphaAnalyticsDataClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-analytics-data/test/gapic_beta_analytics_data_v1beta.ts b/packages/google-analytics-data/test/gapic_beta_analytics_data_v1beta.ts index 3cc7800fae4..843efa6ffd2 100644 --- a/packages/google-analytics-data/test/gapic_beta_analytics_data_v1beta.ts +++ b/packages/google-analytics-data/test/gapic_beta_analytics_data_v1beta.ts @@ -161,16 +161,64 @@ function stubAsyncIterationCall( describe('v1beta.BetaAnalyticsDataClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - betaanalyticsdataModule.v1beta.BetaAnalyticsDataClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = + new betaanalyticsdataModule.v1beta.BetaAnalyticsDataClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'analyticsdata.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - betaanalyticsdataModule.v1beta.BetaAnalyticsDataClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = + new betaanalyticsdataModule.v1beta.BetaAnalyticsDataClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + betaanalyticsdataModule.v1beta.BetaAnalyticsDataClient.servicePath; + assert.strictEqual(servicePath, 'analyticsdata.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + betaanalyticsdataModule.v1beta.BetaAnalyticsDataClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'analyticsdata.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new betaanalyticsdataModule.v1beta.BetaAnalyticsDataClient( + {universeDomain: 'example.com'} + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'analyticsdata.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new betaanalyticsdataModule.v1beta.BetaAnalyticsDataClient( + {universe_domain: 'example.com'} + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'analyticsdata.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new betaanalyticsdataModule.v1beta.BetaAnalyticsDataClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-api-apikeys/samples/generated/v2/api_keys.list_keys.js b/packages/google-api-apikeys/samples/generated/v2/api_keys.list_keys.js index 8b46c537b37..8a2e153bf13 100644 --- a/packages/google-api-apikeys/samples/generated/v2/api_keys.list_keys.js +++ b/packages/google-api-apikeys/samples/generated/v2/api_keys.list_keys.js @@ -59,7 +59,7 @@ function main(parent) { }; // Run request - const iterable = await apikeysClient.listKeysAsync(request); + const iterable = apikeysClient.listKeysAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-api-apikeys/src/v2/api_keys_client.ts b/packages/google-api-apikeys/src/v2/api_keys_client.ts index db075b550bf..cfa2c21f80a 100644 --- a/packages/google-api-apikeys/src/v2/api_keys_client.ts +++ b/packages/google-api-apikeys/src/v2/api_keys_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v2/api_keys_client_config.json`. @@ -52,6 +53,8 @@ export class ApiKeysClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -110,8 +113,20 @@ export class ApiKeysClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof ApiKeysClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'apikeys.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -126,7 +141,7 @@ export class ApiKeysClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -151,10 +166,10 @@ export class ApiKeysClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -363,21 +378,52 @@ export class ApiKeysClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'apikeys.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'apikeys.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-api-apikeys/test/gapic_api_keys_v2.ts b/packages/google-api-apikeys/test/gapic_api_keys_v2.ts index cbaaa0cf0eb..248ddf1fe8e 100644 --- a/packages/google-api-apikeys/test/gapic_api_keys_v2.ts +++ b/packages/google-api-apikeys/test/gapic_api_keys_v2.ts @@ -161,14 +161,60 @@ function stubAsyncIterationCall( describe('v2.ApiKeysClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = apikeysModule.v2.ApiKeysClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new apikeysModule.v2.ApiKeysClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'apikeys.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = apikeysModule.v2.ApiKeysClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new apikeysModule.v2.ApiKeysClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = apikeysModule.v2.ApiKeysClient.servicePath; + assert.strictEqual(servicePath, 'apikeys.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = apikeysModule.v2.ApiKeysClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'apikeys.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new apikeysModule.v2.ApiKeysClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'apikeys.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new apikeysModule.v2.ApiKeysClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'apikeys.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new apikeysModule.v2.ApiKeysClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-api-cloudquotas/samples/generated/v1/cloud_quotas.list_quota_infos.js b/packages/google-api-cloudquotas/samples/generated/v1/cloud_quotas.list_quota_infos.js index 486e890d751..436fb6432fc 100644 --- a/packages/google-api-cloudquotas/samples/generated/v1/cloud_quotas.list_quota_infos.js +++ b/packages/google-api-cloudquotas/samples/generated/v1/cloud_quotas.list_quota_infos.js @@ -61,7 +61,7 @@ function main(parent) { }; // Run request - const iterable = await cloudquotasClient.listQuotaInfosAsync(request); + const iterable = cloudquotasClient.listQuotaInfosAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-api-cloudquotas/samples/generated/v1/cloud_quotas.list_quota_preferences.js b/packages/google-api-cloudquotas/samples/generated/v1/cloud_quotas.list_quota_preferences.js index 8886ace1911..6fb528e42b0 100644 --- a/packages/google-api-cloudquotas/samples/generated/v1/cloud_quotas.list_quota_preferences.js +++ b/packages/google-api-cloudquotas/samples/generated/v1/cloud_quotas.list_quota_preferences.js @@ -80,7 +80,7 @@ function main(parent) { }; // Run request - const iterable = await cloudquotasClient.listQuotaPreferencesAsync(request); + const iterable = cloudquotasClient.listQuotaPreferencesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-api-cloudquotas/src/v1/cloud_quotas_client.ts b/packages/google-api-cloudquotas/src/v1/cloud_quotas_client.ts index 94e5af099e8..5f8430b7cae 100644 --- a/packages/google-api-cloudquotas/src/v1/cloud_quotas_client.ts +++ b/packages/google-api-cloudquotas/src/v1/cloud_quotas_client.ts @@ -29,6 +29,7 @@ import type { 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_quotas_client_config.json`. @@ -56,6 +57,8 @@ export class CloudQuotasClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -113,8 +116,20 @@ export class CloudQuotasClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof CloudQuotasClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'cloudquotas.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -129,7 +144,7 @@ export class CloudQuotasClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -154,10 +169,10 @@ export class CloudQuotasClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -319,21 +334,52 @@ export class CloudQuotasClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'cloudquotas.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'cloudquotas.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-api-cloudquotas/test/gapic_cloud_quotas_v1.ts b/packages/google-api-cloudquotas/test/gapic_cloud_quotas_v1.ts index 6d418fb196d..30ed1b8ee65 100644 --- a/packages/google-api-cloudquotas/test/gapic_cloud_quotas_v1.ts +++ b/packages/google-api-cloudquotas/test/gapic_cloud_quotas_v1.ts @@ -129,14 +129,60 @@ function stubAsyncIterationCall( describe('v1.CloudQuotasClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = cloudquotasModule.v1.CloudQuotasClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new cloudquotasModule.v1.CloudQuotasClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudquotas.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = cloudquotasModule.v1.CloudQuotasClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new cloudquotasModule.v1.CloudQuotasClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = cloudquotasModule.v1.CloudQuotasClient.servicePath; + assert.strictEqual(servicePath, 'cloudquotas.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = cloudquotasModule.v1.CloudQuotasClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudquotas.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new cloudquotasModule.v1.CloudQuotasClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudquotas.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new cloudquotasModule.v1.CloudQuotasClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudquotas.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new cloudquotasModule.v1.CloudQuotasClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-api-servicecontrol/src/v1/quota_controller_client.ts b/packages/google-api-servicecontrol/src/v1/quota_controller_client.ts index 75c09fafe98..2f35168a0bd 100644 --- a/packages/google-api-servicecontrol/src/v1/quota_controller_client.ts +++ b/packages/google-api-servicecontrol/src/v1/quota_controller_client.ts @@ -27,6 +27,7 @@ import type { import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/quota_controller_client_config.json`. @@ -51,6 +52,8 @@ export class QuotaControllerClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -107,8 +110,20 @@ export class QuotaControllerClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof QuotaControllerClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'servicecontrol.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -123,7 +138,7 @@ export class QuotaControllerClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -148,10 +163,10 @@ export class QuotaControllerClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -254,21 +269,52 @@ export class QuotaControllerClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'servicecontrol.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'servicecontrol.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-api-servicecontrol/src/v1/service_controller_client.ts b/packages/google-api-servicecontrol/src/v1/service_controller_client.ts index 7b48c3055e3..5492d52950e 100644 --- a/packages/google-api-servicecontrol/src/v1/service_controller_client.ts +++ b/packages/google-api-servicecontrol/src/v1/service_controller_client.ts @@ -27,6 +27,7 @@ import type { import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/service_controller_client_config.json`. @@ -51,6 +52,8 @@ export class ServiceControllerClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -107,8 +110,20 @@ export class ServiceControllerClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof ServiceControllerClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'servicecontrol.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -123,7 +138,7 @@ export class ServiceControllerClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -148,10 +163,10 @@ export class ServiceControllerClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -254,21 +269,52 @@ export class ServiceControllerClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'servicecontrol.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'servicecontrol.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-api-servicecontrol/src/v2/service_controller_client.ts b/packages/google-api-servicecontrol/src/v2/service_controller_client.ts index c93d19288ec..66079a13c1c 100644 --- a/packages/google-api-servicecontrol/src/v2/service_controller_client.ts +++ b/packages/google-api-servicecontrol/src/v2/service_controller_client.ts @@ -27,6 +27,7 @@ import type { import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v2/service_controller_client_config.json`. @@ -55,6 +56,8 @@ export class ServiceControllerClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -111,8 +114,20 @@ export class ServiceControllerClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof ServiceControllerClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'servicecontrol.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -127,7 +142,7 @@ export class ServiceControllerClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -152,10 +167,10 @@ export class ServiceControllerClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -258,21 +273,52 @@ export class ServiceControllerClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'servicecontrol.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'servicecontrol.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-api-servicecontrol/test/gapic_quota_controller_v1.ts b/packages/google-api-servicecontrol/test/gapic_quota_controller_v1.ts index f3fa7894c15..1eec84bb518 100644 --- a/packages/google-api-servicecontrol/test/gapic_quota_controller_v1.ts +++ b/packages/google-api-servicecontrol/test/gapic_quota_controller_v1.ts @@ -66,16 +66,62 @@ function stubSimpleCallWithCallback( describe('v1.QuotaControllerClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - quotacontrollerModule.v1.QuotaControllerClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new quotacontrollerModule.v1.QuotaControllerClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'servicecontrol.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - quotacontrollerModule.v1.QuotaControllerClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new quotacontrollerModule.v1.QuotaControllerClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + quotacontrollerModule.v1.QuotaControllerClient.servicePath; + assert.strictEqual(servicePath, 'servicecontrol.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + quotacontrollerModule.v1.QuotaControllerClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'servicecontrol.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new quotacontrollerModule.v1.QuotaControllerClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'servicecontrol.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new quotacontrollerModule.v1.QuotaControllerClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'servicecontrol.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new quotacontrollerModule.v1.QuotaControllerClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-api-servicecontrol/test/gapic_service_controller_v1.ts b/packages/google-api-servicecontrol/test/gapic_service_controller_v1.ts index e11c4440e67..a3ce6e3883c 100644 --- a/packages/google-api-servicecontrol/test/gapic_service_controller_v1.ts +++ b/packages/google-api-servicecontrol/test/gapic_service_controller_v1.ts @@ -66,16 +66,62 @@ function stubSimpleCallWithCallback( describe('v1.ServiceControllerClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - servicecontrollerModule.v1.ServiceControllerClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new servicecontrollerModule.v1.ServiceControllerClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'servicecontrol.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - servicecontrollerModule.v1.ServiceControllerClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new servicecontrollerModule.v1.ServiceControllerClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + servicecontrollerModule.v1.ServiceControllerClient.servicePath; + assert.strictEqual(servicePath, 'servicecontrol.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + servicecontrollerModule.v1.ServiceControllerClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'servicecontrol.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new servicecontrollerModule.v1.ServiceControllerClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'servicecontrol.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new servicecontrollerModule.v1.ServiceControllerClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'servicecontrol.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new servicecontrollerModule.v1.ServiceControllerClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-api-servicecontrol/test/gapic_service_controller_v2.ts b/packages/google-api-servicecontrol/test/gapic_service_controller_v2.ts index 09526ce7f3c..e7851b2c368 100644 --- a/packages/google-api-servicecontrol/test/gapic_service_controller_v2.ts +++ b/packages/google-api-servicecontrol/test/gapic_service_controller_v2.ts @@ -66,16 +66,62 @@ function stubSimpleCallWithCallback( describe('v2.ServiceControllerClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - servicecontrollerModule.v2.ServiceControllerClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new servicecontrollerModule.v2.ServiceControllerClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'servicecontrol.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - servicecontrollerModule.v2.ServiceControllerClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new servicecontrollerModule.v2.ServiceControllerClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + servicecontrollerModule.v2.ServiceControllerClient.servicePath; + assert.strictEqual(servicePath, 'servicecontrol.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + servicecontrollerModule.v2.ServiceControllerClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'servicecontrol.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new servicecontrollerModule.v2.ServiceControllerClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'servicecontrol.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new servicecontrollerModule.v2.ServiceControllerClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'servicecontrol.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new servicecontrollerModule.v2.ServiceControllerClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-api-servicemanagement/samples/generated/v1/service_manager.list_service_configs.js b/packages/google-api-servicemanagement/samples/generated/v1/service_manager.list_service_configs.js index 4cd3e797688..b0b2e955b1f 100644 --- a/packages/google-api-servicemanagement/samples/generated/v1/service_manager.list_service_configs.js +++ b/packages/google-api-servicemanagement/samples/generated/v1/service_manager.list_service_configs.js @@ -57,7 +57,7 @@ function main(serviceName) { }; // Run request - const iterable = await servicemanagementClient.listServiceConfigsAsync(request); + const iterable = servicemanagementClient.listServiceConfigsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-api-servicemanagement/samples/generated/v1/service_manager.list_service_rollouts.js b/packages/google-api-servicemanagement/samples/generated/v1/service_manager.list_service_rollouts.js index ec3fbc64d2f..288fea4f1d6 100644 --- a/packages/google-api-servicemanagement/samples/generated/v1/service_manager.list_service_rollouts.js +++ b/packages/google-api-servicemanagement/samples/generated/v1/service_manager.list_service_rollouts.js @@ -69,7 +69,7 @@ function main(serviceName, filter) { }; // Run request - const iterable = await servicemanagementClient.listServiceRolloutsAsync(request); + const iterable = servicemanagementClient.listServiceRolloutsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-api-servicemanagement/samples/generated/v1/service_manager.list_services.js b/packages/google-api-servicemanagement/samples/generated/v1/service_manager.list_services.js index d56a1a751db..38302cf6447 100644 --- a/packages/google-api-servicemanagement/samples/generated/v1/service_manager.list_services.js +++ b/packages/google-api-servicemanagement/samples/generated/v1/service_manager.list_services.js @@ -62,7 +62,7 @@ function main() { }; // Run request - const iterable = await servicemanagementClient.listServicesAsync(request); + const iterable = servicemanagementClient.listServicesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-api-servicemanagement/src/v1/service_manager_client.ts b/packages/google-api-servicemanagement/src/v1/service_manager_client.ts index 9518c3d14bb..d8a950765a9 100644 --- a/packages/google-api-servicemanagement/src/v1/service_manager_client.ts +++ b/packages/google-api-servicemanagement/src/v1/service_manager_client.ts @@ -33,6 +33,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/service_manager_client_config.json`. @@ -55,6 +56,8 @@ export class ServiceManagerClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -113,8 +116,20 @@ export class ServiceManagerClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof ServiceManagerClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'servicemanagement.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -129,7 +144,7 @@ export class ServiceManagerClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -154,10 +169,10 @@ export class ServiceManagerClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); @@ -411,21 +426,52 @@ export class ServiceManagerClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'servicemanagement.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'servicemanagement.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-api-servicemanagement/test/gapic_service_manager_v1.ts b/packages/google-api-servicemanagement/test/gapic_service_manager_v1.ts index 9e22f6d5aed..331cec83734 100644 --- a/packages/google-api-servicemanagement/test/gapic_service_manager_v1.ts +++ b/packages/google-api-servicemanagement/test/gapic_service_manager_v1.ts @@ -161,16 +161,62 @@ function stubAsyncIterationCall( describe('v1.ServiceManagerClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - servicemanagerModule.v1.ServiceManagerClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new servicemanagerModule.v1.ServiceManagerClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'servicemanagement.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - servicemanagerModule.v1.ServiceManagerClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new servicemanagerModule.v1.ServiceManagerClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + servicemanagerModule.v1.ServiceManagerClient.servicePath; + assert.strictEqual(servicePath, 'servicemanagement.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + servicemanagerModule.v1.ServiceManagerClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'servicemanagement.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new servicemanagerModule.v1.ServiceManagerClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'servicemanagement.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new servicemanagerModule.v1.ServiceManagerClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'servicemanagement.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new servicemanagerModule.v1.ServiceManagerClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-api-serviceusage/samples/generated/v1/service_usage.list_services.js b/packages/google-api-serviceusage/samples/generated/v1/service_usage.list_services.js index f2e5b7d2e16..f325eb94c92 100644 --- a/packages/google-api-serviceusage/samples/generated/v1/service_usage.list_services.js +++ b/packages/google-api-serviceusage/samples/generated/v1/service_usage.list_services.js @@ -63,7 +63,7 @@ function main() { }; // Run request - const iterable = await serviceusageClient.listServicesAsync(request); + const iterable = serviceusageClient.listServicesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-api-serviceusage/samples/generated/v1beta1/service_usage.list_admin_overrides.js b/packages/google-api-serviceusage/samples/generated/v1beta1/service_usage.list_admin_overrides.js index ecb75f0636b..8c2c55c682f 100644 --- a/packages/google-api-serviceusage/samples/generated/v1beta1/service_usage.list_admin_overrides.js +++ b/packages/google-api-serviceusage/samples/generated/v1beta1/service_usage.list_admin_overrides.js @@ -57,7 +57,7 @@ function main() { }; // Run request - const iterable = await serviceusageClient.listAdminOverridesAsync(request); + const iterable = serviceusageClient.listAdminOverridesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-api-serviceusage/samples/generated/v1beta1/service_usage.list_consumer_overrides.js b/packages/google-api-serviceusage/samples/generated/v1beta1/service_usage.list_consumer_overrides.js index ff8e6bd0a2a..cc612797cbf 100644 --- a/packages/google-api-serviceusage/samples/generated/v1beta1/service_usage.list_consumer_overrides.js +++ b/packages/google-api-serviceusage/samples/generated/v1beta1/service_usage.list_consumer_overrides.js @@ -57,7 +57,7 @@ function main() { }; // Run request - const iterable = await serviceusageClient.listConsumerOverridesAsync(request); + const iterable = serviceusageClient.listConsumerOverridesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-api-serviceusage/samples/generated/v1beta1/service_usage.list_consumer_quota_metrics.js b/packages/google-api-serviceusage/samples/generated/v1beta1/service_usage.list_consumer_quota_metrics.js index 9e6354e78b4..d6048cff579 100644 --- a/packages/google-api-serviceusage/samples/generated/v1beta1/service_usage.list_consumer_quota_metrics.js +++ b/packages/google-api-serviceusage/samples/generated/v1beta1/service_usage.list_consumer_quota_metrics.js @@ -62,7 +62,7 @@ function main() { }; // Run request - const iterable = await serviceusageClient.listConsumerQuotaMetricsAsync(request); + const iterable = serviceusageClient.listConsumerQuotaMetricsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-api-serviceusage/samples/generated/v1beta1/service_usage.list_services.js b/packages/google-api-serviceusage/samples/generated/v1beta1/service_usage.list_services.js index 43654ea92bc..88da644262e 100644 --- a/packages/google-api-serviceusage/samples/generated/v1beta1/service_usage.list_services.js +++ b/packages/google-api-serviceusage/samples/generated/v1beta1/service_usage.list_services.js @@ -64,7 +64,7 @@ function main() { }; // Run request - const iterable = await serviceusageClient.listServicesAsync(request); + const iterable = serviceusageClient.listServicesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-api-serviceusage/src/v1/service_usage_client.ts b/packages/google-api-serviceusage/src/v1/service_usage_client.ts index 4c791f07456..fc428f9195f 100644 --- a/packages/google-api-serviceusage/src/v1/service_usage_client.ts +++ b/packages/google-api-serviceusage/src/v1/service_usage_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/service_usage_client_config.json`. @@ -56,6 +57,8 @@ export class ServiceUsageClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -114,8 +117,20 @@ export class ServiceUsageClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof ServiceUsageClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'serviceusage.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -130,7 +145,7 @@ export class ServiceUsageClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -155,10 +170,10 @@ export class ServiceUsageClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -358,21 +373,52 @@ export class ServiceUsageClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'serviceusage.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'serviceusage.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-api-serviceusage/src/v1beta1/service_usage_client.ts b/packages/google-api-serviceusage/src/v1beta1/service_usage_client.ts index b5aaf316d9a..f3baee4e72d 100644 --- a/packages/google-api-serviceusage/src/v1beta1/service_usage_client.ts +++ b/packages/google-api-serviceusage/src/v1beta1/service_usage_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1beta1/service_usage_client_config.json`. @@ -52,6 +53,8 @@ export class ServiceUsageClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -109,8 +112,20 @@ export class ServiceUsageClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof ServiceUsageClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'serviceusage.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -125,7 +140,7 @@ export class ServiceUsageClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -150,10 +165,10 @@ export class ServiceUsageClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -485,21 +500,52 @@ export class ServiceUsageClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'serviceusage.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'serviceusage.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-api-serviceusage/test/gapic_service_usage_v1.ts b/packages/google-api-serviceusage/test/gapic_service_usage_v1.ts index 8c4328a69c8..922428c1cf7 100644 --- a/packages/google-api-serviceusage/test/gapic_service_usage_v1.ts +++ b/packages/google-api-serviceusage/test/gapic_service_usage_v1.ts @@ -161,14 +161,62 @@ function stubAsyncIterationCall( describe('v1.ServiceUsageClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = serviceusageModule.v1.ServiceUsageClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new serviceusageModule.v1.ServiceUsageClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'serviceusage.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = serviceusageModule.v1.ServiceUsageClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new serviceusageModule.v1.ServiceUsageClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + serviceusageModule.v1.ServiceUsageClient.servicePath; + assert.strictEqual(servicePath, 'serviceusage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + serviceusageModule.v1.ServiceUsageClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'serviceusage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new serviceusageModule.v1.ServiceUsageClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'serviceusage.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new serviceusageModule.v1.ServiceUsageClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'serviceusage.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new serviceusageModule.v1.ServiceUsageClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-api-serviceusage/test/gapic_service_usage_v1beta1.ts b/packages/google-api-serviceusage/test/gapic_service_usage_v1beta1.ts index e6fd43a3cea..8ca0e0c013b 100644 --- a/packages/google-api-serviceusage/test/gapic_service_usage_v1beta1.ts +++ b/packages/google-api-serviceusage/test/gapic_service_usage_v1beta1.ts @@ -161,16 +161,62 @@ function stubAsyncIterationCall( describe('v1beta1.ServiceUsageClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - serviceusageModule.v1beta1.ServiceUsageClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new serviceusageModule.v1beta1.ServiceUsageClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'serviceusage.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - serviceusageModule.v1beta1.ServiceUsageClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new serviceusageModule.v1beta1.ServiceUsageClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + serviceusageModule.v1beta1.ServiceUsageClient.servicePath; + assert.strictEqual(servicePath, 'serviceusage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + serviceusageModule.v1beta1.ServiceUsageClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'serviceusage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new serviceusageModule.v1beta1.ServiceUsageClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'serviceusage.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new serviceusageModule.v1beta1.ServiceUsageClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'serviceusage.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new serviceusageModule.v1beta1.ServiceUsageClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-appengine/samples/generated/v1/authorized_certificates.list_authorized_certificates.js b/packages/google-appengine/samples/generated/v1/authorized_certificates.list_authorized_certificates.js index d867e3baea5..736f038e7d3 100644 --- a/packages/google-appengine/samples/generated/v1/authorized_certificates.list_authorized_certificates.js +++ b/packages/google-appengine/samples/generated/v1/authorized_certificates.list_authorized_certificates.js @@ -57,7 +57,7 @@ function main() { }; // Run request - const iterable = await appengineClient.listAuthorizedCertificatesAsync(request); + const iterable = appengineClient.listAuthorizedCertificatesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-appengine/samples/generated/v1/authorized_domains.list_authorized_domains.js b/packages/google-appengine/samples/generated/v1/authorized_domains.list_authorized_domains.js index 1b91a9dc639..e83c89f6a13 100644 --- a/packages/google-appengine/samples/generated/v1/authorized_domains.list_authorized_domains.js +++ b/packages/google-appengine/samples/generated/v1/authorized_domains.list_authorized_domains.js @@ -53,7 +53,7 @@ function main() { }; // Run request - const iterable = await appengineClient.listAuthorizedDomainsAsync(request); + const iterable = appengineClient.listAuthorizedDomainsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-appengine/samples/generated/v1/domain_mappings.list_domain_mappings.js b/packages/google-appengine/samples/generated/v1/domain_mappings.list_domain_mappings.js index 57c806e7edb..32001c9ad1f 100644 --- a/packages/google-appengine/samples/generated/v1/domain_mappings.list_domain_mappings.js +++ b/packages/google-appengine/samples/generated/v1/domain_mappings.list_domain_mappings.js @@ -53,7 +53,7 @@ function main() { }; // Run request - const iterable = await appengineClient.listDomainMappingsAsync(request); + const iterable = appengineClient.listDomainMappingsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-appengine/samples/generated/v1/firewall.list_ingress_rules.js b/packages/google-appengine/samples/generated/v1/firewall.list_ingress_rules.js index 5fc1a86e8d7..5176b9c55b2 100644 --- a/packages/google-appengine/samples/generated/v1/firewall.list_ingress_rules.js +++ b/packages/google-appengine/samples/generated/v1/firewall.list_ingress_rules.js @@ -60,7 +60,7 @@ function main() { }; // Run request - const iterable = await appengineClient.listIngressRulesAsync(request); + const iterable = appengineClient.listIngressRulesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-appengine/samples/generated/v1/instances.list_instances.js b/packages/google-appengine/samples/generated/v1/instances.list_instances.js index 7b8cc64a494..567f5dd8b6b 100644 --- a/packages/google-appengine/samples/generated/v1/instances.list_instances.js +++ b/packages/google-appengine/samples/generated/v1/instances.list_instances.js @@ -54,7 +54,7 @@ function main() { }; // Run request - const iterable = await appengineClient.listInstancesAsync(request); + const iterable = appengineClient.listInstancesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-appengine/samples/generated/v1/services.list_services.js b/packages/google-appengine/samples/generated/v1/services.list_services.js index b14332ca091..413d03824c4 100644 --- a/packages/google-appengine/samples/generated/v1/services.list_services.js +++ b/packages/google-appengine/samples/generated/v1/services.list_services.js @@ -53,7 +53,7 @@ function main() { }; // Run request - const iterable = await appengineClient.listServicesAsync(request); + const iterable = appengineClient.listServicesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-appengine/samples/generated/v1/versions.list_versions.js b/packages/google-appengine/samples/generated/v1/versions.list_versions.js index 6ed0a881d47..3969735e609 100644 --- a/packages/google-appengine/samples/generated/v1/versions.list_versions.js +++ b/packages/google-appengine/samples/generated/v1/versions.list_versions.js @@ -58,7 +58,7 @@ function main() { }; // Run request - const iterable = await appengineClient.listVersionsAsync(request); + const iterable = appengineClient.listVersionsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-appengine/src/v1/applications_client.ts b/packages/google-appengine/src/v1/applications_client.ts index d49f866468b..aac0ae66f5f 100644 --- a/packages/google-appengine/src/v1/applications_client.ts +++ b/packages/google-appengine/src/v1/applications_client.ts @@ -29,6 +29,7 @@ import type { import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/applications_client_config.json`. @@ -50,6 +51,8 @@ export class ApplicationsClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -108,8 +111,20 @@ export class ApplicationsClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof ApplicationsClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'appengine.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -124,7 +139,7 @@ export class ApplicationsClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -149,10 +164,10 @@ export class ApplicationsClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -338,21 +353,52 @@ export class ApplicationsClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'appengine.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'appengine.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-appengine/src/v1/authorized_certificates_client.ts b/packages/google-appengine/src/v1/authorized_certificates_client.ts index 5c03ba05b01..d34c01f9e09 100644 --- a/packages/google-appengine/src/v1/authorized_certificates_client.ts +++ b/packages/google-appengine/src/v1/authorized_certificates_client.ts @@ -29,6 +29,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/authorized_certificates_client_config.json`. @@ -51,6 +52,8 @@ export class AuthorizedCertificatesClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -109,8 +112,20 @@ export class AuthorizedCertificatesClient { // Ensure that options include all the required fields. const staticMembers = this .constructor as typeof AuthorizedCertificatesClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'appengine.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -125,7 +140,7 @@ export class AuthorizedCertificatesClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -150,10 +165,10 @@ export class AuthorizedCertificatesClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -282,21 +297,52 @@ export class AuthorizedCertificatesClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'appengine.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'appengine.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-appengine/src/v1/authorized_domains_client.ts b/packages/google-appengine/src/v1/authorized_domains_client.ts index eb07182d001..2316988a20a 100644 --- a/packages/google-appengine/src/v1/authorized_domains_client.ts +++ b/packages/google-appengine/src/v1/authorized_domains_client.ts @@ -29,6 +29,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/authorized_domains_client_config.json`. @@ -52,6 +53,8 @@ export class AuthorizedDomainsClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -109,8 +112,20 @@ export class AuthorizedDomainsClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof AuthorizedDomainsClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'appengine.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -125,7 +140,7 @@ export class AuthorizedDomainsClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -150,10 +165,10 @@ export class AuthorizedDomainsClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -276,21 +291,52 @@ export class AuthorizedDomainsClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'appengine.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'appengine.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-appengine/src/v1/domain_mappings_client.ts b/packages/google-appengine/src/v1/domain_mappings_client.ts index 9c8acfdd12d..41601645400 100644 --- a/packages/google-appengine/src/v1/domain_mappings_client.ts +++ b/packages/google-appengine/src/v1/domain_mappings_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/domain_mappings_client_config.json`. @@ -52,6 +53,8 @@ export class DomainMappingsClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -110,8 +113,20 @@ export class DomainMappingsClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof DomainMappingsClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'appengine.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -126,7 +141,7 @@ export class DomainMappingsClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -151,10 +166,10 @@ export class DomainMappingsClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -355,21 +370,52 @@ export class DomainMappingsClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'appengine.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'appengine.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-appengine/src/v1/firewall_client.ts b/packages/google-appengine/src/v1/firewall_client.ts index 29e574320e4..afefb5da8de 100644 --- a/packages/google-appengine/src/v1/firewall_client.ts +++ b/packages/google-appengine/src/v1/firewall_client.ts @@ -29,6 +29,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/firewall_client_config.json`. @@ -59,6 +60,8 @@ export class FirewallClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -116,8 +119,20 @@ export class FirewallClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof FirewallClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'appengine.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -132,7 +147,7 @@ export class FirewallClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -157,10 +172,10 @@ export class FirewallClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -290,21 +305,52 @@ export class FirewallClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'appengine.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'appengine.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-appengine/src/v1/instances_client.ts b/packages/google-appengine/src/v1/instances_client.ts index 4877ea8f7f3..303e0572071 100644 --- a/packages/google-appengine/src/v1/instances_client.ts +++ b/packages/google-appengine/src/v1/instances_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/instances_client_config.json`. @@ -52,6 +53,8 @@ export class InstancesClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -110,8 +113,20 @@ export class InstancesClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof InstancesClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'appengine.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -126,7 +141,7 @@ export class InstancesClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -151,10 +166,10 @@ export class InstancesClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -343,21 +358,52 @@ export class InstancesClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'appengine.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'appengine.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-appengine/src/v1/services_client.ts b/packages/google-appengine/src/v1/services_client.ts index 488401cbd28..44b96eb0126 100644 --- a/packages/google-appengine/src/v1/services_client.ts +++ b/packages/google-appengine/src/v1/services_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/services_client_config.json`. @@ -52,6 +53,8 @@ export class ServicesClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -110,8 +113,20 @@ export class ServicesClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof ServicesClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'appengine.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -126,7 +141,7 @@ export class ServicesClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -151,10 +166,10 @@ export class ServicesClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -343,21 +358,52 @@ export class ServicesClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'appengine.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'appengine.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-appengine/src/v1/versions_client.ts b/packages/google-appengine/src/v1/versions_client.ts index 7b2f017f808..d79f1a8d6b5 100644 --- a/packages/google-appengine/src/v1/versions_client.ts +++ b/packages/google-appengine/src/v1/versions_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/versions_client_config.json`. @@ -52,6 +53,8 @@ export class VersionsClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -110,8 +113,20 @@ export class VersionsClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof VersionsClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'appengine.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -126,7 +141,7 @@ export class VersionsClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -151,10 +166,10 @@ export class VersionsClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -355,21 +370,52 @@ export class VersionsClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'appengine.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'appengine.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-appengine/test/gapic_applications_v1.ts b/packages/google-appengine/test/gapic_applications_v1.ts index 787a033a3e4..de7c0b9a3eb 100644 --- a/packages/google-appengine/test/gapic_applications_v1.ts +++ b/packages/google-appengine/test/gapic_applications_v1.ts @@ -98,14 +98,62 @@ function stubLongRunningCallWithCallback( describe('v1.ApplicationsClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = applicationsModule.v1.ApplicationsClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new applicationsModule.v1.ApplicationsClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'appengine.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = applicationsModule.v1.ApplicationsClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new applicationsModule.v1.ApplicationsClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + applicationsModule.v1.ApplicationsClient.servicePath; + assert.strictEqual(servicePath, 'appengine.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + applicationsModule.v1.ApplicationsClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'appengine.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new applicationsModule.v1.ApplicationsClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'appengine.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new applicationsModule.v1.ApplicationsClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'appengine.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new applicationsModule.v1.ApplicationsClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-appengine/test/gapic_authorized_certificates_v1.ts b/packages/google-appengine/test/gapic_authorized_certificates_v1.ts index c5e9827b8cf..dd8fe628c8f 100644 --- a/packages/google-appengine/test/gapic_authorized_certificates_v1.ts +++ b/packages/google-appengine/test/gapic_authorized_certificates_v1.ts @@ -129,18 +129,68 @@ function stubAsyncIterationCall( describe('v1.AuthorizedCertificatesClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - authorizedcertificatesModule.v1.AuthorizedCertificatesClient - .servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = + new authorizedcertificatesModule.v1.AuthorizedCertificatesClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'appengine.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - authorizedcertificatesModule.v1.AuthorizedCertificatesClient - .apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = + new authorizedcertificatesModule.v1.AuthorizedCertificatesClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + authorizedcertificatesModule.v1.AuthorizedCertificatesClient + .servicePath; + assert.strictEqual(servicePath, 'appengine.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + authorizedcertificatesModule.v1.AuthorizedCertificatesClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'appengine.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new authorizedcertificatesModule.v1.AuthorizedCertificatesClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'appengine.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new authorizedcertificatesModule.v1.AuthorizedCertificatesClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'appengine.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new authorizedcertificatesModule.v1.AuthorizedCertificatesClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-appengine/test/gapic_authorized_domains_v1.ts b/packages/google-appengine/test/gapic_authorized_domains_v1.ts index 093019ce727..59f56100c57 100644 --- a/packages/google-appengine/test/gapic_authorized_domains_v1.ts +++ b/packages/google-appengine/test/gapic_authorized_domains_v1.ts @@ -129,16 +129,62 @@ function stubAsyncIterationCall( describe('v1.AuthorizedDomainsClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - authorizeddomainsModule.v1.AuthorizedDomainsClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new authorizeddomainsModule.v1.AuthorizedDomainsClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'appengine.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - authorizeddomainsModule.v1.AuthorizedDomainsClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new authorizeddomainsModule.v1.AuthorizedDomainsClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + authorizeddomainsModule.v1.AuthorizedDomainsClient.servicePath; + assert.strictEqual(servicePath, 'appengine.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + authorizeddomainsModule.v1.AuthorizedDomainsClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'appengine.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new authorizeddomainsModule.v1.AuthorizedDomainsClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'appengine.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new authorizeddomainsModule.v1.AuthorizedDomainsClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'appengine.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new authorizeddomainsModule.v1.AuthorizedDomainsClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-appengine/test/gapic_domain_mappings_v1.ts b/packages/google-appengine/test/gapic_domain_mappings_v1.ts index eaa097c6528..25d2f4f1930 100644 --- a/packages/google-appengine/test/gapic_domain_mappings_v1.ts +++ b/packages/google-appengine/test/gapic_domain_mappings_v1.ts @@ -161,16 +161,62 @@ function stubAsyncIterationCall( describe('v1.DomainMappingsClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - domainmappingsModule.v1.DomainMappingsClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new domainmappingsModule.v1.DomainMappingsClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'appengine.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - domainmappingsModule.v1.DomainMappingsClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new domainmappingsModule.v1.DomainMappingsClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + domainmappingsModule.v1.DomainMappingsClient.servicePath; + assert.strictEqual(servicePath, 'appengine.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + domainmappingsModule.v1.DomainMappingsClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'appengine.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new domainmappingsModule.v1.DomainMappingsClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'appengine.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new domainmappingsModule.v1.DomainMappingsClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'appengine.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new domainmappingsModule.v1.DomainMappingsClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-appengine/test/gapic_firewall_v1.ts b/packages/google-appengine/test/gapic_firewall_v1.ts index d9a70488782..2bac6d84e2f 100644 --- a/packages/google-appengine/test/gapic_firewall_v1.ts +++ b/packages/google-appengine/test/gapic_firewall_v1.ts @@ -129,14 +129,60 @@ function stubAsyncIterationCall( describe('v1.FirewallClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = firewallModule.v1.FirewallClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new firewallModule.v1.FirewallClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'appengine.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = firewallModule.v1.FirewallClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new firewallModule.v1.FirewallClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = firewallModule.v1.FirewallClient.servicePath; + assert.strictEqual(servicePath, 'appengine.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = firewallModule.v1.FirewallClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'appengine.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new firewallModule.v1.FirewallClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'appengine.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new firewallModule.v1.FirewallClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'appengine.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new firewallModule.v1.FirewallClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-appengine/test/gapic_instances_v1.ts b/packages/google-appengine/test/gapic_instances_v1.ts index 63e2e755410..7a2653aa990 100644 --- a/packages/google-appengine/test/gapic_instances_v1.ts +++ b/packages/google-appengine/test/gapic_instances_v1.ts @@ -161,14 +161,60 @@ function stubAsyncIterationCall( describe('v1.InstancesClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = instancesModule.v1.InstancesClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new instancesModule.v1.InstancesClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'appengine.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = instancesModule.v1.InstancesClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new instancesModule.v1.InstancesClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = instancesModule.v1.InstancesClient.servicePath; + assert.strictEqual(servicePath, 'appengine.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = instancesModule.v1.InstancesClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'appengine.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new instancesModule.v1.InstancesClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'appengine.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new instancesModule.v1.InstancesClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'appengine.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new instancesModule.v1.InstancesClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-appengine/test/gapic_services_v1.ts b/packages/google-appengine/test/gapic_services_v1.ts index f7c10ddf37a..484bdc1cf2d 100644 --- a/packages/google-appengine/test/gapic_services_v1.ts +++ b/packages/google-appengine/test/gapic_services_v1.ts @@ -161,14 +161,60 @@ function stubAsyncIterationCall( describe('v1.ServicesClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = servicesModule.v1.ServicesClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new servicesModule.v1.ServicesClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'appengine.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = servicesModule.v1.ServicesClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new servicesModule.v1.ServicesClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = servicesModule.v1.ServicesClient.servicePath; + assert.strictEqual(servicePath, 'appengine.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = servicesModule.v1.ServicesClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'appengine.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new servicesModule.v1.ServicesClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'appengine.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new servicesModule.v1.ServicesClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'appengine.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new servicesModule.v1.ServicesClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-appengine/test/gapic_versions_v1.ts b/packages/google-appengine/test/gapic_versions_v1.ts index 2fe9ad6321e..6334b97e0e1 100644 --- a/packages/google-appengine/test/gapic_versions_v1.ts +++ b/packages/google-appengine/test/gapic_versions_v1.ts @@ -161,14 +161,60 @@ function stubAsyncIterationCall( describe('v1.VersionsClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = versionsModule.v1.VersionsClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new versionsModule.v1.VersionsClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'appengine.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = versionsModule.v1.VersionsClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new versionsModule.v1.VersionsClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = versionsModule.v1.VersionsClient.servicePath; + assert.strictEqual(servicePath, 'appengine.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = versionsModule.v1.VersionsClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'appengine.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new versionsModule.v1.VersionsClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'appengine.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new versionsModule.v1.VersionsClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'appengine.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new versionsModule.v1.VersionsClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-area120-tables/samples/generated/v1alpha1/tables_service.list_rows.js b/packages/google-area120-tables/samples/generated/v1alpha1/tables_service.list_rows.js index 4027f6c5f5a..999e7e340a5 100644 --- a/packages/google-area120-tables/samples/generated/v1alpha1/tables_service.list_rows.js +++ b/packages/google-area120-tables/samples/generated/v1alpha1/tables_service.list_rows.js @@ -72,7 +72,7 @@ function main(parent) { }; // Run request - const iterable = await tablesClient.listRowsAsync(request); + const iterable = tablesClient.listRowsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-area120-tables/samples/generated/v1alpha1/tables_service.list_tables.js b/packages/google-area120-tables/samples/generated/v1alpha1/tables_service.list_tables.js index 059a7926de6..10a731fc49d 100644 --- a/packages/google-area120-tables/samples/generated/v1alpha1/tables_service.list_tables.js +++ b/packages/google-area120-tables/samples/generated/v1alpha1/tables_service.list_tables.js @@ -55,7 +55,7 @@ function main() { }; // Run request - const iterable = await tablesClient.listTablesAsync(request); + const iterable = tablesClient.listTablesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-area120-tables/samples/generated/v1alpha1/tables_service.list_workspaces.js b/packages/google-area120-tables/samples/generated/v1alpha1/tables_service.list_workspaces.js index 0f3228eb537..d305ef3ffa6 100644 --- a/packages/google-area120-tables/samples/generated/v1alpha1/tables_service.list_workspaces.js +++ b/packages/google-area120-tables/samples/generated/v1alpha1/tables_service.list_workspaces.js @@ -55,7 +55,7 @@ function main() { }; // Run request - const iterable = await tablesClient.listWorkspacesAsync(request); + const iterable = tablesClient.listWorkspacesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-area120-tables/src/v1alpha1/tables_service_client.ts b/packages/google-area120-tables/src/v1alpha1/tables_service_client.ts index 68bd7c4adee..acdc1b99eeb 100644 --- a/packages/google-area120-tables/src/v1alpha1/tables_service_client.ts +++ b/packages/google-area120-tables/src/v1alpha1/tables_service_client.ts @@ -29,6 +29,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1alpha1/tables_service_client_config.json`. @@ -61,6 +62,8 @@ export class TablesServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -118,8 +121,20 @@ export class TablesServiceClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof TablesServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'area120tables.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -134,7 +149,7 @@ export class TablesServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -159,10 +174,10 @@ export class TablesServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -312,21 +327,52 @@ export class TablesServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'area120tables.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'area120tables.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-area120-tables/test/gapic_tables_service_v1alpha1.ts b/packages/google-area120-tables/test/gapic_tables_service_v1alpha1.ts index e4b118431bc..8e933b66faa 100644 --- a/packages/google-area120-tables/test/gapic_tables_service_v1alpha1.ts +++ b/packages/google-area120-tables/test/gapic_tables_service_v1alpha1.ts @@ -129,16 +129,62 @@ function stubAsyncIterationCall( describe('v1alpha1.TablesServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - tablesserviceModule.v1alpha1.TablesServiceClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new tablesserviceModule.v1alpha1.TablesServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'area120tables.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - tablesserviceModule.v1alpha1.TablesServiceClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new tablesserviceModule.v1alpha1.TablesServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + tablesserviceModule.v1alpha1.TablesServiceClient.servicePath; + assert.strictEqual(servicePath, 'area120tables.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + tablesserviceModule.v1alpha1.TablesServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'area120tables.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new tablesserviceModule.v1alpha1.TablesServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'area120tables.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new tablesserviceModule.v1alpha1.TablesServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'area120tables.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new tablesserviceModule.v1alpha1.TablesServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-cloud-accessapproval/samples/generated/v1/access_approval.list_approval_requests.js b/packages/google-cloud-accessapproval/samples/generated/v1/access_approval.list_approval_requests.js index 03851275644..4b8839e4542 100644 --- a/packages/google-cloud-accessapproval/samples/generated/v1/access_approval.list_approval_requests.js +++ b/packages/google-cloud-accessapproval/samples/generated/v1/access_approval.list_approval_requests.js @@ -68,7 +68,7 @@ function main() { }; // Run request - const iterable = await accessapprovalClient.listApprovalRequestsAsync(request); + const iterable = accessapprovalClient.listApprovalRequestsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-accessapproval/src/v1/access_approval_client.ts b/packages/google-cloud-accessapproval/src/v1/access_approval_client.ts index 6772343a9be..d220a85210b 100644 --- a/packages/google-cloud-accessapproval/src/v1/access_approval_client.ts +++ b/packages/google-cloud-accessapproval/src/v1/access_approval_client.ts @@ -29,6 +29,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/access_approval_client_config.json`. @@ -82,6 +83,8 @@ export class AccessApprovalClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -139,8 +142,20 @@ export class AccessApprovalClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof AccessApprovalClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'accessapproval.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -155,7 +170,7 @@ export class AccessApprovalClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -180,10 +195,10 @@ export class AccessApprovalClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -346,21 +361,52 @@ export class AccessApprovalClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'accessapproval.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'accessapproval.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-cloud-accessapproval/test/gapic_access_approval_v1.ts b/packages/google-cloud-accessapproval/test/gapic_access_approval_v1.ts index 10aa726202f..ffb51a4d666 100644 --- a/packages/google-cloud-accessapproval/test/gapic_access_approval_v1.ts +++ b/packages/google-cloud-accessapproval/test/gapic_access_approval_v1.ts @@ -129,16 +129,62 @@ function stubAsyncIterationCall( describe('v1.AccessApprovalClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - accessapprovalModule.v1.AccessApprovalClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new accessapprovalModule.v1.AccessApprovalClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'accessapproval.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - accessapprovalModule.v1.AccessApprovalClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new accessapprovalModule.v1.AccessApprovalClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + accessapprovalModule.v1.AccessApprovalClient.servicePath; + assert.strictEqual(servicePath, 'accessapproval.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + accessapprovalModule.v1.AccessApprovalClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'accessapproval.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new accessapprovalModule.v1.AccessApprovalClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'accessapproval.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new accessapprovalModule.v1.AccessApprovalClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'accessapproval.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new accessapprovalModule.v1.AccessApprovalClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-cloud-advisorynotifications/samples/generated/v1/advisory_notifications_service.list_notifications.js b/packages/google-cloud-advisorynotifications/samples/generated/v1/advisory_notifications_service.list_notifications.js index cfa91ceebf9..58b5ba93b58 100644 --- a/packages/google-cloud-advisorynotifications/samples/generated/v1/advisory_notifications_service.list_notifications.js +++ b/packages/google-cloud-advisorynotifications/samples/generated/v1/advisory_notifications_service.list_notifications.js @@ -74,7 +74,7 @@ function main(parent) { }; // Run request - const iterable = await advisorynotificationsClient.listNotificationsAsync(request); + const iterable = advisorynotificationsClient.listNotificationsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-advisorynotifications/src/v1/advisory_notifications_service_client.ts b/packages/google-cloud-advisorynotifications/src/v1/advisory_notifications_service_client.ts index d49b0cd13b8..6e169165df3 100644 --- a/packages/google-cloud-advisorynotifications/src/v1/advisory_notifications_service_client.ts +++ b/packages/google-cloud-advisorynotifications/src/v1/advisory_notifications_service_client.ts @@ -29,6 +29,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/advisory_notifications_service_client_config.json`. @@ -50,6 +51,8 @@ export class AdvisoryNotificationsServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -108,8 +111,20 @@ export class AdvisoryNotificationsServiceClient { // Ensure that options include all the required fields. const staticMembers = this .constructor as typeof AdvisoryNotificationsServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'advisorynotifications.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -124,7 +139,7 @@ export class AdvisoryNotificationsServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -149,10 +164,10 @@ export class AdvisoryNotificationsServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -291,21 +306,52 @@ export class AdvisoryNotificationsServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'advisorynotifications.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'advisorynotifications.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-cloud-advisorynotifications/test/gapic_advisory_notifications_service_v1.ts b/packages/google-cloud-advisorynotifications/test/gapic_advisory_notifications_service_v1.ts index eff37444f84..128de53a2ea 100644 --- a/packages/google-cloud-advisorynotifications/test/gapic_advisory_notifications_service_v1.ts +++ b/packages/google-cloud-advisorynotifications/test/gapic_advisory_notifications_service_v1.ts @@ -129,18 +129,67 @@ function stubAsyncIterationCall( describe('v1.AdvisoryNotificationsServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - advisorynotificationsserviceModule.v1.AdvisoryNotificationsServiceClient - .servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = + new advisorynotificationsserviceModule.v1.AdvisoryNotificationsServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'advisorynotifications.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - advisorynotificationsserviceModule.v1.AdvisoryNotificationsServiceClient - .apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = + new advisorynotificationsserviceModule.v1.AdvisoryNotificationsServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + advisorynotificationsserviceModule.v1 + .AdvisoryNotificationsServiceClient.servicePath; + assert.strictEqual(servicePath, 'advisorynotifications.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + advisorynotificationsserviceModule.v1 + .AdvisoryNotificationsServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'advisorynotifications.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new advisorynotificationsserviceModule.v1.AdvisoryNotificationsServiceClient( + {universeDomain: 'example.com'} + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'advisorynotifications.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new advisorynotificationsserviceModule.v1.AdvisoryNotificationsServiceClient( + {universe_domain: 'example.com'} + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'advisorynotifications.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new advisorynotificationsserviceModule.v1.AdvisoryNotificationsServiceClient( + {universe_domain: 'example.com', universeDomain: 'example.net'} + ); + }); }); it('has port', () => { diff --git a/packages/google-cloud-alloydb/samples/generated/v1/alloy_d_b_admin.list_backups.js b/packages/google-cloud-alloydb/samples/generated/v1/alloy_d_b_admin.list_backups.js index 3fdee93a627..4d8ac6bd6d8 100644 --- a/packages/google-cloud-alloydb/samples/generated/v1/alloy_d_b_admin.list_backups.js +++ b/packages/google-cloud-alloydb/samples/generated/v1/alloy_d_b_admin.list_backups.js @@ -63,7 +63,7 @@ function main(parent) { }; // Run request - const iterable = await alloydbClient.listBackupsAsync(request); + const iterable = alloydbClient.listBackupsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-alloydb/samples/generated/v1/alloy_d_b_admin.list_clusters.js b/packages/google-cloud-alloydb/samples/generated/v1/alloy_d_b_admin.list_clusters.js index 600532021a1..f887660681c 100644 --- a/packages/google-cloud-alloydb/samples/generated/v1/alloy_d_b_admin.list_clusters.js +++ b/packages/google-cloud-alloydb/samples/generated/v1/alloy_d_b_admin.list_clusters.js @@ -66,7 +66,7 @@ function main(parent) { }; // Run request - const iterable = await alloydbClient.listClustersAsync(request); + const iterable = alloydbClient.listClustersAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-alloydb/samples/generated/v1/alloy_d_b_admin.list_instances.js b/packages/google-cloud-alloydb/samples/generated/v1/alloy_d_b_admin.list_instances.js index 68e532bc76d..120678beb7a 100644 --- a/packages/google-cloud-alloydb/samples/generated/v1/alloy_d_b_admin.list_instances.js +++ b/packages/google-cloud-alloydb/samples/generated/v1/alloy_d_b_admin.list_instances.js @@ -68,7 +68,7 @@ function main(parent) { }; // Run request - const iterable = await alloydbClient.listInstancesAsync(request); + const iterable = alloydbClient.listInstancesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-alloydb/samples/generated/v1/alloy_d_b_admin.list_supported_database_flags.js b/packages/google-cloud-alloydb/samples/generated/v1/alloy_d_b_admin.list_supported_database_flags.js index 60be247361c..18b1912620d 100644 --- a/packages/google-cloud-alloydb/samples/generated/v1/alloy_d_b_admin.list_supported_database_flags.js +++ b/packages/google-cloud-alloydb/samples/generated/v1/alloy_d_b_admin.list_supported_database_flags.js @@ -60,7 +60,7 @@ function main(parent) { }; // Run request - const iterable = await alloydbClient.listSupportedDatabaseFlagsAsync(request); + const iterable = alloydbClient.listSupportedDatabaseFlagsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-alloydb/samples/generated/v1/alloy_d_b_admin.list_users.js b/packages/google-cloud-alloydb/samples/generated/v1/alloy_d_b_admin.list_users.js index f006613eff4..c2b9c8db326 100644 --- a/packages/google-cloud-alloydb/samples/generated/v1/alloy_d_b_admin.list_users.js +++ b/packages/google-cloud-alloydb/samples/generated/v1/alloy_d_b_admin.list_users.js @@ -63,7 +63,7 @@ function main(parent) { }; // Run request - const iterable = await alloydbClient.listUsersAsync(request); + const iterable = alloydbClient.listUsersAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-alloydb/samples/generated/v1alpha/alloy_d_b_admin.list_backups.js b/packages/google-cloud-alloydb/samples/generated/v1alpha/alloy_d_b_admin.list_backups.js index 5157fc66326..53e52fe2ffd 100644 --- a/packages/google-cloud-alloydb/samples/generated/v1alpha/alloy_d_b_admin.list_backups.js +++ b/packages/google-cloud-alloydb/samples/generated/v1alpha/alloy_d_b_admin.list_backups.js @@ -63,7 +63,7 @@ function main(parent) { }; // Run request - const iterable = await alloydbClient.listBackupsAsync(request); + const iterable = alloydbClient.listBackupsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-alloydb/samples/generated/v1alpha/alloy_d_b_admin.list_clusters.js b/packages/google-cloud-alloydb/samples/generated/v1alpha/alloy_d_b_admin.list_clusters.js index c207c12f6cf..ed4e90d94d7 100644 --- a/packages/google-cloud-alloydb/samples/generated/v1alpha/alloy_d_b_admin.list_clusters.js +++ b/packages/google-cloud-alloydb/samples/generated/v1alpha/alloy_d_b_admin.list_clusters.js @@ -66,7 +66,7 @@ function main(parent) { }; // Run request - const iterable = await alloydbClient.listClustersAsync(request); + const iterable = alloydbClient.listClustersAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-alloydb/samples/generated/v1alpha/alloy_d_b_admin.list_databases.js b/packages/google-cloud-alloydb/samples/generated/v1alpha/alloy_d_b_admin.list_databases.js index e9f9f2bb57f..3b9770aa516 100644 --- a/packages/google-cloud-alloydb/samples/generated/v1alpha/alloy_d_b_admin.list_databases.js +++ b/packages/google-cloud-alloydb/samples/generated/v1alpha/alloy_d_b_admin.list_databases.js @@ -64,7 +64,7 @@ function main(parent) { }; // Run request - const iterable = await alloydbClient.listDatabasesAsync(request); + const iterable = alloydbClient.listDatabasesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-alloydb/samples/generated/v1alpha/alloy_d_b_admin.list_instances.js b/packages/google-cloud-alloydb/samples/generated/v1alpha/alloy_d_b_admin.list_instances.js index 47e1bc0a67e..87a01b0ff90 100644 --- a/packages/google-cloud-alloydb/samples/generated/v1alpha/alloy_d_b_admin.list_instances.js +++ b/packages/google-cloud-alloydb/samples/generated/v1alpha/alloy_d_b_admin.list_instances.js @@ -68,7 +68,7 @@ function main(parent) { }; // Run request - const iterable = await alloydbClient.listInstancesAsync(request); + const iterable = alloydbClient.listInstancesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-alloydb/samples/generated/v1alpha/alloy_d_b_admin.list_supported_database_flags.js b/packages/google-cloud-alloydb/samples/generated/v1alpha/alloy_d_b_admin.list_supported_database_flags.js index 1d909ae96f2..e198bcb7061 100644 --- a/packages/google-cloud-alloydb/samples/generated/v1alpha/alloy_d_b_admin.list_supported_database_flags.js +++ b/packages/google-cloud-alloydb/samples/generated/v1alpha/alloy_d_b_admin.list_supported_database_flags.js @@ -60,7 +60,7 @@ function main(parent) { }; // Run request - const iterable = await alloydbClient.listSupportedDatabaseFlagsAsync(request); + const iterable = alloydbClient.listSupportedDatabaseFlagsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-alloydb/samples/generated/v1alpha/alloy_d_b_admin.list_users.js b/packages/google-cloud-alloydb/samples/generated/v1alpha/alloy_d_b_admin.list_users.js index 157c2f50c66..f94287e2519 100644 --- a/packages/google-cloud-alloydb/samples/generated/v1alpha/alloy_d_b_admin.list_users.js +++ b/packages/google-cloud-alloydb/samples/generated/v1alpha/alloy_d_b_admin.list_users.js @@ -63,7 +63,7 @@ function main(parent) { }; // Run request - const iterable = await alloydbClient.listUsersAsync(request); + const iterable = alloydbClient.listUsersAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-alloydb/samples/generated/v1beta/alloy_d_b_admin.list_backups.js b/packages/google-cloud-alloydb/samples/generated/v1beta/alloy_d_b_admin.list_backups.js index 00afda7ae57..4e614c2c99e 100644 --- a/packages/google-cloud-alloydb/samples/generated/v1beta/alloy_d_b_admin.list_backups.js +++ b/packages/google-cloud-alloydb/samples/generated/v1beta/alloy_d_b_admin.list_backups.js @@ -63,7 +63,7 @@ function main(parent) { }; // Run request - const iterable = await alloydbClient.listBackupsAsync(request); + const iterable = alloydbClient.listBackupsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-alloydb/samples/generated/v1beta/alloy_d_b_admin.list_clusters.js b/packages/google-cloud-alloydb/samples/generated/v1beta/alloy_d_b_admin.list_clusters.js index d8e708bc2e7..6911145b5ff 100644 --- a/packages/google-cloud-alloydb/samples/generated/v1beta/alloy_d_b_admin.list_clusters.js +++ b/packages/google-cloud-alloydb/samples/generated/v1beta/alloy_d_b_admin.list_clusters.js @@ -66,7 +66,7 @@ function main(parent) { }; // Run request - const iterable = await alloydbClient.listClustersAsync(request); + const iterable = alloydbClient.listClustersAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-alloydb/samples/generated/v1beta/alloy_d_b_admin.list_instances.js b/packages/google-cloud-alloydb/samples/generated/v1beta/alloy_d_b_admin.list_instances.js index 866e5d49db2..7a036b4ab31 100644 --- a/packages/google-cloud-alloydb/samples/generated/v1beta/alloy_d_b_admin.list_instances.js +++ b/packages/google-cloud-alloydb/samples/generated/v1beta/alloy_d_b_admin.list_instances.js @@ -68,7 +68,7 @@ function main(parent) { }; // Run request - const iterable = await alloydbClient.listInstancesAsync(request); + const iterable = alloydbClient.listInstancesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-alloydb/samples/generated/v1beta/alloy_d_b_admin.list_supported_database_flags.js b/packages/google-cloud-alloydb/samples/generated/v1beta/alloy_d_b_admin.list_supported_database_flags.js index 2e78c095d87..faf32726570 100644 --- a/packages/google-cloud-alloydb/samples/generated/v1beta/alloy_d_b_admin.list_supported_database_flags.js +++ b/packages/google-cloud-alloydb/samples/generated/v1beta/alloy_d_b_admin.list_supported_database_flags.js @@ -60,7 +60,7 @@ function main(parent) { }; // Run request - const iterable = await alloydbClient.listSupportedDatabaseFlagsAsync(request); + const iterable = alloydbClient.listSupportedDatabaseFlagsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-alloydb/samples/generated/v1beta/alloy_d_b_admin.list_users.js b/packages/google-cloud-alloydb/samples/generated/v1beta/alloy_d_b_admin.list_users.js index cf09356c05f..cb4109d0019 100644 --- a/packages/google-cloud-alloydb/samples/generated/v1beta/alloy_d_b_admin.list_users.js +++ b/packages/google-cloud-alloydb/samples/generated/v1beta/alloy_d_b_admin.list_users.js @@ -63,7 +63,7 @@ function main(parent) { }; // Run request - const iterable = await alloydbClient.listUsersAsync(request); + const iterable = alloydbClient.listUsersAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-alloydb/src/v1/alloy_d_b_admin_client.ts b/packages/google-cloud-alloydb/src/v1/alloy_d_b_admin_client.ts index 39842813072..118c1983e5e 100644 --- a/packages/google-cloud-alloydb/src/v1/alloy_d_b_admin_client.ts +++ b/packages/google-cloud-alloydb/src/v1/alloy_d_b_admin_client.ts @@ -35,6 +35,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/alloy_d_b_admin_client_config.json`. @@ -56,6 +57,8 @@ export class AlloyDBAdminClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -116,8 +119,20 @@ export class AlloyDBAdminClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof AlloyDBAdminClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'alloydb.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -132,7 +147,7 @@ export class AlloyDBAdminClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -157,10 +172,10 @@ export class AlloyDBAdminClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); @@ -605,21 +620,52 @@ export class AlloyDBAdminClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'alloydb.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'alloydb.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-cloud-alloydb/src/v1alpha/alloy_d_b_admin_client.ts b/packages/google-cloud-alloydb/src/v1alpha/alloy_d_b_admin_client.ts index dfc1999bf75..7bbecc5466d 100644 --- a/packages/google-cloud-alloydb/src/v1alpha/alloy_d_b_admin_client.ts +++ b/packages/google-cloud-alloydb/src/v1alpha/alloy_d_b_admin_client.ts @@ -35,6 +35,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1alpha/alloy_d_b_admin_client_config.json`. @@ -56,6 +57,8 @@ export class AlloyDBAdminClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -116,8 +119,20 @@ export class AlloyDBAdminClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof AlloyDBAdminClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'alloydb.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -132,7 +147,7 @@ export class AlloyDBAdminClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -157,10 +172,10 @@ export class AlloyDBAdminClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); @@ -614,21 +629,52 @@ export class AlloyDBAdminClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'alloydb.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'alloydb.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-cloud-alloydb/src/v1beta/alloy_d_b_admin_client.ts b/packages/google-cloud-alloydb/src/v1beta/alloy_d_b_admin_client.ts index 280dddccbe7..018458c160d 100644 --- a/packages/google-cloud-alloydb/src/v1beta/alloy_d_b_admin_client.ts +++ b/packages/google-cloud-alloydb/src/v1beta/alloy_d_b_admin_client.ts @@ -35,6 +35,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1beta/alloy_d_b_admin_client_config.json`. @@ -56,6 +57,8 @@ export class AlloyDBAdminClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -116,8 +119,20 @@ export class AlloyDBAdminClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof AlloyDBAdminClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'alloydb.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -132,7 +147,7 @@ export class AlloyDBAdminClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -157,10 +172,10 @@ export class AlloyDBAdminClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); @@ -604,21 +619,52 @@ export class AlloyDBAdminClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'alloydb.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'alloydb.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-cloud-alloydb/test/gapic_alloy_d_b_admin_v1.ts b/packages/google-cloud-alloydb/test/gapic_alloy_d_b_admin_v1.ts index 46aba652f2a..c6c609ab914 100644 --- a/packages/google-cloud-alloydb/test/gapic_alloy_d_b_admin_v1.ts +++ b/packages/google-cloud-alloydb/test/gapic_alloy_d_b_admin_v1.ts @@ -167,14 +167,62 @@ function stubAsyncIterationCall( describe('v1.AlloyDBAdminClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = alloydbadminModule.v1.AlloyDBAdminClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new alloydbadminModule.v1.AlloyDBAdminClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'alloydb.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = alloydbadminModule.v1.AlloyDBAdminClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new alloydbadminModule.v1.AlloyDBAdminClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + alloydbadminModule.v1.AlloyDBAdminClient.servicePath; + assert.strictEqual(servicePath, 'alloydb.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + alloydbadminModule.v1.AlloyDBAdminClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'alloydb.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new alloydbadminModule.v1.AlloyDBAdminClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'alloydb.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new alloydbadminModule.v1.AlloyDBAdminClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'alloydb.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new alloydbadminModule.v1.AlloyDBAdminClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-cloud-alloydb/test/gapic_alloy_d_b_admin_v1alpha.ts b/packages/google-cloud-alloydb/test/gapic_alloy_d_b_admin_v1alpha.ts index 762cbd46385..77263441515 100644 --- a/packages/google-cloud-alloydb/test/gapic_alloy_d_b_admin_v1alpha.ts +++ b/packages/google-cloud-alloydb/test/gapic_alloy_d_b_admin_v1alpha.ts @@ -167,16 +167,62 @@ function stubAsyncIterationCall( describe('v1alpha.AlloyDBAdminClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - alloydbadminModule.v1alpha.AlloyDBAdminClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new alloydbadminModule.v1alpha.AlloyDBAdminClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'alloydb.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - alloydbadminModule.v1alpha.AlloyDBAdminClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new alloydbadminModule.v1alpha.AlloyDBAdminClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + alloydbadminModule.v1alpha.AlloyDBAdminClient.servicePath; + assert.strictEqual(servicePath, 'alloydb.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + alloydbadminModule.v1alpha.AlloyDBAdminClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'alloydb.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new alloydbadminModule.v1alpha.AlloyDBAdminClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'alloydb.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new alloydbadminModule.v1alpha.AlloyDBAdminClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'alloydb.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new alloydbadminModule.v1alpha.AlloyDBAdminClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-cloud-alloydb/test/gapic_alloy_d_b_admin_v1beta.ts b/packages/google-cloud-alloydb/test/gapic_alloy_d_b_admin_v1beta.ts index 20608e9f04c..7542727441d 100644 --- a/packages/google-cloud-alloydb/test/gapic_alloy_d_b_admin_v1beta.ts +++ b/packages/google-cloud-alloydb/test/gapic_alloy_d_b_admin_v1beta.ts @@ -167,16 +167,62 @@ function stubAsyncIterationCall( describe('v1beta.AlloyDBAdminClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - alloydbadminModule.v1beta.AlloyDBAdminClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new alloydbadminModule.v1beta.AlloyDBAdminClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'alloydb.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - alloydbadminModule.v1beta.AlloyDBAdminClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new alloydbadminModule.v1beta.AlloyDBAdminClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + alloydbadminModule.v1beta.AlloyDBAdminClient.servicePath; + assert.strictEqual(servicePath, 'alloydb.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + alloydbadminModule.v1beta.AlloyDBAdminClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'alloydb.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new alloydbadminModule.v1beta.AlloyDBAdminClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'alloydb.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new alloydbadminModule.v1beta.AlloyDBAdminClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'alloydb.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new alloydbadminModule.v1beta.AlloyDBAdminClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-cloud-apigateway/samples/generated/v1/api_gateway_service.list_api_configs.js b/packages/google-cloud-apigateway/samples/generated/v1/api_gateway_service.list_api_configs.js index 618d687289f..25b95457526 100644 --- a/packages/google-cloud-apigateway/samples/generated/v1/api_gateway_service.list_api_configs.js +++ b/packages/google-cloud-apigateway/samples/generated/v1/api_gateway_service.list_api_configs.js @@ -63,7 +63,7 @@ function main(parent) { }; // Run request - const iterable = await apigatewayClient.listApiConfigsAsync(request); + const iterable = apigatewayClient.listApiConfigsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-apigateway/samples/generated/v1/api_gateway_service.list_apis.js b/packages/google-cloud-apigateway/samples/generated/v1/api_gateway_service.list_apis.js index 8dabaf77dc8..45e1d4e5fe5 100644 --- a/packages/google-cloud-apigateway/samples/generated/v1/api_gateway_service.list_apis.js +++ b/packages/google-cloud-apigateway/samples/generated/v1/api_gateway_service.list_apis.js @@ -63,7 +63,7 @@ function main(parent) { }; // Run request - const iterable = await apigatewayClient.listApisAsync(request); + const iterable = apigatewayClient.listApisAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-apigateway/samples/generated/v1/api_gateway_service.list_gateways.js b/packages/google-cloud-apigateway/samples/generated/v1/api_gateway_service.list_gateways.js index 623055a30b9..adea708e039 100644 --- a/packages/google-cloud-apigateway/samples/generated/v1/api_gateway_service.list_gateways.js +++ b/packages/google-cloud-apigateway/samples/generated/v1/api_gateway_service.list_gateways.js @@ -63,7 +63,7 @@ function main(parent) { }; // Run request - const iterable = await apigatewayClient.listGatewaysAsync(request); + const iterable = apigatewayClient.listGatewaysAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-apigateway/src/v1/api_gateway_service_client.ts b/packages/google-cloud-apigateway/src/v1/api_gateway_service_client.ts index a9459c2c366..6af5c5432bd 100644 --- a/packages/google-cloud-apigateway/src/v1/api_gateway_service_client.ts +++ b/packages/google-cloud-apigateway/src/v1/api_gateway_service_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/api_gateway_service_client_config.json`. @@ -52,6 +53,8 @@ export class ApiGatewayServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -110,8 +113,20 @@ export class ApiGatewayServiceClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof ApiGatewayServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'apigateway.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -126,7 +141,7 @@ export class ApiGatewayServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -151,10 +166,10 @@ export class ApiGatewayServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -496,21 +511,52 @@ export class ApiGatewayServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'apigateway.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'apigateway.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-cloud-apigateway/test/gapic_api_gateway_service_v1.ts b/packages/google-cloud-apigateway/test/gapic_api_gateway_service_v1.ts index 4d53908e64c..f6ba24e07d3 100644 --- a/packages/google-cloud-apigateway/test/gapic_api_gateway_service_v1.ts +++ b/packages/google-cloud-apigateway/test/gapic_api_gateway_service_v1.ts @@ -161,16 +161,62 @@ function stubAsyncIterationCall( describe('v1.ApiGatewayServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - apigatewayserviceModule.v1.ApiGatewayServiceClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new apigatewayserviceModule.v1.ApiGatewayServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'apigateway.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - apigatewayserviceModule.v1.ApiGatewayServiceClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new apigatewayserviceModule.v1.ApiGatewayServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + apigatewayserviceModule.v1.ApiGatewayServiceClient.servicePath; + assert.strictEqual(servicePath, 'apigateway.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + apigatewayserviceModule.v1.ApiGatewayServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'apigateway.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new apigatewayserviceModule.v1.ApiGatewayServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'apigateway.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new apigatewayserviceModule.v1.ApiGatewayServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'apigateway.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new apigatewayserviceModule.v1.ApiGatewayServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-cloud-apigeeconnect/samples/generated/v1/connection_service.list_connections.js b/packages/google-cloud-apigeeconnect/samples/generated/v1/connection_service.list_connections.js index d37d1acd162..93a0dbd8e7d 100644 --- a/packages/google-cloud-apigeeconnect/samples/generated/v1/connection_service.list_connections.js +++ b/packages/google-cloud-apigeeconnect/samples/generated/v1/connection_service.list_connections.js @@ -60,7 +60,7 @@ function main(parent) { }; // Run request - const iterable = await apigeeconnectClient.listConnectionsAsync(request); + const iterable = apigeeconnectClient.listConnectionsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-apigeeconnect/samples/generated/v1/tether.egress.js b/packages/google-cloud-apigeeconnect/samples/generated/v1/tether.egress.js index 4ae3b58df2c..eab5c914936 100644 --- a/packages/google-cloud-apigeeconnect/samples/generated/v1/tether.egress.js +++ b/packages/google-cloud-apigeeconnect/samples/generated/v1/tether.egress.js @@ -77,7 +77,7 @@ function main() { stream.on('error', (err) => { throw(err) }); stream.on('end', () => { /* API call completed */ }); stream.write(request); - stream.end(); + stream.end(); } callEgress(); diff --git a/packages/google-cloud-apigeeconnect/src/v1/connection_service_client.ts b/packages/google-cloud-apigeeconnect/src/v1/connection_service_client.ts index 9b49947236d..dc0600c09de 100644 --- a/packages/google-cloud-apigeeconnect/src/v1/connection_service_client.ts +++ b/packages/google-cloud-apigeeconnect/src/v1/connection_service_client.ts @@ -29,6 +29,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/connection_service_client_config.json`. @@ -50,6 +51,8 @@ export class ConnectionServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -107,8 +110,20 @@ export class ConnectionServiceClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof ConnectionServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'apigeeconnect.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -123,7 +138,7 @@ export class ConnectionServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -148,10 +163,10 @@ export class ConnectionServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -274,21 +289,52 @@ export class ConnectionServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'apigeeconnect.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'apigeeconnect.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-cloud-apigeeconnect/src/v1/tether_client.ts b/packages/google-cloud-apigeeconnect/src/v1/tether_client.ts index 8480afbcf9b..ecff9f67e2f 100644 --- a/packages/google-cloud-apigeeconnect/src/v1/tether_client.ts +++ b/packages/google-cloud-apigeeconnect/src/v1/tether_client.ts @@ -27,6 +27,7 @@ import type { import {PassThrough} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/tether_client_config.json`. @@ -50,6 +51,8 @@ export class TetherClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -106,8 +109,20 @@ export class TetherClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof TetherClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'apigeeconnect.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -122,7 +137,7 @@ export class TetherClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -147,10 +162,10 @@ export class TetherClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -178,7 +193,7 @@ export class TetherClient { egress: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.BIDI_STREAMING, !!opts.fallback, - /* gaxStreamingRetries: */ true + /* gaxStreamingRetries: */ false ), }; @@ -275,21 +290,52 @@ export class TetherClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'apigeeconnect.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'apigeeconnect.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-cloud-apigeeconnect/test/gapic_connection_service_v1.ts b/packages/google-cloud-apigeeconnect/test/gapic_connection_service_v1.ts index 6b2f4641857..776df607179 100644 --- a/packages/google-cloud-apigeeconnect/test/gapic_connection_service_v1.ts +++ b/packages/google-cloud-apigeeconnect/test/gapic_connection_service_v1.ts @@ -129,16 +129,62 @@ function stubAsyncIterationCall( describe('v1.ConnectionServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - connectionserviceModule.v1.ConnectionServiceClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new connectionserviceModule.v1.ConnectionServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'apigeeconnect.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - connectionserviceModule.v1.ConnectionServiceClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new connectionserviceModule.v1.ConnectionServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + connectionserviceModule.v1.ConnectionServiceClient.servicePath; + assert.strictEqual(servicePath, 'apigeeconnect.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + connectionserviceModule.v1.ConnectionServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'apigeeconnect.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new connectionserviceModule.v1.ConnectionServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'apigeeconnect.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new connectionserviceModule.v1.ConnectionServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'apigeeconnect.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new connectionserviceModule.v1.ConnectionServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-cloud-apigeeconnect/test/gapic_tether_v1.ts b/packages/google-cloud-apigeeconnect/test/gapic_tether_v1.ts index e1d511f1a65..9496a2315ce 100644 --- a/packages/google-cloud-apigeeconnect/test/gapic_tether_v1.ts +++ b/packages/google-cloud-apigeeconnect/test/gapic_tether_v1.ts @@ -67,14 +67,60 @@ function stubBidiStreamingCall( describe('v1.TetherClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = tetherModule.v1.TetherClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new tetherModule.v1.TetherClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'apigeeconnect.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = tetherModule.v1.TetherClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new tetherModule.v1.TetherClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = tetherModule.v1.TetherClient.servicePath; + assert.strictEqual(servicePath, 'apigeeconnect.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = tetherModule.v1.TetherClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'apigeeconnect.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new tetherModule.v1.TetherClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'apigeeconnect.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new tetherModule.v1.TetherClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'apigeeconnect.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new tetherModule.v1.TetherClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_api_deployment_revisions.js b/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_api_deployment_revisions.js index abe60bfa38f..2afe16e1bdb 100644 --- a/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_api_deployment_revisions.js +++ b/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_api_deployment_revisions.js @@ -55,7 +55,7 @@ function main(name) { }; // Run request - const iterable = await apigeeregistryClient.listApiDeploymentRevisionsAsync(request); + const iterable = apigeeregistryClient.listApiDeploymentRevisionsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_api_deployments.js b/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_api_deployments.js index dc17928b6fc..5ba10fce133 100644 --- a/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_api_deployments.js +++ b/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_api_deployments.js @@ -66,7 +66,7 @@ function main(parent) { }; // Run request - const iterable = await apigeeregistryClient.listApiDeploymentsAsync(request); + const iterable = apigeeregistryClient.listApiDeploymentsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_api_spec_revisions.js b/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_api_spec_revisions.js index 9f80a8759ef..b226c51242a 100644 --- a/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_api_spec_revisions.js +++ b/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_api_spec_revisions.js @@ -55,7 +55,7 @@ function main(name) { }; // Run request - const iterable = await apigeeregistryClient.listApiSpecRevisionsAsync(request); + const iterable = apigeeregistryClient.listApiSpecRevisionsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_api_specs.js b/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_api_specs.js index 28706e61dae..5bc24ce522f 100644 --- a/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_api_specs.js +++ b/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_api_specs.js @@ -66,7 +66,7 @@ function main(parent) { }; // Run request - const iterable = await apigeeregistryClient.listApiSpecsAsync(request); + const iterable = apigeeregistryClient.listApiSpecsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_api_versions.js b/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_api_versions.js index 465ec8858e7..e53a051b2d0 100644 --- a/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_api_versions.js +++ b/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_api_versions.js @@ -66,7 +66,7 @@ function main(parent) { }; // Run request - const iterable = await apigeeregistryClient.listApiVersionsAsync(request); + const iterable = apigeeregistryClient.listApiVersionsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_apis.js b/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_apis.js index e5870e084a2..412e8dbacda 100644 --- a/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_apis.js +++ b/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_apis.js @@ -66,7 +66,7 @@ function main(parent) { }; // Run request - const iterable = await apigeeregistryClient.listApisAsync(request); + const iterable = apigeeregistryClient.listApisAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_artifacts.js b/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_artifacts.js index 03b5d36406b..0bf6382de63 100644 --- a/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_artifacts.js +++ b/packages/google-cloud-apigeeregistry/samples/generated/v1/registry.list_artifacts.js @@ -66,7 +66,7 @@ function main(parent) { }; // Run request - const iterable = await apigeeregistryClient.listArtifactsAsync(request); + const iterable = apigeeregistryClient.listArtifactsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-apigeeregistry/src/v1/provisioning_client.ts b/packages/google-cloud-apigeeregistry/src/v1/provisioning_client.ts index b6525ed06bb..42e9547af5d 100644 --- a/packages/google-cloud-apigeeregistry/src/v1/provisioning_client.ts +++ b/packages/google-cloud-apigeeregistry/src/v1/provisioning_client.ts @@ -33,6 +33,7 @@ import type { import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/provisioning_client_config.json`. @@ -55,6 +56,8 @@ export class ProvisioningClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -115,8 +118,20 @@ export class ProvisioningClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof ProvisioningClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'apigeeregistry.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -131,7 +146,7 @@ export class ProvisioningClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -156,10 +171,10 @@ export class ProvisioningClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); @@ -498,21 +513,52 @@ export class ProvisioningClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'apigeeregistry.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'apigeeregistry.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-cloud-apigeeregistry/src/v1/registry_client.ts b/packages/google-cloud-apigeeregistry/src/v1/registry_client.ts index 01b32f30fc5..9acf7ea389d 100644 --- a/packages/google-cloud-apigeeregistry/src/v1/registry_client.ts +++ b/packages/google-cloud-apigeeregistry/src/v1/registry_client.ts @@ -33,6 +33,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/registry_client_config.json`. @@ -54,6 +55,8 @@ export class RegistryClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -113,8 +116,20 @@ export class RegistryClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof RegistryClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'apigeeregistry.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -129,7 +144,7 @@ export class RegistryClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -154,10 +169,10 @@ export class RegistryClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); @@ -388,21 +403,52 @@ export class RegistryClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'apigeeregistry.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'apigeeregistry.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-cloud-apigeeregistry/test/gapic_provisioning_v1.ts b/packages/google-cloud-apigeeregistry/test/gapic_provisioning_v1.ts index e05288327f2..51772af366a 100644 --- a/packages/google-cloud-apigeeregistry/test/gapic_provisioning_v1.ts +++ b/packages/google-cloud-apigeeregistry/test/gapic_provisioning_v1.ts @@ -127,14 +127,62 @@ function stubAsyncIterationCall( describe('v1.ProvisioningClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = provisioningModule.v1.ProvisioningClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new provisioningModule.v1.ProvisioningClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'apigeeregistry.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = provisioningModule.v1.ProvisioningClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new provisioningModule.v1.ProvisioningClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + provisioningModule.v1.ProvisioningClient.servicePath; + assert.strictEqual(servicePath, 'apigeeregistry.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + provisioningModule.v1.ProvisioningClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'apigeeregistry.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new provisioningModule.v1.ProvisioningClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'apigeeregistry.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new provisioningModule.v1.ProvisioningClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'apigeeregistry.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new provisioningModule.v1.ProvisioningClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-cloud-apigeeregistry/test/gapic_registry_v1.ts b/packages/google-cloud-apigeeregistry/test/gapic_registry_v1.ts index 6c49e5daddb..b435e4b7de6 100644 --- a/packages/google-cloud-apigeeregistry/test/gapic_registry_v1.ts +++ b/packages/google-cloud-apigeeregistry/test/gapic_registry_v1.ts @@ -129,14 +129,60 @@ function stubAsyncIterationCall( describe('v1.RegistryClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = registryModule.v1.RegistryClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new registryModule.v1.RegistryClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'apigeeregistry.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = registryModule.v1.RegistryClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new registryModule.v1.RegistryClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = registryModule.v1.RegistryClient.servicePath; + assert.strictEqual(servicePath, 'apigeeregistry.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = registryModule.v1.RegistryClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'apigeeregistry.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new registryModule.v1.RegistryClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'apigeeregistry.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new registryModule.v1.RegistryClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'apigeeregistry.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new registryModule.v1.RegistryClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-cloud-assuredworkloads/samples/generated/v1/assured_workloads_service.list_violations.js b/packages/google-cloud-assuredworkloads/samples/generated/v1/assured_workloads_service.list_violations.js index 321df2de540..450f40f945c 100644 --- a/packages/google-cloud-assuredworkloads/samples/generated/v1/assured_workloads_service.list_violations.js +++ b/packages/google-cloud-assuredworkloads/samples/generated/v1/assured_workloads_service.list_violations.js @@ -65,7 +65,7 @@ function main(parent) { }; // Run request - const iterable = await assuredworkloadsClient.listViolationsAsync(request); + const iterable = assuredworkloadsClient.listViolationsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-assuredworkloads/samples/generated/v1/assured_workloads_service.list_workloads.js b/packages/google-cloud-assuredworkloads/samples/generated/v1/assured_workloads_service.list_workloads.js index 6802d57e5fa..1c3d49dcbdc 100644 --- a/packages/google-cloud-assuredworkloads/samples/generated/v1/assured_workloads_service.list_workloads.js +++ b/packages/google-cloud-assuredworkloads/samples/generated/v1/assured_workloads_service.list_workloads.js @@ -62,7 +62,7 @@ function main(parent) { }; // Run request - const iterable = await assuredworkloadsClient.listWorkloadsAsync(request); + const iterable = assuredworkloadsClient.listWorkloadsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-assuredworkloads/samples/generated/v1beta1/assured_workloads_service.list_workloads.js b/packages/google-cloud-assuredworkloads/samples/generated/v1beta1/assured_workloads_service.list_workloads.js index 5b8640e5509..b6eb1c10664 100644 --- a/packages/google-cloud-assuredworkloads/samples/generated/v1beta1/assured_workloads_service.list_workloads.js +++ b/packages/google-cloud-assuredworkloads/samples/generated/v1beta1/assured_workloads_service.list_workloads.js @@ -62,7 +62,7 @@ function main(parent) { }; // Run request - const iterable = await assuredworkloadsClient.listWorkloadsAsync(request); + const iterable = assuredworkloadsClient.listWorkloadsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-assuredworkloads/src/v1/assured_workloads_service_client.ts b/packages/google-cloud-assuredworkloads/src/v1/assured_workloads_service_client.ts index a2de543219f..2cc8464002d 100644 --- a/packages/google-cloud-assuredworkloads/src/v1/assured_workloads_service_client.ts +++ b/packages/google-cloud-assuredworkloads/src/v1/assured_workloads_service_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/assured_workloads_service_client_config.json`. @@ -52,6 +53,8 @@ export class AssuredWorkloadsServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -111,8 +114,20 @@ export class AssuredWorkloadsServiceClient { // Ensure that options include all the required fields. const staticMembers = this .constructor as typeof AssuredWorkloadsServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'assuredworkloads.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -127,7 +142,7 @@ export class AssuredWorkloadsServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -152,10 +167,10 @@ export class AssuredWorkloadsServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -345,21 +360,52 @@ export class AssuredWorkloadsServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'assuredworkloads.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'assuredworkloads.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-cloud-assuredworkloads/src/v1beta1/assured_workloads_service_client.ts b/packages/google-cloud-assuredworkloads/src/v1beta1/assured_workloads_service_client.ts index c17dbc64ff5..998ec507613 100644 --- a/packages/google-cloud-assuredworkloads/src/v1beta1/assured_workloads_service_client.ts +++ b/packages/google-cloud-assuredworkloads/src/v1beta1/assured_workloads_service_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1beta1/assured_workloads_service_client_config.json`. @@ -52,6 +53,8 @@ export class AssuredWorkloadsServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -111,8 +114,20 @@ export class AssuredWorkloadsServiceClient { // Ensure that options include all the required fields. const staticMembers = this .constructor as typeof AssuredWorkloadsServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'assuredworkloads.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -127,7 +142,7 @@ export class AssuredWorkloadsServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -152,10 +167,10 @@ export class AssuredWorkloadsServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -329,21 +344,52 @@ export class AssuredWorkloadsServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'assuredworkloads.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'assuredworkloads.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-cloud-assuredworkloads/test/gapic_assured_workloads_service_v1.ts b/packages/google-cloud-assuredworkloads/test/gapic_assured_workloads_service_v1.ts index a1c374eb42f..b68f4759db4 100644 --- a/packages/google-cloud-assuredworkloads/test/gapic_assured_workloads_service_v1.ts +++ b/packages/google-cloud-assuredworkloads/test/gapic_assured_workloads_service_v1.ts @@ -161,18 +161,68 @@ function stubAsyncIterationCall( describe('v1.AssuredWorkloadsServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - assuredworkloadsserviceModule.v1.AssuredWorkloadsServiceClient - .servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = + new assuredworkloadsserviceModule.v1.AssuredWorkloadsServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'assuredworkloads.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - assuredworkloadsserviceModule.v1.AssuredWorkloadsServiceClient - .apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = + new assuredworkloadsserviceModule.v1.AssuredWorkloadsServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + assuredworkloadsserviceModule.v1.AssuredWorkloadsServiceClient + .servicePath; + assert.strictEqual(servicePath, 'assuredworkloads.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + assuredworkloadsserviceModule.v1.AssuredWorkloadsServiceClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'assuredworkloads.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new assuredworkloadsserviceModule.v1.AssuredWorkloadsServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'assuredworkloads.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new assuredworkloadsserviceModule.v1.AssuredWorkloadsServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'assuredworkloads.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new assuredworkloadsserviceModule.v1.AssuredWorkloadsServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-cloud-assuredworkloads/test/gapic_assured_workloads_service_v1beta1.ts b/packages/google-cloud-assuredworkloads/test/gapic_assured_workloads_service_v1beta1.ts index 3ba47f6ab97..dcce221f92b 100644 --- a/packages/google-cloud-assuredworkloads/test/gapic_assured_workloads_service_v1beta1.ts +++ b/packages/google-cloud-assuredworkloads/test/gapic_assured_workloads_service_v1beta1.ts @@ -161,18 +161,67 @@ function stubAsyncIterationCall( describe('v1beta1.AssuredWorkloadsServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - assuredworkloadsserviceModule.v1beta1.AssuredWorkloadsServiceClient - .servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = + new assuredworkloadsserviceModule.v1beta1.AssuredWorkloadsServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'assuredworkloads.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - assuredworkloadsserviceModule.v1beta1.AssuredWorkloadsServiceClient - .apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = + new assuredworkloadsserviceModule.v1beta1.AssuredWorkloadsServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + assuredworkloadsserviceModule.v1beta1.AssuredWorkloadsServiceClient + .servicePath; + assert.strictEqual(servicePath, 'assuredworkloads.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + assuredworkloadsserviceModule.v1beta1.AssuredWorkloadsServiceClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'assuredworkloads.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new assuredworkloadsserviceModule.v1beta1.AssuredWorkloadsServiceClient( + {universeDomain: 'example.com'} + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'assuredworkloads.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new assuredworkloadsserviceModule.v1beta1.AssuredWorkloadsServiceClient( + {universe_domain: 'example.com'} + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'assuredworkloads.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new assuredworkloadsserviceModule.v1beta1.AssuredWorkloadsServiceClient( + {universe_domain: 'example.com', universeDomain: 'example.net'} + ); + }); }); it('has port', () => { diff --git a/packages/google-cloud-automl/samples/generated/v1/auto_ml.list_datasets.js b/packages/google-cloud-automl/samples/generated/v1/auto_ml.list_datasets.js index ea526e545ec..0e801c97676 100644 --- a/packages/google-cloud-automl/samples/generated/v1/auto_ml.list_datasets.js +++ b/packages/google-cloud-automl/samples/generated/v1/auto_ml.list_datasets.js @@ -66,7 +66,7 @@ function main(parent) { }; // Run request - const iterable = await automlClient.listDatasetsAsync(request); + const iterable = automlClient.listDatasetsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-automl/samples/generated/v1/auto_ml.list_model_evaluations.js b/packages/google-cloud-automl/samples/generated/v1/auto_ml.list_model_evaluations.js index a67a0b86231..4ab4ad3f6b9 100644 --- a/packages/google-cloud-automl/samples/generated/v1/auto_ml.list_model_evaluations.js +++ b/packages/google-cloud-automl/samples/generated/v1/auto_ml.list_model_evaluations.js @@ -71,7 +71,7 @@ function main(parent, filter) { }; // Run request - const iterable = await automlClient.listModelEvaluationsAsync(request); + const iterable = automlClient.listModelEvaluationsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-automl/samples/generated/v1/auto_ml.list_models.js b/packages/google-cloud-automl/samples/generated/v1/auto_ml.list_models.js index f82c4358dbf..24616879e5e 100644 --- a/packages/google-cloud-automl/samples/generated/v1/auto_ml.list_models.js +++ b/packages/google-cloud-automl/samples/generated/v1/auto_ml.list_models.js @@ -67,7 +67,7 @@ function main(parent) { }; // Run request - const iterable = await automlClient.listModelsAsync(request); + const iterable = automlClient.listModelsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-automl/samples/generated/v1beta1/auto_ml.list_column_specs.js b/packages/google-cloud-automl/samples/generated/v1beta1/auto_ml.list_column_specs.js index 22fb2a11311..65f832b4c87 100644 --- a/packages/google-cloud-automl/samples/generated/v1beta1/auto_ml.list_column_specs.js +++ b/packages/google-cloud-automl/samples/generated/v1beta1/auto_ml.list_column_specs.js @@ -66,7 +66,7 @@ function main(parent) { }; // Run request - const iterable = await automlClient.listColumnSpecsAsync(request); + const iterable = automlClient.listColumnSpecsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-automl/samples/generated/v1beta1/auto_ml.list_datasets.js b/packages/google-cloud-automl/samples/generated/v1beta1/auto_ml.list_datasets.js index 33fc0b2514a..7964582846e 100644 --- a/packages/google-cloud-automl/samples/generated/v1beta1/auto_ml.list_datasets.js +++ b/packages/google-cloud-automl/samples/generated/v1beta1/auto_ml.list_datasets.js @@ -67,7 +67,7 @@ function main(parent) { }; // Run request - const iterable = await automlClient.listDatasetsAsync(request); + const iterable = automlClient.listDatasetsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-automl/samples/generated/v1beta1/auto_ml.list_model_evaluations.js b/packages/google-cloud-automl/samples/generated/v1beta1/auto_ml.list_model_evaluations.js index 4cae4292d88..be72078ec32 100644 --- a/packages/google-cloud-automl/samples/generated/v1beta1/auto_ml.list_model_evaluations.js +++ b/packages/google-cloud-automl/samples/generated/v1beta1/auto_ml.list_model_evaluations.js @@ -70,7 +70,7 @@ function main(parent) { }; // Run request - const iterable = await automlClient.listModelEvaluationsAsync(request); + const iterable = automlClient.listModelEvaluationsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-automl/samples/generated/v1beta1/auto_ml.list_models.js b/packages/google-cloud-automl/samples/generated/v1beta1/auto_ml.list_models.js index 5d5bc072ae5..ae64b25e948 100644 --- a/packages/google-cloud-automl/samples/generated/v1beta1/auto_ml.list_models.js +++ b/packages/google-cloud-automl/samples/generated/v1beta1/auto_ml.list_models.js @@ -67,7 +67,7 @@ function main(parent) { }; // Run request - const iterable = await automlClient.listModelsAsync(request); + const iterable = automlClient.listModelsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-automl/samples/generated/v1beta1/auto_ml.list_table_specs.js b/packages/google-cloud-automl/samples/generated/v1beta1/auto_ml.list_table_specs.js index 21877d03476..612eb93cb18 100644 --- a/packages/google-cloud-automl/samples/generated/v1beta1/auto_ml.list_table_specs.js +++ b/packages/google-cloud-automl/samples/generated/v1beta1/auto_ml.list_table_specs.js @@ -66,7 +66,7 @@ function main(parent) { }; // Run request - const iterable = await automlClient.listTableSpecsAsync(request); + const iterable = automlClient.listTableSpecsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-automl/src/v1/auto_ml_client.ts b/packages/google-cloud-automl/src/v1/auto_ml_client.ts index 7a21b4c7da3..6ab49f858fd 100644 --- a/packages/google-cloud-automl/src/v1/auto_ml_client.ts +++ b/packages/google-cloud-automl/src/v1/auto_ml_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/auto_ml_client_config.json`. @@ -65,6 +66,8 @@ export class AutoMlClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -123,8 +126,20 @@ export class AutoMlClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof AutoMlClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'automl.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -139,7 +154,7 @@ export class AutoMlClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -164,10 +179,10 @@ export class AutoMlClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -515,21 +530,52 @@ export class AutoMlClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'automl.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'automl.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-cloud-automl/src/v1/prediction_service_client.ts b/packages/google-cloud-automl/src/v1/prediction_service_client.ts index 2349c6e8332..033192759fa 100644 --- a/packages/google-cloud-automl/src/v1/prediction_service_client.ts +++ b/packages/google-cloud-automl/src/v1/prediction_service_client.ts @@ -29,6 +29,7 @@ import type { import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/prediction_service_client_config.json`. @@ -53,6 +54,8 @@ export class PredictionServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -111,8 +114,20 @@ export class PredictionServiceClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof PredictionServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'automl.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -127,7 +142,7 @@ export class PredictionServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -152,10 +167,10 @@ export class PredictionServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -369,21 +384,52 @@ export class PredictionServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'automl.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'automl.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-cloud-automl/src/v1beta1/auto_ml_client.ts b/packages/google-cloud-automl/src/v1beta1/auto_ml_client.ts index ae7ccf13659..912bf1d7edf 100644 --- a/packages/google-cloud-automl/src/v1beta1/auto_ml_client.ts +++ b/packages/google-cloud-automl/src/v1beta1/auto_ml_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1beta1/auto_ml_client_config.json`. @@ -65,6 +66,8 @@ export class AutoMlClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -123,8 +126,20 @@ export class AutoMlClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof AutoMlClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'automl.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -139,7 +154,7 @@ export class AutoMlClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -164,10 +179,10 @@ export class AutoMlClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -533,21 +548,52 @@ export class AutoMlClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'automl.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'automl.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-cloud-automl/src/v1beta1/prediction_service_client.ts b/packages/google-cloud-automl/src/v1beta1/prediction_service_client.ts index c9d8001efa9..3cbad4ec975 100644 --- a/packages/google-cloud-automl/src/v1beta1/prediction_service_client.ts +++ b/packages/google-cloud-automl/src/v1beta1/prediction_service_client.ts @@ -29,6 +29,7 @@ import type { import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1beta1/prediction_service_client_config.json`. @@ -53,6 +54,8 @@ export class PredictionServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -111,8 +114,20 @@ export class PredictionServiceClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof PredictionServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'automl.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -127,7 +142,7 @@ export class PredictionServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -152,10 +167,10 @@ export class PredictionServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } @@ -367,21 +382,52 @@ export class PredictionServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'automl.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'automl.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-cloud-automl/test/gapic_auto_ml_v1.ts b/packages/google-cloud-automl/test/gapic_auto_ml_v1.ts index 6b9542aab9b..ad14551fb4c 100644 --- a/packages/google-cloud-automl/test/gapic_auto_ml_v1.ts +++ b/packages/google-cloud-automl/test/gapic_auto_ml_v1.ts @@ -161,14 +161,60 @@ function stubAsyncIterationCall( describe('v1.AutoMlClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = automlModule.v1.AutoMlClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new automlModule.v1.AutoMlClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'automl.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = automlModule.v1.AutoMlClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new automlModule.v1.AutoMlClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = automlModule.v1.AutoMlClient.servicePath; + assert.strictEqual(servicePath, 'automl.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = automlModule.v1.AutoMlClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'automl.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new automlModule.v1.AutoMlClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'automl.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new automlModule.v1.AutoMlClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'automl.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new automlModule.v1.AutoMlClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-cloud-automl/test/gapic_auto_ml_v1beta1.ts b/packages/google-cloud-automl/test/gapic_auto_ml_v1beta1.ts index 45d63f36cec..ac36309d308 100644 --- a/packages/google-cloud-automl/test/gapic_auto_ml_v1beta1.ts +++ b/packages/google-cloud-automl/test/gapic_auto_ml_v1beta1.ts @@ -161,14 +161,60 @@ function stubAsyncIterationCall( describe('v1beta1.AutoMlClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = automlModule.v1beta1.AutoMlClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new automlModule.v1beta1.AutoMlClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'automl.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = automlModule.v1beta1.AutoMlClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new automlModule.v1beta1.AutoMlClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = automlModule.v1beta1.AutoMlClient.servicePath; + assert.strictEqual(servicePath, 'automl.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = automlModule.v1beta1.AutoMlClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'automl.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new automlModule.v1beta1.AutoMlClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'automl.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new automlModule.v1beta1.AutoMlClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'automl.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new automlModule.v1beta1.AutoMlClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-cloud-automl/test/gapic_prediction_service_v1.ts b/packages/google-cloud-automl/test/gapic_prediction_service_v1.ts index a27ec3e48ed..23e1f7298b0 100644 --- a/packages/google-cloud-automl/test/gapic_prediction_service_v1.ts +++ b/packages/google-cloud-automl/test/gapic_prediction_service_v1.ts @@ -98,16 +98,62 @@ function stubLongRunningCallWithCallback( describe('v1.PredictionServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - predictionserviceModule.v1.PredictionServiceClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new predictionserviceModule.v1.PredictionServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'automl.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - predictionserviceModule.v1.PredictionServiceClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new predictionserviceModule.v1.PredictionServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + predictionserviceModule.v1.PredictionServiceClient.servicePath; + assert.strictEqual(servicePath, 'automl.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + predictionserviceModule.v1.PredictionServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'automl.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new predictionserviceModule.v1.PredictionServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'automl.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new predictionserviceModule.v1.PredictionServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'automl.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new predictionserviceModule.v1.PredictionServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-cloud-automl/test/gapic_prediction_service_v1beta1.ts b/packages/google-cloud-automl/test/gapic_prediction_service_v1beta1.ts index 5ae2280162a..9bda5def89d 100644 --- a/packages/google-cloud-automl/test/gapic_prediction_service_v1beta1.ts +++ b/packages/google-cloud-automl/test/gapic_prediction_service_v1beta1.ts @@ -98,16 +98,66 @@ function stubLongRunningCallWithCallback( describe('v1beta1.PredictionServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - predictionserviceModule.v1beta1.PredictionServiceClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = + new predictionserviceModule.v1beta1.PredictionServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'automl.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - predictionserviceModule.v1beta1.PredictionServiceClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = + new predictionserviceModule.v1beta1.PredictionServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + predictionserviceModule.v1beta1.PredictionServiceClient.servicePath; + assert.strictEqual(servicePath, 'automl.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + predictionserviceModule.v1beta1.PredictionServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'automl.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new predictionserviceModule.v1beta1.PredictionServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'automl.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new predictionserviceModule.v1beta1.PredictionServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'automl.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new predictionserviceModule.v1beta1.PredictionServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_instances.js b/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_instances.js index 5e9c505c026..58c16970ab1 100644 --- a/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_instances.js +++ b/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_instances.js @@ -59,7 +59,7 @@ function main(parent) { }; // Run request - const iterable = await baremetalsolutionClient.listInstancesAsync(request); + const iterable = baremetalsolutionClient.listInstancesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_luns.js b/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_luns.js index d2bcf529358..14fe08d20bc 100644 --- a/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_luns.js +++ b/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_luns.js @@ -55,7 +55,7 @@ function main(parent) { }; // Run request - const iterable = await baremetalsolutionClient.listLunsAsync(request); + const iterable = baremetalsolutionClient.listLunsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_networks.js b/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_networks.js index b32634d77b0..721543a3b88 100644 --- a/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_networks.js +++ b/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_networks.js @@ -59,7 +59,7 @@ function main(parent) { }; // Run request - const iterable = await baremetalsolutionClient.listNetworksAsync(request); + const iterable = baremetalsolutionClient.listNetworksAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_nfs_shares.js b/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_nfs_shares.js index 5a1eb3d1097..322cff5ee83 100644 --- a/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_nfs_shares.js +++ b/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_nfs_shares.js @@ -59,7 +59,7 @@ function main(parent) { }; // Run request - const iterable = await baremetalsolutionClient.listNfsSharesAsync(request); + const iterable = baremetalsolutionClient.listNfsSharesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_o_s_images.js b/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_o_s_images.js index c3148228100..87709c75d8c 100644 --- a/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_o_s_images.js +++ b/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_o_s_images.js @@ -57,7 +57,7 @@ function main(parent) { }; // Run request - const iterable = await baremetalsolutionClient.listOSImagesAsync(request); + const iterable = baremetalsolutionClient.listOSImagesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_provisioning_quotas.js b/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_provisioning_quotas.js index 4464639f717..ebae5759ace 100644 --- a/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_provisioning_quotas.js +++ b/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_provisioning_quotas.js @@ -57,7 +57,7 @@ function main(parent) { }; // Run request - const iterable = await baremetalsolutionClient.listProvisioningQuotasAsync(request); + const iterable = baremetalsolutionClient.listProvisioningQuotasAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_s_s_h_keys.js b/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_s_s_h_keys.js index d7009ff9aac..1e003e7bde4 100644 --- a/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_s_s_h_keys.js +++ b/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_s_s_h_keys.js @@ -55,7 +55,7 @@ function main(parent) { }; // Run request - const iterable = await baremetalsolutionClient.listSSHKeysAsync(request); + const iterable = baremetalsolutionClient.listSSHKeysAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_volume_snapshots.js b/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_volume_snapshots.js index 48604de938b..6c1ad8eeabe 100644 --- a/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_volume_snapshots.js +++ b/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_volume_snapshots.js @@ -55,7 +55,7 @@ function main(parent) { }; // Run request - const iterable = await baremetalsolutionClient.listVolumeSnapshotsAsync(request); + const iterable = baremetalsolutionClient.listVolumeSnapshotsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_volumes.js b/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_volumes.js index 44a090ed7ae..c0f5fe0c146 100644 --- a/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_volumes.js +++ b/packages/google-cloud-baremetalsolution/samples/generated/v2/bare_metal_solution.list_volumes.js @@ -59,7 +59,7 @@ function main(parent) { }; // Run request - const iterable = await baremetalsolutionClient.listVolumesAsync(request); + const iterable = baremetalsolutionClient.listVolumesAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-baremetalsolution/src/v2/bare_metal_solution_client.ts b/packages/google-cloud-baremetalsolution/src/v2/bare_metal_solution_client.ts index e931c3f9de3..d4d915499b2 100644 --- a/packages/google-cloud-baremetalsolution/src/v2/bare_metal_solution_client.ts +++ b/packages/google-cloud-baremetalsolution/src/v2/bare_metal_solution_client.ts @@ -35,6 +35,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v2/bare_metal_solution_client_config.json`. @@ -63,6 +64,8 @@ export class BareMetalSolutionClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -123,8 +126,20 @@ export class BareMetalSolutionClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof BareMetalSolutionClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'baremetalsolution.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -139,7 +154,7 @@ export class BareMetalSolutionClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -164,10 +179,10 @@ export class BareMetalSolutionClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); @@ -642,21 +657,52 @@ export class BareMetalSolutionClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'baremetalsolution.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'baremetalsolution.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-cloud-baremetalsolution/test/gapic_bare_metal_solution_v2.ts b/packages/google-cloud-baremetalsolution/test/gapic_bare_metal_solution_v2.ts index ff416e2ef92..2460f6ce747 100644 --- a/packages/google-cloud-baremetalsolution/test/gapic_bare_metal_solution_v2.ts +++ b/packages/google-cloud-baremetalsolution/test/gapic_bare_metal_solution_v2.ts @@ -167,16 +167,62 @@ function stubAsyncIterationCall( describe('v2.BareMetalSolutionClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - baremetalsolutionModule.v2.BareMetalSolutionClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new baremetalsolutionModule.v2.BareMetalSolutionClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'baremetalsolution.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - baremetalsolutionModule.v2.BareMetalSolutionClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new baremetalsolutionModule.v2.BareMetalSolutionClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + baremetalsolutionModule.v2.BareMetalSolutionClient.servicePath; + assert.strictEqual(servicePath, 'baremetalsolution.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + baremetalsolutionModule.v2.BareMetalSolutionClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'baremetalsolution.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new baremetalsolutionModule.v2.BareMetalSolutionClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'baremetalsolution.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new baremetalsolutionModule.v2.BareMetalSolutionClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'baremetalsolution.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new baremetalsolutionModule.v2.BareMetalSolutionClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-cloud-batch/samples/generated/v1/batch_service.list_jobs.js b/packages/google-cloud-batch/samples/generated/v1/batch_service.list_jobs.js index 7a59d9a4dd4..cfd8edc4cf8 100644 --- a/packages/google-cloud-batch/samples/generated/v1/batch_service.list_jobs.js +++ b/packages/google-cloud-batch/samples/generated/v1/batch_service.list_jobs.js @@ -62,7 +62,7 @@ function main() { }; // Run request - const iterable = await batchClient.listJobsAsync(request); + const iterable = batchClient.listJobsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-batch/samples/generated/v1/batch_service.list_tasks.js b/packages/google-cloud-batch/samples/generated/v1/batch_service.list_tasks.js index 6fede78d596..d0546798f89 100644 --- a/packages/google-cloud-batch/samples/generated/v1/batch_service.list_tasks.js +++ b/packages/google-cloud-batch/samples/generated/v1/batch_service.list_tasks.js @@ -62,7 +62,7 @@ function main(parent) { }; // Run request - const iterable = await batchClient.listTasksAsync(request); + const iterable = batchClient.listTasksAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.list_jobs.js b/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.list_jobs.js index 182d5f8d114..42a2ecc05b5 100644 --- a/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.list_jobs.js +++ b/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.list_jobs.js @@ -62,7 +62,7 @@ function main() { }; // Run request - const iterable = await batchClient.listJobsAsync(request); + const iterable = batchClient.listJobsAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.list_tasks.js b/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.list_tasks.js index 17f19202c31..8214c4fede3 100644 --- a/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.list_tasks.js +++ b/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.list_tasks.js @@ -66,7 +66,7 @@ function main(parent) { }; // Run request - const iterable = await batchClient.listTasksAsync(request); + const iterable = batchClient.listTasksAsync(request); for await (const response of iterable) { console.log(response); } diff --git a/packages/google-cloud-batch/src/v1/batch_service_client.ts b/packages/google-cloud-batch/src/v1/batch_service_client.ts index 5e4b25e2b0d..b61e7909d1a 100644 --- a/packages/google-cloud-batch/src/v1/batch_service_client.ts +++ b/packages/google-cloud-batch/src/v1/batch_service_client.ts @@ -33,6 +33,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1/batch_service_client_config.json`. @@ -56,6 +57,8 @@ export class BatchServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -115,8 +118,20 @@ export class BatchServiceClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof BatchServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'batch.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -131,7 +146,7 @@ export class BatchServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -156,10 +171,10 @@ export class BatchServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } this.locationsClient = new this._gaxModule.LocationsClient( @@ -369,21 +384,52 @@ export class BatchServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'batch.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'batch.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-cloud-batch/src/v1alpha/batch_service_client.ts b/packages/google-cloud-batch/src/v1alpha/batch_service_client.ts index 20c153fc965..720378b0767 100644 --- a/packages/google-cloud-batch/src/v1alpha/batch_service_client.ts +++ b/packages/google-cloud-batch/src/v1alpha/batch_service_client.ts @@ -33,6 +33,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); + /** * Client JSON configuration object, loaded from * `src/v1alpha/batch_service_client_config.json`. @@ -56,6 +57,8 @@ export class BatchServiceClient { private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; + private _universeDomain: string; + private _servicePath: string; auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -115,8 +118,20 @@ export class BatchServiceClient { ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof BatchServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + this._universeDomain = + opts?.universeDomain ?? opts?.universe_domain ?? 'googleapis.com'; + this._servicePath = 'batch.' + this._universeDomain; const servicePath = - opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + opts?.servicePath || opts?.apiEndpoint || this._servicePath; this._providedCustomServicePath = !!( opts?.servicePath || opts?.apiEndpoint ); @@ -131,7 +146,7 @@ export class BatchServiceClient { 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)) { + if (servicePath !== this._servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -156,10 +171,10 @@ export class BatchServiceClient { this.auth.useJWTAccessWithScope = true; // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; + this.auth.defaultServicePath = this._servicePath; // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { + if (servicePath === this._servicePath) { this.auth.defaultScopes = staticMembers.scopes; } this.locationsClient = new this._gaxModule.LocationsClient( @@ -369,21 +384,52 @@ export class BatchServiceClient { /** * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'batch.googleapis.com'; } /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { + if ( + typeof process !== undefined && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } return 'batch.googleapis.com'; } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + /** * The port for this API service. * @returns {number} The default port for this service. diff --git a/packages/google-cloud-batch/test/gapic_batch_service_v1.ts b/packages/google-cloud-batch/test/gapic_batch_service_v1.ts index d40d5bac4f9..5d94dca7b33 100644 --- a/packages/google-cloud-batch/test/gapic_batch_service_v1.ts +++ b/packages/google-cloud-batch/test/gapic_batch_service_v1.ts @@ -166,14 +166,62 @@ function stubAsyncIterationCall( describe('v1.BatchServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = batchserviceModule.v1.BatchServiceClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new batchserviceModule.v1.BatchServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'batch.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = batchserviceModule.v1.BatchServiceClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new batchserviceModule.v1.BatchServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + batchserviceModule.v1.BatchServiceClient.servicePath; + assert.strictEqual(servicePath, 'batch.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + batchserviceModule.v1.BatchServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'batch.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'batch.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'batch.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new batchserviceModule.v1.BatchServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => { diff --git a/packages/google-cloud-batch/test/gapic_batch_service_v1alpha.ts b/packages/google-cloud-batch/test/gapic_batch_service_v1alpha.ts index 295548ae3f2..c9fab51182e 100644 --- a/packages/google-cloud-batch/test/gapic_batch_service_v1alpha.ts +++ b/packages/google-cloud-batch/test/gapic_batch_service_v1alpha.ts @@ -166,16 +166,62 @@ function stubAsyncIterationCall( describe('v1alpha.BatchServiceClient', () => { describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = - batchserviceModule.v1alpha.BatchServiceClient.servicePath; - assert(servicePath); + it('has apiEndpoint', () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'batch.googleapis.com'); }); - it('has apiEndpoint', () => { - const apiEndpoint = - batchserviceModule.v1alpha.BatchServiceClient.apiEndpoint; - assert(apiEndpoint); + it('has universeDomain', () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process !== 'undefined' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + batchserviceModule.v1alpha.BatchServiceClient.servicePath; + assert.strictEqual(servicePath, 'batch.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + batchserviceModule.v1alpha.BatchServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'batch.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'batch.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'batch.example.com'); + }); + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new batchserviceModule.v1alpha.BatchServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); }); it('has port', () => {