diff --git a/BUILD.bazel b/BUILD.bazel index 5c191cee3e02e..c7142d44ec3ff 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -249,7 +249,7 @@ cc_library( ) cc_library( - name = "experimental-universe_domain", + name = "universe_domain", deps = [ "//google/cloud:google_cloud_cpp_universe_domain", ], diff --git a/bazel/gapic.bzl b/bazel/gapic.bzl index d3b30f21c8fa0..ef02cb7d259d6 100644 --- a/bazel/gapic.bzl +++ b/bazel/gapic.bzl @@ -82,6 +82,7 @@ def cc_gapic_library(name, service_dirs = [], googleapis_deps = [], additional_d tags = ["integration-test"], deps = [ "//:" + name, + "//:universe_domain", "//google/cloud/testing_util:google_cloud_cpp_testing_private", ], ) for sample in native.glob([d + "samples/*_samples.cc" for d in service_dirs])] diff --git a/ci/abi-dumps/google_cloud_cpp_universe_domain.expected.abi.dump.gz b/ci/abi-dumps/google_cloud_cpp_universe_domain.expected.abi.dump.gz new file mode 100644 index 0000000000000..3923eef72f9a8 Binary files /dev/null and b/ci/abi-dumps/google_cloud_cpp_universe_domain.expected.abi.dump.gz differ diff --git a/ci/cloudbuild/builds/check-api.sh b/ci/cloudbuild/builds/check-api.sh index 7804290967239..ef6a0b21b5ed4 100755 --- a/ci/cloudbuild/builds/check-api.sh +++ b/ci/cloudbuild/builds/check-api.sh @@ -31,10 +31,10 @@ if [ "${GOOGLE_CLOUD_CPP_CHECK_API:-}" ]; then readonly ENABLED_FEATURES="${GOOGLE_CLOUD_CPP_CHECK_API}" IFS=',' read -ra library_list <<<"${GOOGLE_CLOUD_CPP_CHECK_API}" else - readonly ENABLED_FEATURES="__ga_libraries__,opentelemetry" + readonly ENABLED_FEATURES="__ga_libraries__,opentelemetry,universe_domain" mapfile -t library_list < <(cmake -P cmake/print-ga-libraries.cmake 2>&1) # These libraries are not "features", but they are part of the public API - library_list+=("common" "grpc_utils") + library_list+=("common" "grpc_utils" "universe_domain") # This is a GA library, not included in __ga_libraries__ library_list+=("opentelemetry") fi @@ -67,7 +67,7 @@ function check_abi() { local shortlib="${library#google_cloud_cpp_}" local public_headers="${prefix}/include/google/cloud/${shortlib}" - if [[ "${shortlib}" == "common" || "${shortlib}" == "grpc_utils" || "${shortlib}" == "oauth2" ]]; then + if [[ "${shortlib}" == "common" || "${shortlib}" == "grpc_utils" || "${shortlib}" == "universe_domain" || "${shortlib}" == "oauth2" ]]; then # These are special and share their header location. public_headers="${prefix}/include/google/cloud" elif [[ "${shortlib}" == "storage_grpc" ]]; then diff --git a/ci/cloudbuild/builds/cmake-install.sh b/ci/cloudbuild/builds/cmake-install.sh index dd342671b263e..ea830d7ad9989 100755 --- a/ci/cloudbuild/builds/cmake-install.sh +++ b/ci/cloudbuild/builds/cmake-install.sh @@ -164,6 +164,7 @@ expected_dirs+=( ./lib64/cmake/google_cloud_cpp_rest_protobuf_internal ./lib64/cmake/google_cloud_cpp_storage_grpc ./lib64/cmake/google_cloud_cpp_storage_grpc_mocks + ./lib64/cmake/google_cloud_cpp_universe_domain ./lib64/pkgconfig ) diff --git a/ci/cloudbuild/builds/lib/features.sh b/ci/cloudbuild/builds/lib/features.sh index f9639a01ec2e8..243dbf48dde85 100755 --- a/ci/cloudbuild/builds/lib/features.sh +++ b/ci/cloudbuild/builds/lib/features.sh @@ -42,6 +42,8 @@ function features::always_build() { opentelemetry # Enable storage_grpc in most builds. storage_grpc + # Samples require universe domain support. + universe_domain ) printf "%s\n" "${list[@]}" | sort -u } @@ -63,6 +65,7 @@ function features::_internal_extra() { local list=( experimental-bigquery_rest opentelemetry + universe_domain ) printf "%s\n" "${list[@]}" } diff --git a/ci/cloudbuild/builds/publish-docs.sh b/ci/cloudbuild/builds/publish-docs.sh index a101b58197834..5f40ea6504bdb 100755 --- a/ci/cloudbuild/builds/publish-docs.sh +++ b/ci/cloudbuild/builds/publish-docs.sh @@ -35,7 +35,7 @@ elif [[ "${LIBRARIES}" == "all_bar_compute" ]]; then ENABLED_FEATURES="${ENABLED_FEATURES},-compute" else mapfile -t FEATURE_LIST < <(printf '%s' "${LIBRARIES}") - ENABLED_FEATURES="compute" + ENABLED_FEATURES="compute,universe_domain" fi doc_args=( diff --git a/ci/generate-markdown/update-library-landing-dox.sh b/ci/generate-markdown/update-library-landing-dox.sh index 6d676b19723f0..8559a7bd787d3 100755 --- a/ci/generate-markdown/update-library-landing-dox.sh +++ b/ci/generate-markdown/update-library-landing-dox.sh @@ -39,6 +39,7 @@ readonly EXPECTED=( "override-authentication.dox" "override-endpoint.dox" "override-retry-policies.dox" + "override-universe-domain.dox" ) for file in "${EXPECTED[@]}"; do if [[ ! -r "${DOCDIR}/${file}" ]]; then @@ -50,6 +51,7 @@ readonly MAIN_DOX="${DOCDIR}/main.dox" readonly ENVIRONMENT_DOX="${DOCDIR}/environment-variables.dox" readonly OVERRIDE_AUTHENTICATION_DOX="${DOCDIR}/override-authentication.dox" readonly OVERRIDE_ENDPOINT_DOX="${DOCDIR}/override-endpoint.dox" +readonly OVERRIDE_UNIVERSE_DOMAIN_DOX="${DOCDIR}/override-universe-domain.dox" readonly OVERRIDE_RETRY_POLICIES_DOX="${DOCDIR}/override-retry-policies.dox" inject_start="" @@ -196,6 +198,39 @@ _EOF_ sed -n '//,$p' "${OVERRIDE_ENDPOINT_DOX}" ) | sponge "${OVERRIDE_ENDPOINT_DOX}" +( + sed '//q' "${OVERRIDE_UNIVERSE_DOMAIN_DOX}" + if [[ ${#samples_cc[@]} -gt 0 ]]; then + sample_cc="${samples_cc[0]}" + client_name="${clients[${sample_cc}]}" + echo 'For example, this will override the default universe domain for `'"${client_name}"'`:' + echo + echo "@snippet $(basename "${sample_cc}") set-client-universe-domain" + if [[ ${#samples_cc[@]} -gt 1 ]]; then + echo + echo "Follow these links to find examples for other \\c *Client classes:" + echo + for sample_cc in "${samples_cc[@]}"; do + client_name="${clients[${sample_cc}]}" + # shellcheck disable=SC2016 + printf -- '- [\c %s](@ref %s-universe-domain-snippet)\n' "${client_name}" "${client_name}" + done + fi + fi + echo + sed -n '//,$p' "${OVERRIDE_UNIVERSE_DOMAIN_DOX}" +) | sponge "${OVERRIDE_UNIVERSE_DOMAIN_DOX}" + +( + sed '//q' "${OVERRIDE_UNIVERSE_DOMAIN_DOX}" + for sample_cc in "${samples_cc[@]}"; do + client_name="${clients[${sample_cc}]}" + printf '\n/*! @page %s-universe-domain-snippet Override %s Universe Domain\n\n@snippet %s set-client-universe-domain\n\n*/\n' \ + "${client_name}" "${client_name}" "${sample_cc}" + done + sed -n '//,$p' "${OVERRIDE_UNIVERSE_DOMAIN_DOX}" +) | sponge "${OVERRIDE_UNIVERSE_DOMAIN_DOX}" + ( sed '//q' "${OVERRIDE_RETRY_POLICIES_DOX}" if [[ ${#samples_cc[@]} -gt 0 ]]; then diff --git a/ci/lib/shard.sh b/ci/lib/shard.sh index 505e74d109887..b0e33320c2a0e 100644 --- a/ci/lib/shard.sh +++ b/ci/lib/shard.sh @@ -36,11 +36,13 @@ readonly DEFAULT_SHARD=( bigtable spanner logging + universe_domain ) readonly BIGQUERY_SHARD=( bigquery experimental-bigquery_rest + universe_domain ) readonly PUBSUB_SHARD=( @@ -51,6 +53,7 @@ readonly PUBSUB_SHARD=( # IAM is included because it has hand-crafted tests and/or examples and is # required by Pub/Sub iam + universe_domain ) readonly STORAGE_SHARD=( @@ -66,6 +69,7 @@ readonly STORAGE_SHARD=( readonly TOOLS_SHARD=( generator docfx + universe_domain ) function shard::cmake_features() { diff --git a/cmake/GoogleCloudCppCommon.cmake b/cmake/GoogleCloudCppCommon.cmake index a9213098624b6..923d69af009b1 100644 --- a/cmake/GoogleCloudCppCommon.cmake +++ b/cmake/GoogleCloudCppCommon.cmake @@ -132,12 +132,16 @@ function (google_cloud_cpp_add_samples_relative library path) google_cloud_cpp_add_executable(target "${library}" "${source}") if (TARGET google-cloud-cpp::${library}) target_link_libraries( - "${target}" PRIVATE google-cloud-cpp::${library} - google_cloud_cpp_testing) + "${target}" + PRIVATE google-cloud-cpp::${library} + google-cloud-cpp::universe_domain + google_cloud_cpp_testing) elseif (TARGET google-cloud-cpp::experimental-${library}) target_link_libraries( - "${target}" PRIVATE google-cloud-cpp::experimental-${library} - google_cloud_cpp_testing) + "${target}" + PRIVATE google-cloud-cpp::experimental-${library} + google-cloud-cpp::universe_domain + google_cloud_cpp_testing) endif () google_cloud_cpp_add_common_options("${target}") add_test(NAME "${target}" COMMAND "${target}") diff --git a/generator/integration_tests/BUILD.bazel b/generator/integration_tests/BUILD.bazel index 0d4c5238dfa19..597fae36f8cf0 100644 --- a/generator/integration_tests/BUILD.bazel +++ b/generator/integration_tests/BUILD.bazel @@ -145,6 +145,7 @@ filegroup( tags = ["integration-test"], deps = [ ":google_cloud_cpp_generator_golden", + "//:universe_domain", "//google/cloud/testing_util:google_cloud_cpp_testing_private", ], ) for sample in glob(["golden/v1/samples/*.cc"])] diff --git a/generator/integration_tests/CMakeLists.txt b/generator/integration_tests/CMakeLists.txt index 2b8fbe8af678e..11169e24a3435 100644 --- a/generator/integration_tests/CMakeLists.txt +++ b/generator/integration_tests/CMakeLists.txt @@ -131,7 +131,9 @@ foreach (fname IN LISTS samples_cc) target_link_libraries( ${target} PRIVATE google_cloud_cpp_generator_golden_testing - google_cloud_cpp_generator_golden google_cloud_cpp_testing + google_cloud_cpp_generator_golden + google_cloud_cpp_universe_domain + google_cloud_cpp_testing google_cloud_cpp_testing_grpc) google_cloud_cpp_add_common_options(${target}) add_test(NAME ${target} COMMAND ${target}) diff --git a/generator/integration_tests/golden/doc/override-universe-domain.dox b/generator/integration_tests/golden/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..8e62e353c783a --- /dev/null +++ b/generator/integration_tests/golden/doc/override-universe-domain.dox @@ -0,0 +1,15 @@ +/*! +@page golden-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + + + +*/ + +// +// diff --git a/generator/integration_tests/golden/v1/samples/deprecated_client_samples.cc b/generator/integration_tests/golden/v1/samples/deprecated_client_samples.cc index 079e18b4a2e8c..d0828947851e3 100644 --- a/generator/integration_tests/golden/v1/samples/deprecated_client_samples.cc +++ b/generator/integration_tests/golden/v1/samples/deprecated_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::golden_v1::DeprecatedServiceClient( + google::cloud::golden_v1::MakeDeprecatedServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::golden_v1::DeprecatedServiceConnectionIdempotencyPolicy { @@ -130,6 +150,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -139,6 +162,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/generator/integration_tests/golden/v1/samples/golden_kitchen_sink_client_samples.cc b/generator/integration_tests/golden/v1/samples/golden_kitchen_sink_client_samples.cc index a01e240f32b2e..2eead3588d107 100644 --- a/generator/integration_tests/golden/v1/samples/golden_kitchen_sink_client_samples.cc +++ b/generator/integration_tests/golden/v1/samples/golden_kitchen_sink_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::golden_v1::GoldenKitchenSinkClient( + google::cloud::golden_v1::MakeGoldenKitchenSinkConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::golden_v1::GoldenKitchenSinkConnectionIdempotencyPolicy { @@ -130,6 +150,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -139,6 +162,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/generator/integration_tests/golden/v1/samples/golden_rest_only_client_samples.cc b/generator/integration_tests/golden/v1/samples/golden_rest_only_client_samples.cc index 62b74dcfd8dd9..68de39100c9d3 100644 --- a/generator/integration_tests/golden/v1/samples/golden_rest_only_client_samples.cc +++ b/generator/integration_tests/golden/v1/samples/golden_rest_only_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -53,6 +54,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::golden_v1::GoldenRestOnlyClient( + google::cloud::golden_v1::MakeGoldenRestOnlyConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::golden_v1::GoldenRestOnlyConnectionIdempotencyPolicy { @@ -136,6 +156,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -145,6 +168,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/generator/integration_tests/golden/v1/samples/golden_thing_admin_client_samples.cc b/generator/integration_tests/golden/v1/samples/golden_thing_admin_client_samples.cc index 6a71d18955189..7864ea9fedd27 100644 --- a/generator/integration_tests/golden/v1/samples/golden_thing_admin_client_samples.cc +++ b/generator/integration_tests/golden/v1/samples/golden_thing_admin_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::golden_v1::GoldenThingAdminClient( + google::cloud::golden_v1::MakeGoldenThingAdminConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::golden_v1::GoldenThingAdminConnectionIdempotencyPolicy { @@ -169,6 +189,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -179,6 +202,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/generator/integration_tests/golden/v1/samples/request_id_client_samples.cc b/generator/integration_tests/golden/v1/samples/request_id_client_samples.cc index d4236c1ecf54e..60847f7efc6e0 100644 --- a/generator/integration_tests/golden/v1/samples/request_id_client_samples.cc +++ b/generator/integration_tests/golden/v1/samples/request_id_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::golden_v1::RequestIdServiceClient( + google::cloud::golden_v1::MakeRequestIdServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::golden_v1::RequestIdServiceConnectionIdempotencyPolicy { @@ -169,6 +189,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -179,6 +202,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/generator/internal/sample_generator.cc b/generator/internal/sample_generator.cc index 67333f934ff85..1d53cd32603e1 100644 --- a/generator/internal/sample_generator.cc +++ b/generator/internal/sample_generator.cc @@ -30,41 +30,10 @@ SampleGenerator::SampleGenerator( Status SampleGenerator::GenerateCc() { return {}; } -Status SampleGenerator::GenerateHeader() { +void SampleGenerator::GenerateSetClientEndpointSample() { auto endpoint_location_style = EndpointLocationStyle(); - HeaderPrint(CopyrightLicenseFileHeader()); HeaderPrint(R"""( -// Generated by the Codegen C++ plugin. -// If you make any local changes, they will be lost. -// source: $proto_file_name$ - -)"""); - - HeaderLocalIncludes({ - vars("client_header_path"), - vars("options_header_path"), - vars("idempotency_policy_header_path"), - "google/cloud/common_options.h", - "google/cloud/credentials.h", - HasLongrunningMethod() ? "google/cloud/polling_policy.h" : "", - "google/cloud/internal/getenv.h", - "google/cloud/testing_util/example_driver.h", - IsExperimental() ? "google/cloud/experimental_tag.h" : "", - }); - HeaderSystemIncludes({"iostream", "fstream", "string", "vector"}); - - HeaderPrint(R"""( -// clang-format off -// main-dox-marker: $product_namespace$::$client_class_name$)"""); - if (HasLongrunningMethod()) { - HeaderPrint(R"""( -// lro-marker: true)"""); - } - HeaderPrint(R"""( -// clang-format on -namespace { - void SetClientEndpoint(std::vector const& argv) { if (!argv.empty()) { throw google::cloud::testing_util::Usage{"set-client-endpoint"}; @@ -124,7 +93,88 @@ void SetClientEndpoint(std::vector const& argv) { HeaderPrint(R"""(options)); //! [set-client-endpoint] } +)"""); +} + +void SampleGenerator::GenerateSetClientUniverseDomainSample() { + auto endpoint_location_style = EndpointLocationStyle(); + HeaderPrint(R"""( +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::$product_namespace$::$client_class_name$()"""); + if (HasGenerateGrpcTransport()) { + HeaderPrint(R"""( + google::cloud::$product_namespace$::Make$connection_class_name$()"""); + } else { + HeaderPrint(R"""( + google::cloud::$product_namespace$::Make$connection_class_name$Rest()"""); + } + if (IsExperimental()) HeaderPrint("ExperimentalTag{},"); + switch (endpoint_location_style) { + case ServiceConfiguration::LOCATION_DEPENDENT: + HeaderPrint(R"""("unused", )"""); + break; + case ServiceConfiguration::LOCATION_DEPENDENT_COMPAT: + default: + break; + } + HeaderPrint(R"""(*ud_options)); + //! [set-client-universe-domain] +} +)"""); +} + +Status SampleGenerator::GenerateHeader() { + auto endpoint_location_style = EndpointLocationStyle(); + + HeaderPrint(CopyrightLicenseFileHeader()); + HeaderPrint(R"""( +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: $proto_file_name$ + +)"""); + + HeaderLocalIncludes({ + vars("client_header_path"), + vars("options_header_path"), + vars("idempotency_policy_header_path"), + "google/cloud/common_options.h", + "google/cloud/credentials.h", + "google/cloud/universe_domain.h", + HasLongrunningMethod() ? "google/cloud/polling_policy.h" : "", + "google/cloud/internal/getenv.h", + "google/cloud/testing_util/example_driver.h", + IsExperimental() ? "google/cloud/experimental_tag.h" : "", + }); + HeaderSystemIncludes({"iostream", "fstream", "string", "vector"}); + + HeaderPrint(R"""( +// clang-format off +// main-dox-marker: $product_namespace$::$client_class_name$)"""); + if (HasLongrunningMethod()) { + HeaderPrint(R"""( +// lro-marker: true)"""); + } + HeaderPrint(R"""( +// clang-format on +namespace { +)"""); + GenerateSetClientEndpointSample(); + GenerateSetClientUniverseDomainSample(); + HeaderPrint(R"""( //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::$product_namespace$::$idempotency_class_name$ { @@ -341,6 +391,9 @@ void AutoRun(std::vector const& argv) { HeaderPrint(R"""( std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -355,6 +408,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) )"""); } HeaderPrint(R"""( {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/generator/internal/sample_generator.h b/generator/internal/sample_generator.h index c873e40f5aadb..92fb4679eea1b 100644 --- a/generator/internal/sample_generator.h +++ b/generator/internal/sample_generator.h @@ -46,6 +46,9 @@ class SampleGenerator : public ServiceCodeGenerator { SampleGenerator& operator=(SampleGenerator&&) = default; private: + void GenerateSetClientEndpointSample(); + void GenerateSetClientUniverseDomainSample(); + Status GenerateHeader() override; Status GenerateCc() override; }; diff --git a/generator/internal/scaffold_generator.cc b/generator/internal/scaffold_generator.cc index 6df8ee3737f2e..01e05eea18473 100644 --- a/generator/internal/scaffold_generator.cc +++ b/generator/internal/scaffold_generator.cc @@ -347,6 +347,8 @@ void GenerateScaffold( {"doc/environment-variables.dox", GenerateDoxygenEnvironmentPage}, {"doc/override-authentication.dox", GenerateOverrideAuthenticationPage}, {"doc/override-endpoint.dox", GenerateOverrideEndpointPage}, + {"doc/override-universe-domain.dox", + GenerateOverrideUniverseDomainPage}, {"doc/override-retry-policies.dox", GenerateOverrideRetryPoliciesPage}, {"doc/options.dox", GenerateDoxygenOptionsPage}, }; @@ -360,6 +362,8 @@ void GenerateScaffold( {"doc/environment-variables.dox", GenerateDoxygenEnvironmentPage}, {"doc/override-authentication.dox", GenerateOverrideAuthenticationPage}, {"doc/override-endpoint.dox", GenerateOverrideEndpointPage}, + {"doc/override-universe-domain.dox", + GenerateOverrideUniverseDomainPage}, {"doc/override-retry-policies.dox", GenerateOverrideRetryPoliciesPage}, {"doc/options.dox", GenerateDoxygenOptionsPage}, {"quickstart/README.md", GenerateQuickstartReadme}, @@ -545,6 +549,7 @@ which should give you a taste of the $title$ C++ client library API. policies. - @ref $library$-env - describes environment variables that can configure the behavior of the library. +- @ref $library$-override-universe-domain - describes how to override the default universe domain. )"""; @@ -670,6 +675,29 @@ client library to change this default. printer.Print(variables, kText); } +void GenerateOverrideUniverseDomainPage( + std::ostream& os, std::map const& variables) { + auto constexpr kText = R"""(/*! +@page $library$-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + + + +*/ + +// +// +)"""; + google::protobuf::io::OstreamOutputStream output(&os); + google::protobuf::io::Printer printer(&output, '$'); + printer.Print(variables, kText); +} + void GenerateOverrideRetryPoliciesPage( std::ostream& os, std::map const& variables) { auto constexpr kText = R"""(/*! diff --git a/generator/internal/scaffold_generator.h b/generator/internal/scaffold_generator.h index cafd384dbd064..dbf38fb18109b 100644 --- a/generator/internal/scaffold_generator.h +++ b/generator/internal/scaffold_generator.h @@ -126,6 +126,8 @@ void GenerateOverrideAuthenticationPage( std::ostream& os, std::map const& variables); void GenerateOverrideEndpointPage( std::ostream& os, std::map const& variables); +void GenerateOverrideUniverseDomainPage( + std::ostream& os, std::map const& variables); void GenerateOverrideRetryPoliciesPage( std::ostream& os, std::map const& variables); void GenerateQuickstartReadme( diff --git a/google/cloud/accessapproval/doc/override-universe-domain.dox b/google/cloud/accessapproval/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..268a0a16252a3 --- /dev/null +++ b/google/cloud/accessapproval/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page accessapproval-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `accessapproval_v1::AccessApprovalClient`: + +@snippet access_approval_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page accessapproval_v1::AccessApprovalClient-universe-domain-snippet Override accessapproval_v1::AccessApprovalClient Universe Domain + +@snippet google/cloud/accessapproval/v1/samples/access_approval_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/accessapproval/v1/samples/access_approval_client_samples.cc b/google/cloud/accessapproval/v1/samples/access_approval_client_samples.cc index e2c4e39f98fb2..966222dd844ef 100644 --- a/google/cloud/accessapproval/v1/samples/access_approval_client_samples.cc +++ b/google/cloud/accessapproval/v1/samples/access_approval_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::accessapproval_v1::AccessApprovalClient( + google::cloud::accessapproval_v1::MakeAccessApprovalConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::accessapproval_v1:: AccessApprovalConnectionIdempotencyPolicy { @@ -144,6 +165,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -153,6 +177,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/accesscontextmanager/doc/override-universe-domain.dox b/google/cloud/accesscontextmanager/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..f566a764d3cb4 --- /dev/null +++ b/google/cloud/accesscontextmanager/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page accesscontextmanager-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `accesscontextmanager_v1::AccessContextManagerClient`: + +@snippet access_context_manager_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page accesscontextmanager_v1::AccessContextManagerClient-universe-domain-snippet Override accesscontextmanager_v1::AccessContextManagerClient Universe Domain + +@snippet google/cloud/accesscontextmanager/v1/samples/access_context_manager_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/accesscontextmanager/v1/samples/access_context_manager_client_samples.cc b/google/cloud/accesscontextmanager/v1/samples/access_context_manager_client_samples.cc index 1edf79a61f23f..46ab2a3cdcbc7 100644 --- a/google/cloud/accesscontextmanager/v1/samples/access_context_manager_client_samples.cc +++ b/google/cloud/accesscontextmanager/v1/samples/access_context_manager_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::accesscontextmanager_v1::AccessContextManagerClient( + google::cloud::accesscontextmanager_v1:: + MakeAccessContextManagerConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::accesscontextmanager_v1:: @@ -198,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -208,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/advisorynotifications/doc/override-universe-domain.dox b/google/cloud/advisorynotifications/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..02be1bb582d1b --- /dev/null +++ b/google/cloud/advisorynotifications/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page advisorynotifications-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `advisorynotifications_v1::AdvisoryNotificationsServiceClient`: + +@snippet advisory_notifications_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page advisorynotifications_v1::AdvisoryNotificationsServiceClient-universe-domain-snippet Override advisorynotifications_v1::AdvisoryNotificationsServiceClient Universe Domain + +@snippet google/cloud/advisorynotifications/v1/samples/advisory_notifications_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/advisorynotifications/v1/samples/advisory_notifications_client_samples.cc b/google/cloud/advisorynotifications/v1/samples/advisory_notifications_client_samples.cc index 5726ea8ca0a95..c709f0baa3491 100644 --- a/google/cloud/advisorynotifications/v1/samples/advisory_notifications_client_samples.cc +++ b/google/cloud/advisorynotifications/v1/samples/advisory_notifications_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::advisorynotifications_v1:: + AdvisoryNotificationsServiceClient( + google::cloud::advisorynotifications_v1:: + MakeAdvisoryNotificationsServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::advisorynotifications_v1:: @@ -154,6 +176,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -163,6 +188,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/doc/override-universe-domain.dox b/google/cloud/aiplatform/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..662187ad5e1c8 --- /dev/null +++ b/google/cloud/aiplatform/doc/override-universe-domain.dox @@ -0,0 +1,211 @@ +/*! +@page aiplatform-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `aiplatform_v1::DatasetServiceClient`: + +@snippet dataset_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c aiplatform_v1::DatasetServiceClient](@ref aiplatform_v1::DatasetServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::DeploymentResourcePoolServiceClient](@ref aiplatform_v1::DeploymentResourcePoolServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::EndpointServiceClient](@ref aiplatform_v1::EndpointServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::EvaluationServiceClient](@ref aiplatform_v1::EvaluationServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::FeatureOnlineStoreAdminServiceClient](@ref aiplatform_v1::FeatureOnlineStoreAdminServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::FeatureOnlineStoreServiceClient](@ref aiplatform_v1::FeatureOnlineStoreServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::FeatureRegistryServiceClient](@ref aiplatform_v1::FeatureRegistryServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::FeaturestoreServiceClient](@ref aiplatform_v1::FeaturestoreServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::FeaturestoreOnlineServingServiceClient](@ref aiplatform_v1::FeaturestoreOnlineServingServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::GenAiTuningServiceClient](@ref aiplatform_v1::GenAiTuningServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::IndexServiceClient](@ref aiplatform_v1::IndexServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::IndexEndpointServiceClient](@ref aiplatform_v1::IndexEndpointServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::JobServiceClient](@ref aiplatform_v1::JobServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::LlmUtilityServiceClient](@ref aiplatform_v1::LlmUtilityServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::MatchServiceClient](@ref aiplatform_v1::MatchServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::MetadataServiceClient](@ref aiplatform_v1::MetadataServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::MigrationServiceClient](@ref aiplatform_v1::MigrationServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::ModelServiceClient](@ref aiplatform_v1::ModelServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::ModelGardenServiceClient](@ref aiplatform_v1::ModelGardenServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::NotebookServiceClient](@ref aiplatform_v1::NotebookServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::PersistentResourceServiceClient](@ref aiplatform_v1::PersistentResourceServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::PipelineServiceClient](@ref aiplatform_v1::PipelineServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::PredictionServiceClient](@ref aiplatform_v1::PredictionServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::ScheduleServiceClient](@ref aiplatform_v1::ScheduleServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::SpecialistPoolServiceClient](@ref aiplatform_v1::SpecialistPoolServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::TensorboardServiceClient](@ref aiplatform_v1::TensorboardServiceClient-universe-domain-snippet) +- [\c aiplatform_v1::VizierServiceClient](@ref aiplatform_v1::VizierServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page aiplatform_v1::DatasetServiceClient-universe-domain-snippet Override aiplatform_v1::DatasetServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/dataset_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::DeploymentResourcePoolServiceClient-universe-domain-snippet Override aiplatform_v1::DeploymentResourcePoolServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/deployment_resource_pool_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::EndpointServiceClient-universe-domain-snippet Override aiplatform_v1::EndpointServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/endpoint_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::EvaluationServiceClient-universe-domain-snippet Override aiplatform_v1::EvaluationServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/evaluation_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::FeatureOnlineStoreAdminServiceClient-universe-domain-snippet Override aiplatform_v1::FeatureOnlineStoreAdminServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/feature_online_store_admin_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::FeatureOnlineStoreServiceClient-universe-domain-snippet Override aiplatform_v1::FeatureOnlineStoreServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/feature_online_store_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::FeatureRegistryServiceClient-universe-domain-snippet Override aiplatform_v1::FeatureRegistryServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/feature_registry_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::FeaturestoreServiceClient-universe-domain-snippet Override aiplatform_v1::FeaturestoreServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/featurestore_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::FeaturestoreOnlineServingServiceClient-universe-domain-snippet Override aiplatform_v1::FeaturestoreOnlineServingServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/featurestore_online_serving_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::GenAiTuningServiceClient-universe-domain-snippet Override aiplatform_v1::GenAiTuningServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/gen_ai_tuning_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::IndexServiceClient-universe-domain-snippet Override aiplatform_v1::IndexServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/index_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::IndexEndpointServiceClient-universe-domain-snippet Override aiplatform_v1::IndexEndpointServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/index_endpoint_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::JobServiceClient-universe-domain-snippet Override aiplatform_v1::JobServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/job_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::LlmUtilityServiceClient-universe-domain-snippet Override aiplatform_v1::LlmUtilityServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/llm_utility_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::MatchServiceClient-universe-domain-snippet Override aiplatform_v1::MatchServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/match_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::MetadataServiceClient-universe-domain-snippet Override aiplatform_v1::MetadataServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/metadata_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::MigrationServiceClient-universe-domain-snippet Override aiplatform_v1::MigrationServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/migration_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::ModelServiceClient-universe-domain-snippet Override aiplatform_v1::ModelServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/model_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::ModelGardenServiceClient-universe-domain-snippet Override aiplatform_v1::ModelGardenServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/model_garden_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::NotebookServiceClient-universe-domain-snippet Override aiplatform_v1::NotebookServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/notebook_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::PersistentResourceServiceClient-universe-domain-snippet Override aiplatform_v1::PersistentResourceServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/persistent_resource_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::PipelineServiceClient-universe-domain-snippet Override aiplatform_v1::PipelineServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/pipeline_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::PredictionServiceClient-universe-domain-snippet Override aiplatform_v1::PredictionServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/prediction_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::ScheduleServiceClient-universe-domain-snippet Override aiplatform_v1::ScheduleServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/schedule_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::SpecialistPoolServiceClient-universe-domain-snippet Override aiplatform_v1::SpecialistPoolServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/specialist_pool_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::TensorboardServiceClient-universe-domain-snippet Override aiplatform_v1::TensorboardServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/tensorboard_client_samples.cc set-client-universe-domain + +*/ + +/*! @page aiplatform_v1::VizierServiceClient-universe-domain-snippet Override aiplatform_v1::VizierServiceClient Universe Domain + +@snippet google/cloud/aiplatform/v1/samples/vizier_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/aiplatform/v1/samples/dataset_client_samples.cc b/google/cloud/aiplatform/v1/samples/dataset_client_samples.cc index bba5c5d7e0c63..fdea632948597 100644 --- a/google/cloud/aiplatform/v1/samples/dataset_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/dataset_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::aiplatform_v1::DatasetServiceClient( + google::cloud::aiplatform_v1::MakeDatasetServiceConnection("unused", + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: DatasetServiceConnectionIdempotencyPolicy { @@ -188,6 +209,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -198,6 +222,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/deployment_resource_pool_client_samples.cc b/google/cloud/aiplatform/v1/samples/deployment_resource_pool_client_samples.cc index bdfb4256e3090..fbda2f751e42d 100644 --- a/google/cloud/aiplatform/v1/samples/deployment_resource_pool_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/deployment_resource_pool_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,28 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::aiplatform_v1::DeploymentResourcePoolServiceClient( + google::cloud::aiplatform_v1:: + MakeDeploymentResourcePoolServiceConnection("unused", + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: @@ -203,6 +226,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -213,6 +239,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/endpoint_client_samples.cc b/google/cloud/aiplatform/v1/samples/endpoint_client_samples.cc index 886d6b03037c1..5805a89c05ca0 100644 --- a/google/cloud/aiplatform/v1/samples/endpoint_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/endpoint_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::aiplatform_v1::EndpointServiceClient( + google::cloud::aiplatform_v1::MakeEndpointServiceConnection("unused", + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: EndpointServiceConnectionIdempotencyPolicy { @@ -190,6 +211,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -200,6 +224,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/evaluation_client_samples.cc b/google/cloud/aiplatform/v1/samples/evaluation_client_samples.cc index b5feb9a9a96a9..f7cae1d674f8b 100644 --- a/google/cloud/aiplatform/v1/samples/evaluation_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/evaluation_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::aiplatform_v1::EvaluationServiceClient( + google::cloud::aiplatform_v1::MakeEvaluationServiceConnection( + "unused", *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: @@ -149,6 +170,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -158,6 +182,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/feature_online_store_admin_client_samples.cc b/google/cloud/aiplatform/v1/samples/feature_online_store_admin_client_samples.cc index 3d7c2ef79d48b..95554a6c7966a 100644 --- a/google/cloud/aiplatform/v1/samples/feature_online_store_admin_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/feature_online_store_admin_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,28 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::aiplatform_v1::FeatureOnlineStoreAdminServiceClient( + google::cloud::aiplatform_v1:: + MakeFeatureOnlineStoreAdminServiceConnection("unused", + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: @@ -203,6 +226,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -213,6 +239,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/feature_online_store_client_samples.cc b/google/cloud/aiplatform/v1/samples/feature_online_store_client_samples.cc index 9e38b9bcb6f2a..68744260c0851 100644 --- a/google/cloud/aiplatform/v1/samples/feature_online_store_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/feature_online_store_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::aiplatform_v1::FeatureOnlineStoreServiceClient( + google::cloud::aiplatform_v1::MakeFeatureOnlineStoreServiceConnection( + "unused", *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: @@ -151,6 +173,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -160,6 +185,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/feature_registry_client_samples.cc b/google/cloud/aiplatform/v1/samples/feature_registry_client_samples.cc index 84f8236576abc..0a2a130cc6aab 100644 --- a/google/cloud/aiplatform/v1/samples/feature_registry_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/feature_registry_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::aiplatform_v1::FeatureRegistryServiceClient( + google::cloud::aiplatform_v1::MakeFeatureRegistryServiceConnection( + "unused", *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: @@ -199,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -209,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/featurestore_client_samples.cc b/google/cloud/aiplatform/v1/samples/featurestore_client_samples.cc index 90522200b7f3c..67e465d1b33ba 100644 --- a/google/cloud/aiplatform/v1/samples/featurestore_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/featurestore_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::aiplatform_v1::FeaturestoreServiceClient( + google::cloud::aiplatform_v1::MakeFeaturestoreServiceConnection( + "unused", *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: @@ -195,6 +216,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -205,6 +229,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/featurestore_online_serving_client_samples.cc b/google/cloud/aiplatform/v1/samples/featurestore_online_serving_client_samples.cc index e6a2c285d3d16..f78bb44c23821 100644 --- a/google/cloud/aiplatform/v1/samples/featurestore_online_serving_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/featurestore_online_serving_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,28 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::aiplatform_v1::FeaturestoreOnlineServingServiceClient( + google::cloud::aiplatform_v1:: + MakeFeaturestoreOnlineServingServiceConnection("unused", + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: @@ -160,6 +183,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -169,6 +195,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/gen_ai_tuning_client_samples.cc b/google/cloud/aiplatform/v1/samples/gen_ai_tuning_client_samples.cc index b4d84f67f74ff..0f664dca01017 100644 --- a/google/cloud/aiplatform/v1/samples/gen_ai_tuning_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/gen_ai_tuning_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::aiplatform_v1::GenAiTuningServiceClient( + google::cloud::aiplatform_v1::MakeGenAiTuningServiceConnection( + "unused", *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: @@ -195,6 +216,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -205,6 +229,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/index_client_samples.cc b/google/cloud/aiplatform/v1/samples/index_client_samples.cc index dc106b3e2a84f..87b8ea81431fd 100644 --- a/google/cloud/aiplatform/v1/samples/index_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/index_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::aiplatform_v1::IndexServiceClient( + google::cloud::aiplatform_v1::MakeIndexServiceConnection("unused", + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: IndexServiceConnectionIdempotencyPolicy { @@ -188,6 +209,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -198,6 +222,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/index_endpoint_client_samples.cc b/google/cloud/aiplatform/v1/samples/index_endpoint_client_samples.cc index 628a78d09513c..311ce2f9af1c9 100644 --- a/google/cloud/aiplatform/v1/samples/index_endpoint_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/index_endpoint_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::aiplatform_v1::IndexEndpointServiceClient( + google::cloud::aiplatform_v1::MakeIndexEndpointServiceConnection( + "unused", *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: @@ -199,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -209,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/job_client_samples.cc b/google/cloud/aiplatform/v1/samples/job_client_samples.cc index 374a8a7fc09aa..8215a4fb6b09d 100644 --- a/google/cloud/aiplatform/v1/samples/job_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/job_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::aiplatform_v1::JobServiceClient( + google::cloud::aiplatform_v1::MakeJobServiceConnection("unused", + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: JobServiceConnectionIdempotencyPolicy { @@ -188,6 +209,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -198,6 +222,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/llm_utility_client_samples.cc b/google/cloud/aiplatform/v1/samples/llm_utility_client_samples.cc index 422caa3b3390b..cf346d7df4d4e 100644 --- a/google/cloud/aiplatform/v1/samples/llm_utility_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/llm_utility_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::aiplatform_v1::LlmUtilityServiceClient( + google::cloud::aiplatform_v1::MakeLlmUtilityServiceConnection( + "unused", *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: @@ -149,6 +170,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -158,6 +182,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/match_client_samples.cc b/google/cloud/aiplatform/v1/samples/match_client_samples.cc index 2a174ded15347..b802a4aa2c590 100644 --- a/google/cloud/aiplatform/v1/samples/match_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/match_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::aiplatform_v1::MatchServiceClient( + google::cloud::aiplatform_v1::MakeMatchServiceConnection("unused", + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: MatchServiceConnectionIdempotencyPolicy { @@ -143,6 +164,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -152,6 +176,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/metadata_client_samples.cc b/google/cloud/aiplatform/v1/samples/metadata_client_samples.cc index c7b7541f39405..df1bd49c55891 100644 --- a/google/cloud/aiplatform/v1/samples/metadata_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/metadata_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::aiplatform_v1::MetadataServiceClient( + google::cloud::aiplatform_v1::MakeMetadataServiceConnection("unused", + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: MetadataServiceConnectionIdempotencyPolicy { @@ -190,6 +211,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -200,6 +224,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/migration_client_samples.cc b/google/cloud/aiplatform/v1/samples/migration_client_samples.cc index ad5d3317cdd29..e3d16bd8b1dab 100644 --- a/google/cloud/aiplatform/v1/samples/migration_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/migration_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::aiplatform_v1::MigrationServiceClient( + google::cloud::aiplatform_v1::MakeMigrationServiceConnection( + "unused", *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: @@ -194,6 +215,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -204,6 +228,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/model_client_samples.cc b/google/cloud/aiplatform/v1/samples/model_client_samples.cc index 81d78448ca158..aa46e35e272a1 100644 --- a/google/cloud/aiplatform/v1/samples/model_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/model_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::aiplatform_v1::ModelServiceClient( + google::cloud::aiplatform_v1::MakeModelServiceConnection("unused", + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: ModelServiceConnectionIdempotencyPolicy { @@ -188,6 +209,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -198,6 +222,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/model_garden_client_samples.cc b/google/cloud/aiplatform/v1/samples/model_garden_client_samples.cc index 1c1ccbebc9ba9..aeab36825908f 100644 --- a/google/cloud/aiplatform/v1/samples/model_garden_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/model_garden_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::aiplatform_v1::ModelGardenServiceClient( + google::cloud::aiplatform_v1::MakeModelGardenServiceConnection( + "unused", *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: @@ -195,6 +216,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -205,6 +229,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/notebook_client_samples.cc b/google/cloud/aiplatform/v1/samples/notebook_client_samples.cc index 7907ec6e486e6..60819dcb38242 100644 --- a/google/cloud/aiplatform/v1/samples/notebook_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/notebook_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::aiplatform_v1::NotebookServiceClient( + google::cloud::aiplatform_v1::MakeNotebookServiceConnection("unused", + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: NotebookServiceConnectionIdempotencyPolicy { @@ -190,6 +211,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -200,6 +224,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/persistent_resource_client_samples.cc b/google/cloud/aiplatform/v1/samples/persistent_resource_client_samples.cc index fa60a8f6d16c0..f965683d68c42 100644 --- a/google/cloud/aiplatform/v1/samples/persistent_resource_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/persistent_resource_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::aiplatform_v1::PersistentResourceServiceClient( + google::cloud::aiplatform_v1::MakePersistentResourceServiceConnection( + "unused", *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: @@ -200,6 +222,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -210,6 +235,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/pipeline_client_samples.cc b/google/cloud/aiplatform/v1/samples/pipeline_client_samples.cc index 01f806c4c09ce..114f63fe93eba 100644 --- a/google/cloud/aiplatform/v1/samples/pipeline_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/pipeline_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::aiplatform_v1::PipelineServiceClient( + google::cloud::aiplatform_v1::MakePipelineServiceConnection("unused", + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: PipelineServiceConnectionIdempotencyPolicy { @@ -190,6 +211,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -200,6 +224,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/prediction_client_samples.cc b/google/cloud/aiplatform/v1/samples/prediction_client_samples.cc index d196e66cfde56..28f7dd70ff24d 100644 --- a/google/cloud/aiplatform/v1/samples/prediction_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/prediction_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::aiplatform_v1::PredictionServiceClient( + google::cloud::aiplatform_v1::MakePredictionServiceConnection( + "unused", *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: @@ -149,6 +170,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -158,6 +182,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/schedule_client_samples.cc b/google/cloud/aiplatform/v1/samples/schedule_client_samples.cc index 0c45a054ad38b..dd91715d5a997 100644 --- a/google/cloud/aiplatform/v1/samples/schedule_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/schedule_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::aiplatform_v1::ScheduleServiceClient( + google::cloud::aiplatform_v1::MakeScheduleServiceConnection("unused", + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: ScheduleServiceConnectionIdempotencyPolicy { @@ -190,6 +211,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -200,6 +224,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/specialist_pool_client_samples.cc b/google/cloud/aiplatform/v1/samples/specialist_pool_client_samples.cc index 8cd602b1545f4..5b892a932deff 100644 --- a/google/cloud/aiplatform/v1/samples/specialist_pool_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/specialist_pool_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::aiplatform_v1::SpecialistPoolServiceClient( + google::cloud::aiplatform_v1::MakeSpecialistPoolServiceConnection( + "unused", *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: @@ -199,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -209,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/tensorboard_client_samples.cc b/google/cloud/aiplatform/v1/samples/tensorboard_client_samples.cc index 635339d3bf8eb..1e0c4436dbe18 100644 --- a/google/cloud/aiplatform/v1/samples/tensorboard_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/tensorboard_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::aiplatform_v1::TensorboardServiceClient( + google::cloud::aiplatform_v1::MakeTensorboardServiceConnection( + "unused", *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: @@ -195,6 +216,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -205,6 +229,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/aiplatform/v1/samples/vizier_client_samples.cc b/google/cloud/aiplatform/v1/samples/vizier_client_samples.cc index c378e2a355fc1..b0fec8fc1c1d0 100644 --- a/google/cloud/aiplatform/v1/samples/vizier_client_samples.cc +++ b/google/cloud/aiplatform/v1/samples/vizier_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::aiplatform_v1::VizierServiceClient( + google::cloud::aiplatform_v1::MakeVizierServiceConnection("unused", + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::aiplatform_v1:: VizierServiceConnectionIdempotencyPolicy { @@ -188,6 +209,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -198,6 +222,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/alloydb/doc/override-universe-domain.dox b/google/cloud/alloydb/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..51779bc64fa83 --- /dev/null +++ b/google/cloud/alloydb/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page alloydb-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `alloydb_v1::AlloyDBAdminClient`: + +@snippet alloy_db_admin_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page alloydb_v1::AlloyDBAdminClient-universe-domain-snippet Override alloydb_v1::AlloyDBAdminClient Universe Domain + +@snippet google/cloud/alloydb/v1/samples/alloy_db_admin_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/alloydb/v1/samples/alloy_db_admin_client_samples.cc b/google/cloud/alloydb/v1/samples/alloy_db_admin_client_samples.cc index aa42633d57828..f520afaec1aa3 100644 --- a/google/cloud/alloydb/v1/samples/alloy_db_admin_client_samples.cc +++ b/google/cloud/alloydb/v1/samples/alloy_db_admin_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::alloydb_v1::AlloyDBAdminClient( + google::cloud::alloydb_v1::MakeAlloyDBAdminConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::alloydb_v1:: AlloyDBAdminConnectionIdempotencyPolicy { @@ -185,6 +205,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -195,6 +218,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/apigateway/doc/override-universe-domain.dox b/google/cloud/apigateway/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..8a92ed56d1aaa --- /dev/null +++ b/google/cloud/apigateway/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page apigateway-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `apigateway_v1::ApiGatewayServiceClient`: + +@snippet api_gateway_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page apigateway_v1::ApiGatewayServiceClient-universe-domain-snippet Override apigateway_v1::ApiGatewayServiceClient Universe Domain + +@snippet google/cloud/apigateway/v1/samples/api_gateway_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/apigateway/v1/samples/api_gateway_client_samples.cc b/google/cloud/apigateway/v1/samples/api_gateway_client_samples.cc index bbfb65c2cb8eb..4e3d1f84959b7 100644 --- a/google/cloud/apigateway/v1/samples/api_gateway_client_samples.cc +++ b/google/cloud/apigateway/v1/samples/api_gateway_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::apigateway_v1::ApiGatewayServiceClient( + google::cloud::apigateway_v1::MakeApiGatewayServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::apigateway_v1:: @@ -192,6 +213,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -202,6 +226,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/apigeeconnect/doc/override-universe-domain.dox b/google/cloud/apigeeconnect/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..9f1f151941b67 --- /dev/null +++ b/google/cloud/apigeeconnect/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page apigeeconnect-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `apigeeconnect_v1::ConnectionServiceClient`: + +@snippet connection_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page apigeeconnect_v1::ConnectionServiceClient-universe-domain-snippet Override apigeeconnect_v1::ConnectionServiceClient Universe Domain + +@snippet google/cloud/apigeeconnect/v1/samples/connection_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/apigeeconnect/v1/samples/connection_client_samples.cc b/google/cloud/apigeeconnect/v1/samples/connection_client_samples.cc index 0a27799841031..a4440e67e6484 100644 --- a/google/cloud/apigeeconnect/v1/samples/connection_client_samples.cc +++ b/google/cloud/apigeeconnect/v1/samples/connection_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::apigeeconnect_v1::ConnectionServiceClient( + google::cloud::apigeeconnect_v1::MakeConnectionServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::apigeeconnect_v1:: @@ -149,6 +170,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -158,6 +182,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/apikeys/doc/override-universe-domain.dox b/google/cloud/apikeys/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..97c8159352b19 --- /dev/null +++ b/google/cloud/apikeys/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page apikeys-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `apikeys_v2::ApiKeysClient`: + +@snippet api_keys_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page apikeys_v2::ApiKeysClient-universe-domain-snippet Override apikeys_v2::ApiKeysClient Universe Domain + +@snippet google/cloud/apikeys/v2/samples/api_keys_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/apikeys/v2/samples/api_keys_client_samples.cc b/google/cloud/apikeys/v2/samples/api_keys_client_samples.cc index e1e7b282c8a41..dfc30dd2a94c1 100644 --- a/google/cloud/apikeys/v2/samples/api_keys_client_samples.cc +++ b/google/cloud/apikeys/v2/samples/api_keys_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::apikeys_v2::ApiKeysClient( + google::cloud::apikeys_v2::MakeApiKeysConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::apikeys_v2::ApiKeysConnectionIdempotencyPolicy { @@ -179,6 +199,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -189,6 +212,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/appengine/doc/override-universe-domain.dox b/google/cloud/appengine/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..c33388d96e9bd --- /dev/null +++ b/google/cloud/appengine/doc/override-universe-domain.dox @@ -0,0 +1,78 @@ +/*! +@page appengine-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `appengine_v1::ApplicationsClient`: + +@snippet applications_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c appengine_v1::ApplicationsClient](@ref appengine_v1::ApplicationsClient-universe-domain-snippet) +- [\c appengine_v1::AuthorizedCertificatesClient](@ref appengine_v1::AuthorizedCertificatesClient-universe-domain-snippet) +- [\c appengine_v1::AuthorizedDomainsClient](@ref appengine_v1::AuthorizedDomainsClient-universe-domain-snippet) +- [\c appengine_v1::DomainMappingsClient](@ref appengine_v1::DomainMappingsClient-universe-domain-snippet) +- [\c appengine_v1::FirewallClient](@ref appengine_v1::FirewallClient-universe-domain-snippet) +- [\c appengine_v1::InstancesClient](@ref appengine_v1::InstancesClient-universe-domain-snippet) +- [\c appengine_v1::ServicesClient](@ref appengine_v1::ServicesClient-universe-domain-snippet) +- [\c appengine_v1::VersionsClient](@ref appengine_v1::VersionsClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page appengine_v1::ApplicationsClient-universe-domain-snippet Override appengine_v1::ApplicationsClient Universe Domain + +@snippet google/cloud/appengine/v1/samples/applications_client_samples.cc set-client-universe-domain + +*/ + +/*! @page appengine_v1::AuthorizedCertificatesClient-universe-domain-snippet Override appengine_v1::AuthorizedCertificatesClient Universe Domain + +@snippet google/cloud/appengine/v1/samples/authorized_certificates_client_samples.cc set-client-universe-domain + +*/ + +/*! @page appengine_v1::AuthorizedDomainsClient-universe-domain-snippet Override appengine_v1::AuthorizedDomainsClient Universe Domain + +@snippet google/cloud/appengine/v1/samples/authorized_domains_client_samples.cc set-client-universe-domain + +*/ + +/*! @page appengine_v1::DomainMappingsClient-universe-domain-snippet Override appengine_v1::DomainMappingsClient Universe Domain + +@snippet google/cloud/appengine/v1/samples/domain_mappings_client_samples.cc set-client-universe-domain + +*/ + +/*! @page appengine_v1::FirewallClient-universe-domain-snippet Override appengine_v1::FirewallClient Universe Domain + +@snippet google/cloud/appengine/v1/samples/firewall_client_samples.cc set-client-universe-domain + +*/ + +/*! @page appengine_v1::InstancesClient-universe-domain-snippet Override appengine_v1::InstancesClient Universe Domain + +@snippet google/cloud/appengine/v1/samples/instances_client_samples.cc set-client-universe-domain + +*/ + +/*! @page appengine_v1::ServicesClient-universe-domain-snippet Override appengine_v1::ServicesClient Universe Domain + +@snippet google/cloud/appengine/v1/samples/services_client_samples.cc set-client-universe-domain + +*/ + +/*! @page appengine_v1::VersionsClient-universe-domain-snippet Override appengine_v1::VersionsClient Universe Domain + +@snippet google/cloud/appengine/v1/samples/versions_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/appengine/v1/samples/applications_client_samples.cc b/google/cloud/appengine/v1/samples/applications_client_samples.cc index ba1f56887a0d3..1369c2883d2d8 100644 --- a/google/cloud/appengine/v1/samples/applications_client_samples.cc +++ b/google/cloud/appengine/v1/samples/applications_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::appengine_v1::ApplicationsClient( + google::cloud::appengine_v1::MakeApplicationsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::appengine_v1:: ApplicationsConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/appengine/v1/samples/authorized_certificates_client_samples.cc b/google/cloud/appengine/v1/samples/authorized_certificates_client_samples.cc index 27c58b93afbc8..e5ba73e3c36cc 100644 --- a/google/cloud/appengine/v1/samples/authorized_certificates_client_samples.cc +++ b/google/cloud/appengine/v1/samples/authorized_certificates_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::appengine_v1::AuthorizedCertificatesClient( + google::cloud::appengine_v1::MakeAuthorizedCertificatesConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::appengine_v1:: @@ -150,6 +171,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -159,6 +183,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/appengine/v1/samples/authorized_domains_client_samples.cc b/google/cloud/appengine/v1/samples/authorized_domains_client_samples.cc index 00dce3a23c235..91aa24eee14d7 100644 --- a/google/cloud/appengine/v1/samples/authorized_domains_client_samples.cc +++ b/google/cloud/appengine/v1/samples/authorized_domains_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::appengine_v1::AuthorizedDomainsClient( + google::cloud::appengine_v1::MakeAuthorizedDomainsConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::appengine_v1:: @@ -144,6 +165,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -153,6 +177,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/appengine/v1/samples/domain_mappings_client_samples.cc b/google/cloud/appengine/v1/samples/domain_mappings_client_samples.cc index 2f40edaddc2b2..42112c3149f2a 100644 --- a/google/cloud/appengine/v1/samples/domain_mappings_client_samples.cc +++ b/google/cloud/appengine/v1/samples/domain_mappings_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::appengine_v1::DomainMappingsClient( + google::cloud::appengine_v1::MakeDomainMappingsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::appengine_v1:: DomainMappingsConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/appengine/v1/samples/firewall_client_samples.cc b/google/cloud/appengine/v1/samples/firewall_client_samples.cc index 8653776276d27..6b1832e7de383 100644 --- a/google/cloud/appengine/v1/samples/firewall_client_samples.cc +++ b/google/cloud/appengine/v1/samples/firewall_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::appengine_v1::FirewallClient( + google::cloud::appengine_v1::MakeFirewallConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::appengine_v1::FirewallConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/appengine/v1/samples/instances_client_samples.cc b/google/cloud/appengine/v1/samples/instances_client_samples.cc index 8d529dbddebcd..f4297ca465c42 100644 --- a/google/cloud/appengine/v1/samples/instances_client_samples.cc +++ b/google/cloud/appengine/v1/samples/instances_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::appengine_v1::InstancesClient( + google::cloud::appengine_v1::MakeInstancesConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::appengine_v1::InstancesConnectionIdempotencyPolicy { @@ -184,6 +204,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -194,6 +217,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/appengine/v1/samples/services_client_samples.cc b/google/cloud/appengine/v1/samples/services_client_samples.cc index 27e97bc10b603..ec585036ea3ce 100644 --- a/google/cloud/appengine/v1/samples/services_client_samples.cc +++ b/google/cloud/appengine/v1/samples/services_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::appengine_v1::ServicesClient( + google::cloud::appengine_v1::MakeServicesConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::appengine_v1::ServicesConnectionIdempotencyPolicy { @@ -184,6 +204,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -194,6 +217,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/appengine/v1/samples/versions_client_samples.cc b/google/cloud/appengine/v1/samples/versions_client_samples.cc index 197ed7ca7a508..e3d5c423e17fd 100644 --- a/google/cloud/appengine/v1/samples/versions_client_samples.cc +++ b/google/cloud/appengine/v1/samples/versions_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::appengine_v1::VersionsClient( + google::cloud::appengine_v1::MakeVersionsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::appengine_v1::VersionsConnectionIdempotencyPolicy { @@ -184,6 +204,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -194,6 +217,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/apphub/doc/override-universe-domain.dox b/google/cloud/apphub/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..33843f57e7b11 --- /dev/null +++ b/google/cloud/apphub/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page apphub-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `apphub_v1::AppHubClient`: + +@snippet app_hub_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page apphub_v1::AppHubClient-universe-domain-snippet Override apphub_v1::AppHubClient Universe Domain + +@snippet google/cloud/apphub/v1/samples/app_hub_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/apphub/v1/samples/app_hub_client_samples.cc b/google/cloud/apphub/v1/samples/app_hub_client_samples.cc index 431cfd0c0354a..10f813d985c91 100644 --- a/google/cloud/apphub/v1/samples/app_hub_client_samples.cc +++ b/google/cloud/apphub/v1/samples/app_hub_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::apphub_v1::AppHubClient( + google::cloud::apphub_v1::MakeAppHubConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::apphub_v1::AppHubConnectionIdempotencyPolicy { @@ -179,6 +199,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -189,6 +212,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/artifactregistry/doc/override-universe-domain.dox b/google/cloud/artifactregistry/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..a2d3c5e7f846a --- /dev/null +++ b/google/cloud/artifactregistry/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page artifactregistry-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `artifactregistry_v1::ArtifactRegistryClient`: + +@snippet artifact_registry_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page artifactregistry_v1::ArtifactRegistryClient-universe-domain-snippet Override artifactregistry_v1::ArtifactRegistryClient Universe Domain + +@snippet google/cloud/artifactregistry/v1/samples/artifact_registry_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/artifactregistry/v1/samples/artifact_registry_client_samples.cc b/google/cloud/artifactregistry/v1/samples/artifact_registry_client_samples.cc index 587a1bc0e9d1c..d9ea6a798973d 100644 --- a/google/cloud/artifactregistry/v1/samples/artifact_registry_client_samples.cc +++ b/google/cloud/artifactregistry/v1/samples/artifact_registry_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::artifactregistry_v1::ArtifactRegistryClient( + google::cloud::artifactregistry_v1::MakeArtifactRegistryConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::artifactregistry_v1:: @@ -199,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -209,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/asset/doc/override-universe-domain.dox b/google/cloud/asset/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..8a2604d565ef9 --- /dev/null +++ b/google/cloud/asset/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page asset-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `asset_v1::AssetServiceClient`: + +@snippet asset_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page asset_v1::AssetServiceClient-universe-domain-snippet Override asset_v1::AssetServiceClient Universe Domain + +@snippet google/cloud/asset/v1/samples/asset_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/asset/v1/samples/asset_client_samples.cc b/google/cloud/asset/v1/samples/asset_client_samples.cc index ba8de4e3e6cf4..ac14a7f822a5d 100644 --- a/google/cloud/asset/v1/samples/asset_client_samples.cc +++ b/google/cloud/asset/v1/samples/asset_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::asset_v1::AssetServiceClient( + google::cloud::asset_v1::MakeAssetServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::asset_v1::AssetServiceConnectionIdempotencyPolicy { @@ -184,6 +204,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -194,6 +217,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/assuredworkloads/doc/override-universe-domain.dox b/google/cloud/assuredworkloads/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..1e96a3475d7e7 --- /dev/null +++ b/google/cloud/assuredworkloads/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page assuredworkloads-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `assuredworkloads_v1::AssuredWorkloadsServiceClient`: + +@snippet assured_workloads_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page assuredworkloads_v1::AssuredWorkloadsServiceClient-universe-domain-snippet Override assuredworkloads_v1::AssuredWorkloadsServiceClient Universe Domain + +@snippet google/cloud/assuredworkloads/v1/samples/assured_workloads_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/assuredworkloads/v1/samples/assured_workloads_client_samples.cc b/google/cloud/assuredworkloads/v1/samples/assured_workloads_client_samples.cc index a62935f5febd3..28d92c742fea4 100644 --- a/google/cloud/assuredworkloads/v1/samples/assured_workloads_client_samples.cc +++ b/google/cloud/assuredworkloads/v1/samples/assured_workloads_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::assuredworkloads_v1::AssuredWorkloadsServiceClient( + google::cloud::assuredworkloads_v1:: + MakeAssuredWorkloadsServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::assuredworkloads_v1:: @@ -200,6 +222,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -210,6 +235,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/automl/doc/override-universe-domain.dox b/google/cloud/automl/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..5562319d5b60b --- /dev/null +++ b/google/cloud/automl/doc/override-universe-domain.dox @@ -0,0 +1,36 @@ +/*! +@page automl-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `automl_v1::AutoMlClient`: + +@snippet auto_ml_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c automl_v1::AutoMlClient](@ref automl_v1::AutoMlClient-universe-domain-snippet) +- [\c automl_v1::PredictionServiceClient](@ref automl_v1::PredictionServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page automl_v1::AutoMlClient-universe-domain-snippet Override automl_v1::AutoMlClient Universe Domain + +@snippet google/cloud/automl/v1/samples/auto_ml_client_samples.cc set-client-universe-domain + +*/ + +/*! @page automl_v1::PredictionServiceClient-universe-domain-snippet Override automl_v1::PredictionServiceClient Universe Domain + +@snippet google/cloud/automl/v1/samples/prediction_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/automl/v1/samples/auto_ml_client_samples.cc b/google/cloud/automl/v1/samples/auto_ml_client_samples.cc index bc54df1ff3365..1e9d3169f486b 100644 --- a/google/cloud/automl/v1/samples/auto_ml_client_samples.cc +++ b/google/cloud/automl/v1/samples/auto_ml_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::automl_v1::AutoMlClient( + google::cloud::automl_v1::MakeAutoMlConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::automl_v1::AutoMlConnectionIdempotencyPolicy { @@ -179,6 +199,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -189,6 +212,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/automl/v1/samples/prediction_client_samples.cc b/google/cloud/automl/v1/samples/prediction_client_samples.cc index a71de2c60d36d..deedb04111743 100644 --- a/google/cloud/automl/v1/samples/prediction_client_samples.cc +++ b/google/cloud/automl/v1/samples/prediction_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::automl_v1::PredictionServiceClient( + google::cloud::automl_v1::MakePredictionServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::automl_v1:: @@ -187,6 +207,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -197,6 +220,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/backupdr/doc/override-universe-domain.dox b/google/cloud/backupdr/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..e4ad5c2d6e463 --- /dev/null +++ b/google/cloud/backupdr/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page backupdr-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `backupdr_v1::BackupDRClient`: + +@snippet backup_dr_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page backupdr_v1::BackupDRClient-universe-domain-snippet Override backupdr_v1::BackupDRClient Universe Domain + +@snippet google/cloud/backupdr/v1/samples/backup_dr_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/backupdr/v1/samples/backup_dr_client_samples.cc b/google/cloud/backupdr/v1/samples/backup_dr_client_samples.cc index 64b790198d64a..73e07ca1ec78b 100644 --- a/google/cloud/backupdr/v1/samples/backup_dr_client_samples.cc +++ b/google/cloud/backupdr/v1/samples/backup_dr_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::backupdr_v1::BackupDRClient( + google::cloud::backupdr_v1::MakeBackupDRConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::backupdr_v1::BackupDRConnectionIdempotencyPolicy { @@ -182,6 +202,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -192,6 +215,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/baremetalsolution/doc/override-universe-domain.dox b/google/cloud/baremetalsolution/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..b79459949fea7 --- /dev/null +++ b/google/cloud/baremetalsolution/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page baremetalsolution-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `baremetalsolution_v2::BareMetalSolutionClient`: + +@snippet bare_metal_solution_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page baremetalsolution_v2::BareMetalSolutionClient-universe-domain-snippet Override baremetalsolution_v2::BareMetalSolutionClient Universe Domain + +@snippet google/cloud/baremetalsolution/v2/samples/bare_metal_solution_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/baremetalsolution/v2/samples/bare_metal_solution_client_samples.cc b/google/cloud/baremetalsolution/v2/samples/bare_metal_solution_client_samples.cc index e56af9dcbcd0b..c89b916384021 100644 --- a/google/cloud/baremetalsolution/v2/samples/bare_metal_solution_client_samples.cc +++ b/google/cloud/baremetalsolution/v2/samples/bare_metal_solution_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::baremetalsolution_v2::BareMetalSolutionClient( + google::cloud::baremetalsolution_v2::MakeBareMetalSolutionConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::baremetalsolution_v2:: @@ -200,6 +221,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -210,6 +234,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/batch/doc/override-universe-domain.dox b/google/cloud/batch/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..2cafdc124711b --- /dev/null +++ b/google/cloud/batch/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page batch-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `batch_v1::BatchServiceClient`: + +@snippet batch_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page batch_v1::BatchServiceClient-universe-domain-snippet Override batch_v1::BatchServiceClient Universe Domain + +@snippet google/cloud/batch/v1/samples/batch_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/batch/v1/samples/batch_client_samples.cc b/google/cloud/batch/v1/samples/batch_client_samples.cc index 5b20e4856eda4..500bcdc94bf5b 100644 --- a/google/cloud/batch/v1/samples/batch_client_samples.cc +++ b/google/cloud/batch/v1/samples/batch_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::batch_v1::BatchServiceClient( + google::cloud::batch_v1::MakeBatchServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::batch_v1::BatchServiceConnectionIdempotencyPolicy { @@ -184,6 +204,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -194,6 +217,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/beyondcorp/appconnections/v1/samples/app_connections_client_samples.cc b/google/cloud/beyondcorp/appconnections/v1/samples/app_connections_client_samples.cc index df0ab124961c9..b8a335523ed14 100644 --- a/google/cloud/beyondcorp/appconnections/v1/samples/app_connections_client_samples.cc +++ b/google/cloud/beyondcorp/appconnections/v1/samples/app_connections_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::beyondcorp_appconnections_v1::AppConnectionsServiceClient( + google::cloud::beyondcorp_appconnections_v1:: + MakeAppConnectionsServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::beyondcorp_appconnections_v1:: @@ -205,6 +227,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -215,6 +240,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/beyondcorp/appconnectors/v1/samples/app_connectors_client_samples.cc b/google/cloud/beyondcorp/appconnectors/v1/samples/app_connectors_client_samples.cc index 56571b3052eb3..f63a96a1e521e 100644 --- a/google/cloud/beyondcorp/appconnectors/v1/samples/app_connectors_client_samples.cc +++ b/google/cloud/beyondcorp/appconnectors/v1/samples/app_connectors_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::beyondcorp_appconnectors_v1::AppConnectorsServiceClient( + google::cloud::beyondcorp_appconnectors_v1:: + MakeAppConnectorsServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::beyondcorp_appconnectors_v1:: @@ -204,6 +226,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -214,6 +239,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/beyondcorp/appgateways/v1/samples/app_gateways_client_samples.cc b/google/cloud/beyondcorp/appgateways/v1/samples/app_gateways_client_samples.cc index e4caa1aded60c..d377d6e028a15 100644 --- a/google/cloud/beyondcorp/appgateways/v1/samples/app_gateways_client_samples.cc +++ b/google/cloud/beyondcorp/appgateways/v1/samples/app_gateways_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::beyondcorp_appgateways_v1::AppGatewaysServiceClient( + google::cloud::beyondcorp_appgateways_v1:: + MakeAppGatewaysServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::beyondcorp_appgateways_v1:: @@ -198,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -208,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/beyondcorp/doc/override-universe-domain.dox b/google/cloud/beyondcorp/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..12a10acdb0968 --- /dev/null +++ b/google/cloud/beyondcorp/doc/override-universe-domain.dox @@ -0,0 +1,43 @@ +/*! +@page beyondcorp-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `beyondcorp_appconnections_v1::AppConnectionsServiceClient`: + +@snippet app_connections_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c beyondcorp_appconnections_v1::AppConnectionsServiceClient](@ref beyondcorp_appconnections_v1::AppConnectionsServiceClient-universe-domain-snippet) +- [\c beyondcorp_appconnectors_v1::AppConnectorsServiceClient](@ref beyondcorp_appconnectors_v1::AppConnectorsServiceClient-universe-domain-snippet) +- [\c beyondcorp_appgateways_v1::AppGatewaysServiceClient](@ref beyondcorp_appgateways_v1::AppGatewaysServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page beyondcorp_appconnections_v1::AppConnectionsServiceClient-universe-domain-snippet Override beyondcorp_appconnections_v1::AppConnectionsServiceClient Universe Domain + +@snippet google/cloud/beyondcorp/appconnections/v1/samples/app_connections_client_samples.cc set-client-universe-domain + +*/ + +/*! @page beyondcorp_appconnectors_v1::AppConnectorsServiceClient-universe-domain-snippet Override beyondcorp_appconnectors_v1::AppConnectorsServiceClient Universe Domain + +@snippet google/cloud/beyondcorp/appconnectors/v1/samples/app_connectors_client_samples.cc set-client-universe-domain + +*/ + +/*! @page beyondcorp_appgateways_v1::AppGatewaysServiceClient-universe-domain-snippet Override beyondcorp_appgateways_v1::AppGatewaysServiceClient Universe Domain + +@snippet google/cloud/beyondcorp/appgateways/v1/samples/app_gateways_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/bigquery/analyticshub/v1/samples/analytics_hub_client_samples.cc b/google/cloud/bigquery/analyticshub/v1/samples/analytics_hub_client_samples.cc index 1ec5db246c3f8..48d0b04731992 100644 --- a/google/cloud/bigquery/analyticshub/v1/samples/analytics_hub_client_samples.cc +++ b/google/cloud/bigquery/analyticshub/v1/samples/analytics_hub_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::bigquery_analyticshub_v1::AnalyticsHubServiceClient( + google::cloud::bigquery_analyticshub_v1:: + MakeAnalyticsHubServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::bigquery_analyticshub_v1:: @@ -198,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -208,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/bigquery/biglake/v1/samples/metastore_client_samples.cc b/google/cloud/bigquery/biglake/v1/samples/metastore_client_samples.cc index 0026988e81df0..4c7e98e208eb9 100644 --- a/google/cloud/bigquery/biglake/v1/samples/metastore_client_samples.cc +++ b/google/cloud/bigquery/biglake/v1/samples/metastore_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::bigquery_biglake_v1::MetastoreServiceClient( + google::cloud::bigquery_biglake_v1::MakeMetastoreServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::bigquery_biglake_v1:: @@ -150,6 +171,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -159,6 +183,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/bigquery/connection/v1/samples/connection_client_samples.cc b/google/cloud/bigquery/connection/v1/samples/connection_client_samples.cc index 07480e45f962a..46bc89dc9d273 100644 --- a/google/cloud/bigquery/connection/v1/samples/connection_client_samples.cc +++ b/google/cloud/bigquery/connection/v1/samples/connection_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::bigquery_connection_v1::ConnectionServiceClient( + google::cloud::bigquery_connection_v1:: + MakeConnectionServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::bigquery_connection_v1:: @@ -151,6 +173,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -160,6 +185,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/bigquery/datapolicies/v1/samples/data_policy_client_samples.cc b/google/cloud/bigquery/datapolicies/v1/samples/data_policy_client_samples.cc index 579ed1b03f85b..86f2ae4a28346 100644 --- a/google/cloud/bigquery/datapolicies/v1/samples/data_policy_client_samples.cc +++ b/google/cloud/bigquery/datapolicies/v1/samples/data_policy_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::bigquery_datapolicies_v1::DataPolicyServiceClient( + google::cloud::bigquery_datapolicies_v1:: + MakeDataPolicyServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::bigquery_datapolicies_v1:: @@ -151,6 +173,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -160,6 +185,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/bigquery/datapolicies/v2/samples/data_policy_client_samples.cc b/google/cloud/bigquery/datapolicies/v2/samples/data_policy_client_samples.cc index f46e4e52654d8..483e64ed1e60e 100644 --- a/google/cloud/bigquery/datapolicies/v2/samples/data_policy_client_samples.cc +++ b/google/cloud/bigquery/datapolicies/v2/samples/data_policy_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::bigquery_datapolicies_v2::DataPolicyServiceClient( + google::cloud::bigquery_datapolicies_v2:: + MakeDataPolicyServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::bigquery_datapolicies_v2:: @@ -151,6 +173,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -160,6 +185,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/bigquery/datatransfer/v1/samples/data_transfer_client_samples.cc b/google/cloud/bigquery/datatransfer/v1/samples/data_transfer_client_samples.cc index 2c4f0804c270d..5062227032435 100644 --- a/google/cloud/bigquery/datatransfer/v1/samples/data_transfer_client_samples.cc +++ b/google/cloud/bigquery/datatransfer/v1/samples/data_transfer_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::bigquery_datatransfer_v1::DataTransferServiceClient( + google::cloud::bigquery_datatransfer_v1:: + MakeDataTransferServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::bigquery_datatransfer_v1:: @@ -150,6 +172,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -159,6 +184,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/bigquery/doc/override-universe-domain.dox b/google/cloud/bigquery/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..5c524448b7cb0 --- /dev/null +++ b/google/cloud/bigquery/doc/override-universe-domain.dox @@ -0,0 +1,92 @@ +/*! +@page bigquery-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `bigquery_analyticshub_v1::AnalyticsHubServiceClient`: + +@snippet analytics_hub_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c bigquery_analyticshub_v1::AnalyticsHubServiceClient](@ref bigquery_analyticshub_v1::AnalyticsHubServiceClient-universe-domain-snippet) +- [\c bigquery_biglake_v1::MetastoreServiceClient](@ref bigquery_biglake_v1::MetastoreServiceClient-universe-domain-snippet) +- [\c bigquery_connection_v1::ConnectionServiceClient](@ref bigquery_connection_v1::ConnectionServiceClient-universe-domain-snippet) +- [\c bigquery_datapolicies_v1::DataPolicyServiceClient](@ref bigquery_datapolicies_v1::DataPolicyServiceClient-universe-domain-snippet) +- [\c bigquery_datapolicies_v2::DataPolicyServiceClient](@ref bigquery_datapolicies_v2::DataPolicyServiceClient-universe-domain-snippet) +- [\c bigquery_datatransfer_v1::DataTransferServiceClient](@ref bigquery_datatransfer_v1::DataTransferServiceClient-universe-domain-snippet) +- [\c bigquery_migration_v2::MigrationServiceClient](@ref bigquery_migration_v2::MigrationServiceClient-universe-domain-snippet) +- [\c bigquery_reservation_v1::ReservationServiceClient](@ref bigquery_reservation_v1::ReservationServiceClient-universe-domain-snippet) +- [\c bigquery_storage_v1::BigQueryReadClient](@ref bigquery_storage_v1::BigQueryReadClient-universe-domain-snippet) +- [\c bigquery_storage_v1::BigQueryWriteClient](@ref bigquery_storage_v1::BigQueryWriteClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page bigquery_analyticshub_v1::AnalyticsHubServiceClient-universe-domain-snippet Override bigquery_analyticshub_v1::AnalyticsHubServiceClient Universe Domain + +@snippet google/cloud/bigquery/analyticshub/v1/samples/analytics_hub_client_samples.cc set-client-universe-domain + +*/ + +/*! @page bigquery_biglake_v1::MetastoreServiceClient-universe-domain-snippet Override bigquery_biglake_v1::MetastoreServiceClient Universe Domain + +@snippet google/cloud/bigquery/biglake/v1/samples/metastore_client_samples.cc set-client-universe-domain + +*/ + +/*! @page bigquery_connection_v1::ConnectionServiceClient-universe-domain-snippet Override bigquery_connection_v1::ConnectionServiceClient Universe Domain + +@snippet google/cloud/bigquery/connection/v1/samples/connection_client_samples.cc set-client-universe-domain + +*/ + +/*! @page bigquery_datapolicies_v1::DataPolicyServiceClient-universe-domain-snippet Override bigquery_datapolicies_v1::DataPolicyServiceClient Universe Domain + +@snippet google/cloud/bigquery/datapolicies/v1/samples/data_policy_client_samples.cc set-client-universe-domain + +*/ + +/*! @page bigquery_datapolicies_v2::DataPolicyServiceClient-universe-domain-snippet Override bigquery_datapolicies_v2::DataPolicyServiceClient Universe Domain + +@snippet google/cloud/bigquery/datapolicies/v2/samples/data_policy_client_samples.cc set-client-universe-domain + +*/ + +/*! @page bigquery_datatransfer_v1::DataTransferServiceClient-universe-domain-snippet Override bigquery_datatransfer_v1::DataTransferServiceClient Universe Domain + +@snippet google/cloud/bigquery/datatransfer/v1/samples/data_transfer_client_samples.cc set-client-universe-domain + +*/ + +/*! @page bigquery_migration_v2::MigrationServiceClient-universe-domain-snippet Override bigquery_migration_v2::MigrationServiceClient Universe Domain + +@snippet google/cloud/bigquery/migration/v2/samples/migration_client_samples.cc set-client-universe-domain + +*/ + +/*! @page bigquery_reservation_v1::ReservationServiceClient-universe-domain-snippet Override bigquery_reservation_v1::ReservationServiceClient Universe Domain + +@snippet google/cloud/bigquery/reservation/v1/samples/reservation_client_samples.cc set-client-universe-domain + +*/ + +/*! @page bigquery_storage_v1::BigQueryReadClient-universe-domain-snippet Override bigquery_storage_v1::BigQueryReadClient Universe Domain + +@snippet google/cloud/bigquery/storage/v1/samples/bigquery_read_client_samples.cc set-client-universe-domain + +*/ + +/*! @page bigquery_storage_v1::BigQueryWriteClient-universe-domain-snippet Override bigquery_storage_v1::BigQueryWriteClient Universe Domain + +@snippet google/cloud/bigquery/storage/v1/samples/bigquery_write_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/bigquery/migration/v2/samples/migration_client_samples.cc b/google/cloud/bigquery/migration/v2/samples/migration_client_samples.cc index 1239cf4bfac5d..5218bd71858c5 100644 --- a/google/cloud/bigquery/migration/v2/samples/migration_client_samples.cc +++ b/google/cloud/bigquery/migration/v2/samples/migration_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::bigquery_migration_v2::MigrationServiceClient( + google::cloud::bigquery_migration_v2::MakeMigrationServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::bigquery_migration_v2:: @@ -151,6 +172,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -160,6 +184,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/bigquery/reservation/v1/samples/reservation_client_samples.cc b/google/cloud/bigquery/reservation/v1/samples/reservation_client_samples.cc index 2e02dc1cb2412..d917d943fb117 100644 --- a/google/cloud/bigquery/reservation/v1/samples/reservation_client_samples.cc +++ b/google/cloud/bigquery/reservation/v1/samples/reservation_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::bigquery_reservation_v1::ReservationServiceClient( + google::cloud::bigquery_reservation_v1:: + MakeReservationServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::bigquery_reservation_v1:: @@ -151,6 +173,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -160,6 +185,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/bigquery/storage/v1/samples/bigquery_read_client_samples.cc b/google/cloud/bigquery/storage/v1/samples/bigquery_read_client_samples.cc index 49265b9f0dadb..3ad492cf3a025 100644 --- a/google/cloud/bigquery/storage/v1/samples/bigquery_read_client_samples.cc +++ b/google/cloud/bigquery/storage/v1/samples/bigquery_read_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::bigquery_storage_v1::BigQueryReadClient( + google::cloud::bigquery_storage_v1::MakeBigQueryReadConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::bigquery_storage_v1:: BigQueryReadConnectionIdempotencyPolicy { @@ -144,6 +165,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -153,6 +177,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/bigquery/storage/v1/samples/bigquery_write_client_samples.cc b/google/cloud/bigquery/storage/v1/samples/bigquery_write_client_samples.cc index 1ca05572e47ed..1b94cd714e751 100644 --- a/google/cloud/bigquery/storage/v1/samples/bigquery_write_client_samples.cc +++ b/google/cloud/bigquery/storage/v1/samples/bigquery_write_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::bigquery_storage_v1::BigQueryWriteClient( + google::cloud::bigquery_storage_v1::MakeBigQueryWriteConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::bigquery_storage_v1:: BigQueryWriteConnectionIdempotencyPolicy { @@ -144,6 +165,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -153,6 +177,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/bigquerycontrol/doc/override-universe-domain.dox b/google/cloud/bigquerycontrol/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..f9e919a2607ea --- /dev/null +++ b/google/cloud/bigquerycontrol/doc/override-universe-domain.dox @@ -0,0 +1,71 @@ +/*! +@page bigquerycontrol-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `bigquerycontrol_v2::DatasetServiceClient`: + +@snippet dataset_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c bigquerycontrol_v2::DatasetServiceClient](@ref bigquerycontrol_v2::DatasetServiceClient-universe-domain-snippet) +- [\c bigquerycontrol_v2::JobServiceClient](@ref bigquerycontrol_v2::JobServiceClient-universe-domain-snippet) +- [\c bigquerycontrol_v2::ModelServiceClient](@ref bigquerycontrol_v2::ModelServiceClient-universe-domain-snippet) +- [\c bigquerycontrol_v2::ProjectServiceClient](@ref bigquerycontrol_v2::ProjectServiceClient-universe-domain-snippet) +- [\c bigquerycontrol_v2::RoutineServiceClient](@ref bigquerycontrol_v2::RoutineServiceClient-universe-domain-snippet) +- [\c bigquerycontrol_v2::RowAccessPolicyServiceClient](@ref bigquerycontrol_v2::RowAccessPolicyServiceClient-universe-domain-snippet) +- [\c bigquerycontrol_v2::TableServiceClient](@ref bigquerycontrol_v2::TableServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page bigquerycontrol_v2::DatasetServiceClient-universe-domain-snippet Override bigquerycontrol_v2::DatasetServiceClient Universe Domain + +@snippet google/cloud/bigquerycontrol/v2/samples/dataset_client_samples.cc set-client-universe-domain + +*/ + +/*! @page bigquerycontrol_v2::JobServiceClient-universe-domain-snippet Override bigquerycontrol_v2::JobServiceClient Universe Domain + +@snippet google/cloud/bigquerycontrol/v2/samples/job_client_samples.cc set-client-universe-domain + +*/ + +/*! @page bigquerycontrol_v2::ModelServiceClient-universe-domain-snippet Override bigquerycontrol_v2::ModelServiceClient Universe Domain + +@snippet google/cloud/bigquerycontrol/v2/samples/model_client_samples.cc set-client-universe-domain + +*/ + +/*! @page bigquerycontrol_v2::ProjectServiceClient-universe-domain-snippet Override bigquerycontrol_v2::ProjectServiceClient Universe Domain + +@snippet google/cloud/bigquerycontrol/v2/samples/project_client_samples.cc set-client-universe-domain + +*/ + +/*! @page bigquerycontrol_v2::RoutineServiceClient-universe-domain-snippet Override bigquerycontrol_v2::RoutineServiceClient Universe Domain + +@snippet google/cloud/bigquerycontrol/v2/samples/routine_client_samples.cc set-client-universe-domain + +*/ + +/*! @page bigquerycontrol_v2::RowAccessPolicyServiceClient-universe-domain-snippet Override bigquerycontrol_v2::RowAccessPolicyServiceClient Universe Domain + +@snippet google/cloud/bigquerycontrol/v2/samples/row_access_policy_client_samples.cc set-client-universe-domain + +*/ + +/*! @page bigquerycontrol_v2::TableServiceClient-universe-domain-snippet Override bigquerycontrol_v2::TableServiceClient Universe Domain + +@snippet google/cloud/bigquerycontrol/v2/samples/table_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/bigquerycontrol/v2/samples/dataset_client_samples.cc b/google/cloud/bigquerycontrol/v2/samples/dataset_client_samples.cc index 2afaadbf6bc73..e9dbcb7b77ffb 100644 --- a/google/cloud/bigquerycontrol/v2/samples/dataset_client_samples.cc +++ b/google/cloud/bigquerycontrol/v2/samples/dataset_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::bigquerycontrol_v2::DatasetServiceClient( + google::cloud::bigquerycontrol_v2::MakeDatasetServiceConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::bigquerycontrol_v2:: DatasetServiceConnectionIdempotencyPolicy { @@ -146,6 +167,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -155,6 +179,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/bigquerycontrol/v2/samples/job_client_samples.cc b/google/cloud/bigquerycontrol/v2/samples/job_client_samples.cc index 2efac1248f7fc..d31bf5cb94d81 100644 --- a/google/cloud/bigquerycontrol/v2/samples/job_client_samples.cc +++ b/google/cloud/bigquerycontrol/v2/samples/job_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::bigquerycontrol_v2::JobServiceClient( + google::cloud::bigquerycontrol_v2::MakeJobServiceConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::bigquerycontrol_v2:: JobServiceConnectionIdempotencyPolicy { @@ -143,6 +164,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -152,6 +176,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/bigquerycontrol/v2/samples/model_client_samples.cc b/google/cloud/bigquerycontrol/v2/samples/model_client_samples.cc index b3ad539cfbf6e..b834efb2d32f9 100644 --- a/google/cloud/bigquerycontrol/v2/samples/model_client_samples.cc +++ b/google/cloud/bigquerycontrol/v2/samples/model_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::bigquerycontrol_v2::ModelServiceClient( + google::cloud::bigquerycontrol_v2::MakeModelServiceConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::bigquerycontrol_v2:: ModelServiceConnectionIdempotencyPolicy { @@ -147,6 +168,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -156,6 +180,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/bigquerycontrol/v2/samples/project_client_samples.cc b/google/cloud/bigquerycontrol/v2/samples/project_client_samples.cc index 540bae577c658..cb3cc4adcf32b 100644 --- a/google/cloud/bigquerycontrol/v2/samples/project_client_samples.cc +++ b/google/cloud/bigquerycontrol/v2/samples/project_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::bigquerycontrol_v2::ProjectServiceClient( + google::cloud::bigquerycontrol_v2::MakeProjectServiceConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::bigquerycontrol_v2:: ProjectServiceConnectionIdempotencyPolicy { @@ -146,6 +167,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -155,6 +179,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/bigquerycontrol/v2/samples/routine_client_samples.cc b/google/cloud/bigquerycontrol/v2/samples/routine_client_samples.cc index f67759fd979ce..779f92205b463 100644 --- a/google/cloud/bigquerycontrol/v2/samples/routine_client_samples.cc +++ b/google/cloud/bigquerycontrol/v2/samples/routine_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::bigquerycontrol_v2::RoutineServiceClient( + google::cloud::bigquerycontrol_v2::MakeRoutineServiceConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::bigquerycontrol_v2:: RoutineServiceConnectionIdempotencyPolicy { @@ -146,6 +167,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -155,6 +179,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/bigquerycontrol/v2/samples/row_access_policy_client_samples.cc b/google/cloud/bigquerycontrol/v2/samples/row_access_policy_client_samples.cc index 8a1f4ab3192f3..4bb2d94d77216 100644 --- a/google/cloud/bigquerycontrol/v2/samples/row_access_policy_client_samples.cc +++ b/google/cloud/bigquerycontrol/v2/samples/row_access_policy_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::bigquerycontrol_v2::RowAccessPolicyServiceClient( + google::cloud::bigquerycontrol_v2:: + MakeRowAccessPolicyServiceConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::bigquerycontrol_v2:: @@ -150,6 +172,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -159,6 +184,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/bigquerycontrol/v2/samples/table_client_samples.cc b/google/cloud/bigquerycontrol/v2/samples/table_client_samples.cc index 6b0b6990daef3..5c3890079c6f6 100644 --- a/google/cloud/bigquerycontrol/v2/samples/table_client_samples.cc +++ b/google/cloud/bigquerycontrol/v2/samples/table_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::bigquerycontrol_v2::TableServiceClient( + google::cloud::bigquerycontrol_v2::MakeTableServiceConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::bigquerycontrol_v2:: TableServiceConnectionIdempotencyPolicy { @@ -147,6 +168,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -156,6 +180,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/bigtable/admin/samples/BUILD.bazel b/google/cloud/bigtable/admin/samples/BUILD.bazel index 5e0e0df93a14e..f6728d8193880 100644 --- a/google/cloud/bigtable/admin/samples/BUILD.bazel +++ b/google/cloud/bigtable/admin/samples/BUILD.bazel @@ -22,6 +22,7 @@ licenses(["notice"]) # Apache 2.0 tags = ["integration-test"], deps = [ "//:bigtable", + "//:universe_domain", "//google/cloud/testing_util:google_cloud_cpp_testing_private", ], ) for sample in glob(["*.cc"])] diff --git a/google/cloud/bigtable/admin/samples/bigtable_instance_admin_client_samples.cc b/google/cloud/bigtable/admin/samples/bigtable_instance_admin_client_samples.cc index f77b68acfca05..9a8419185b91f 100644 --- a/google/cloud/bigtable/admin/samples/bigtable_instance_admin_client_samples.cc +++ b/google/cloud/bigtable/admin/samples/bigtable_instance_admin_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::bigtable_admin::BigtableInstanceAdminClient( + google::cloud::bigtable_admin::MakeBigtableInstanceAdminConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::bigtable_admin:: @@ -199,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -209,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/bigtable/admin/samples/bigtable_table_admin_client_samples.cc b/google/cloud/bigtable/admin/samples/bigtable_table_admin_client_samples.cc index 6fa1c8d4f78d7..77fcbf9066be3 100644 --- a/google/cloud/bigtable/admin/samples/bigtable_table_admin_client_samples.cc +++ b/google/cloud/bigtable/admin/samples/bigtable_table_admin_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::bigtable_admin::BigtableTableAdminClient( + google::cloud::bigtable_admin::MakeBigtableTableAdminConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::bigtable_admin:: @@ -192,6 +213,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -202,6 +226,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/billing/budgets/v1/samples/budget_client_samples.cc b/google/cloud/billing/budgets/v1/samples/budget_client_samples.cc index 474a0f6122c96..3d7edd899df4a 100644 --- a/google/cloud/billing/budgets/v1/samples/budget_client_samples.cc +++ b/google/cloud/billing/budgets/v1/samples/budget_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::billing_budgets_v1::BudgetServiceClient( + google::cloud::billing_budgets_v1::MakeBudgetServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::billing_budgets_v1:: BudgetServiceConnectionIdempotencyPolicy { @@ -144,6 +165,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -153,6 +177,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/billing/doc/override-universe-domain.dox b/google/cloud/billing/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..6b54700603dcf --- /dev/null +++ b/google/cloud/billing/doc/override-universe-domain.dox @@ -0,0 +1,43 @@ +/*! +@page billing-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `billing_budgets_v1::BudgetServiceClient`: + +@snippet budget_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c billing_budgets_v1::BudgetServiceClient](@ref billing_budgets_v1::BudgetServiceClient-universe-domain-snippet) +- [\c billing_v1::CloudBillingClient](@ref billing_v1::CloudBillingClient-universe-domain-snippet) +- [\c billing_v1::CloudCatalogClient](@ref billing_v1::CloudCatalogClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page billing_budgets_v1::BudgetServiceClient-universe-domain-snippet Override billing_budgets_v1::BudgetServiceClient Universe Domain + +@snippet google/cloud/billing/budgets/v1/samples/budget_client_samples.cc set-client-universe-domain + +*/ + +/*! @page billing_v1::CloudBillingClient-universe-domain-snippet Override billing_v1::CloudBillingClient Universe Domain + +@snippet google/cloud/billing/v1/samples/cloud_billing_client_samples.cc set-client-universe-domain + +*/ + +/*! @page billing_v1::CloudCatalogClient-universe-domain-snippet Override billing_v1::CloudCatalogClient Universe Domain + +@snippet google/cloud/billing/v1/samples/cloud_catalog_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/billing/v1/samples/cloud_billing_client_samples.cc b/google/cloud/billing/v1/samples/cloud_billing_client_samples.cc index 1a3726f7bf255..1d9bca7bb3b53 100644 --- a/google/cloud/billing/v1/samples/cloud_billing_client_samples.cc +++ b/google/cloud/billing/v1/samples/cloud_billing_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::billing_v1::CloudBillingClient( + google::cloud::billing_v1::MakeCloudBillingConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::billing_v1:: CloudBillingConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/billing/v1/samples/cloud_catalog_client_samples.cc b/google/cloud/billing/v1/samples/cloud_catalog_client_samples.cc index d9afa28594259..38bf7cef13945 100644 --- a/google/cloud/billing/v1/samples/cloud_catalog_client_samples.cc +++ b/google/cloud/billing/v1/samples/cloud_catalog_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::billing_v1::CloudCatalogClient( + google::cloud::billing_v1::MakeCloudCatalogConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::billing_v1:: CloudCatalogConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/binaryauthorization/doc/override-universe-domain.dox b/google/cloud/binaryauthorization/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..2cce39f3cb150 --- /dev/null +++ b/google/cloud/binaryauthorization/doc/override-universe-domain.dox @@ -0,0 +1,43 @@ +/*! +@page binaryauthorization-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `binaryauthorization_v1::BinauthzManagementServiceV1Client`: + +@snippet binauthz_management_service_v1_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c binaryauthorization_v1::BinauthzManagementServiceV1Client](@ref binaryauthorization_v1::BinauthzManagementServiceV1Client-universe-domain-snippet) +- [\c binaryauthorization_v1::SystemPolicyV1Client](@ref binaryauthorization_v1::SystemPolicyV1Client-universe-domain-snippet) +- [\c binaryauthorization_v1::ValidationHelperV1Client](@ref binaryauthorization_v1::ValidationHelperV1Client-universe-domain-snippet) + + + +*/ + +// + +/*! @page binaryauthorization_v1::BinauthzManagementServiceV1Client-universe-domain-snippet Override binaryauthorization_v1::BinauthzManagementServiceV1Client Universe Domain + +@snippet google/cloud/binaryauthorization/v1/samples/binauthz_management_service_v1_client_samples.cc set-client-universe-domain + +*/ + +/*! @page binaryauthorization_v1::SystemPolicyV1Client-universe-domain-snippet Override binaryauthorization_v1::SystemPolicyV1Client Universe Domain + +@snippet google/cloud/binaryauthorization/v1/samples/system_policy_v1_client_samples.cc set-client-universe-domain + +*/ + +/*! @page binaryauthorization_v1::ValidationHelperV1Client-universe-domain-snippet Override binaryauthorization_v1::ValidationHelperV1Client Universe Domain + +@snippet google/cloud/binaryauthorization/v1/samples/validation_helper_v1_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/binaryauthorization/v1/samples/binauthz_management_service_v1_client_samples.cc b/google/cloud/binaryauthorization/v1/samples/binauthz_management_service_v1_client_samples.cc index 6e5cdd75a2673..c1c3bca5fc2f7 100644 --- a/google/cloud/binaryauthorization/v1/samples/binauthz_management_service_v1_client_samples.cc +++ b/google/cloud/binaryauthorization/v1/samples/binauthz_management_service_v1_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::binaryauthorization_v1::BinauthzManagementServiceV1Client( + google::cloud::binaryauthorization_v1:: + MakeBinauthzManagementServiceV1Connection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::binaryauthorization_v1:: @@ -156,6 +178,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -165,6 +190,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/binaryauthorization/v1/samples/system_policy_v1_client_samples.cc b/google/cloud/binaryauthorization/v1/samples/system_policy_v1_client_samples.cc index 501d9b3ba74e8..53ec3e4c1c92d 100644 --- a/google/cloud/binaryauthorization/v1/samples/system_policy_v1_client_samples.cc +++ b/google/cloud/binaryauthorization/v1/samples/system_policy_v1_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::binaryauthorization_v1::SystemPolicyV1Client( + google::cloud::binaryauthorization_v1::MakeSystemPolicyV1Connection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::binaryauthorization_v1:: SystemPolicyV1ConnectionIdempotencyPolicy { @@ -148,6 +169,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -157,6 +181,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/binaryauthorization/v1/samples/validation_helper_v1_client_samples.cc b/google/cloud/binaryauthorization/v1/samples/validation_helper_v1_client_samples.cc index aa073b7c65548..8d2806256c90b 100644 --- a/google/cloud/binaryauthorization/v1/samples/validation_helper_v1_client_samples.cc +++ b/google/cloud/binaryauthorization/v1/samples/validation_helper_v1_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::binaryauthorization_v1::ValidationHelperV1Client( + google::cloud::binaryauthorization_v1:: + MakeValidationHelperV1Connection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::binaryauthorization_v1:: @@ -151,6 +173,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -160,6 +185,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/certificatemanager/doc/override-universe-domain.dox b/google/cloud/certificatemanager/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..0c5279f227faa --- /dev/null +++ b/google/cloud/certificatemanager/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page certificatemanager-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `certificatemanager_v1::CertificateManagerClient`: + +@snippet certificate_manager_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page certificatemanager_v1::CertificateManagerClient-universe-domain-snippet Override certificatemanager_v1::CertificateManagerClient Universe Domain + +@snippet google/cloud/certificatemanager/v1/samples/certificate_manager_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/certificatemanager/v1/samples/certificate_manager_client_samples.cc b/google/cloud/certificatemanager/v1/samples/certificate_manager_client_samples.cc index cc5ff6f9b0e0b..54b04c2f22d19 100644 --- a/google/cloud/certificatemanager/v1/samples/certificate_manager_client_samples.cc +++ b/google/cloud/certificatemanager/v1/samples/certificate_manager_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::certificatemanager_v1::CertificateManagerClient( + google::cloud::certificatemanager_v1:: + MakeCertificateManagerConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::certificatemanager_v1:: @@ -200,6 +222,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -210,6 +235,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/channel/doc/override-universe-domain.dox b/google/cloud/channel/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..0b3fba3fd5a2d --- /dev/null +++ b/google/cloud/channel/doc/override-universe-domain.dox @@ -0,0 +1,36 @@ +/*! +@page channel-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `channel_v1::CloudChannelServiceClient`: + +@snippet cloud_channel_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c channel_v1::CloudChannelServiceClient](@ref channel_v1::CloudChannelServiceClient-universe-domain-snippet) +- [\c channel_v1::CloudChannelReportsServiceClient](@ref channel_v1::CloudChannelReportsServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page channel_v1::CloudChannelServiceClient-universe-domain-snippet Override channel_v1::CloudChannelServiceClient Universe Domain + +@snippet google/cloud/channel/v1/samples/cloud_channel_client_samples.cc set-client-universe-domain + +*/ + +/*! @page channel_v1::CloudChannelReportsServiceClient-universe-domain-snippet Override channel_v1::CloudChannelReportsServiceClient Universe Domain + +@snippet google/cloud/channel/v1/samples/cloud_channel_reports_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/channel/v1/samples/cloud_channel_client_samples.cc b/google/cloud/channel/v1/samples/cloud_channel_client_samples.cc index 720cd999902f5..c2986f68489a4 100644 --- a/google/cloud/channel/v1/samples/cloud_channel_client_samples.cc +++ b/google/cloud/channel/v1/samples/cloud_channel_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::channel_v1::CloudChannelServiceClient( + google::cloud::channel_v1::MakeCloudChannelServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::channel_v1:: @@ -190,6 +211,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -200,6 +224,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/channel/v1/samples/cloud_channel_reports_client_samples.cc b/google/cloud/channel/v1/samples/cloud_channel_reports_client_samples.cc index 9e236ca65dc2b..32ff801201d3a 100644 --- a/google/cloud/channel/v1/samples/cloud_channel_reports_client_samples.cc +++ b/google/cloud/channel/v1/samples/cloud_channel_reports_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::channel_v1::CloudChannelReportsServiceClient( + google::cloud::channel_v1::MakeCloudChannelReportsServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::channel_v1:: @@ -199,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -209,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/chronicle/doc/override-universe-domain.dox b/google/cloud/chronicle/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..a12b8b7001258 --- /dev/null +++ b/google/cloud/chronicle/doc/override-universe-domain.dox @@ -0,0 +1,57 @@ +/*! +@page chronicle-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `chronicle_v1::DataAccessControlServiceClient`: + +@snippet data_access_control_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c chronicle_v1::DataAccessControlServiceClient](@ref chronicle_v1::DataAccessControlServiceClient-universe-domain-snippet) +- [\c chronicle_v1::EntityServiceClient](@ref chronicle_v1::EntityServiceClient-universe-domain-snippet) +- [\c chronicle_v1::InstanceServiceClient](@ref chronicle_v1::InstanceServiceClient-universe-domain-snippet) +- [\c chronicle_v1::ReferenceListServiceClient](@ref chronicle_v1::ReferenceListServiceClient-universe-domain-snippet) +- [\c chronicle_v1::RuleServiceClient](@ref chronicle_v1::RuleServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page chronicle_v1::DataAccessControlServiceClient-universe-domain-snippet Override chronicle_v1::DataAccessControlServiceClient Universe Domain + +@snippet google/cloud/chronicle/v1/samples/data_access_control_client_samples.cc set-client-universe-domain + +*/ + +/*! @page chronicle_v1::EntityServiceClient-universe-domain-snippet Override chronicle_v1::EntityServiceClient Universe Domain + +@snippet google/cloud/chronicle/v1/samples/entity_client_samples.cc set-client-universe-domain + +*/ + +/*! @page chronicle_v1::InstanceServiceClient-universe-domain-snippet Override chronicle_v1::InstanceServiceClient Universe Domain + +@snippet google/cloud/chronicle/v1/samples/instance_client_samples.cc set-client-universe-domain + +*/ + +/*! @page chronicle_v1::ReferenceListServiceClient-universe-domain-snippet Override chronicle_v1::ReferenceListServiceClient Universe Domain + +@snippet google/cloud/chronicle/v1/samples/reference_list_client_samples.cc set-client-universe-domain + +*/ + +/*! @page chronicle_v1::RuleServiceClient-universe-domain-snippet Override chronicle_v1::RuleServiceClient Universe Domain + +@snippet google/cloud/chronicle/v1/samples/rule_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/chronicle/v1/samples/data_access_control_client_samples.cc b/google/cloud/chronicle/v1/samples/data_access_control_client_samples.cc index 0accdb0024728..8962aca094e3f 100644 --- a/google/cloud/chronicle/v1/samples/data_access_control_client_samples.cc +++ b/google/cloud/chronicle/v1/samples/data_access_control_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::chronicle_v1::DataAccessControlServiceClient( + google::cloud::chronicle_v1::MakeDataAccessControlServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::chronicle_v1:: @@ -150,6 +171,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -159,6 +183,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/chronicle/v1/samples/entity_client_samples.cc b/google/cloud/chronicle/v1/samples/entity_client_samples.cc index b9c7e75bae6e0..06261e46c8702 100644 --- a/google/cloud/chronicle/v1/samples/entity_client_samples.cc +++ b/google/cloud/chronicle/v1/samples/entity_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::chronicle_v1::EntityServiceClient( + google::cloud::chronicle_v1::MakeEntityServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::chronicle_v1:: EntityServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/chronicle/v1/samples/instance_client_samples.cc b/google/cloud/chronicle/v1/samples/instance_client_samples.cc index b53a5ab91a54d..11e53fbd36180 100644 --- a/google/cloud/chronicle/v1/samples/instance_client_samples.cc +++ b/google/cloud/chronicle/v1/samples/instance_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::chronicle_v1::InstanceServiceClient( + google::cloud::chronicle_v1::MakeInstanceServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::chronicle_v1:: InstanceServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/chronicle/v1/samples/reference_list_client_samples.cc b/google/cloud/chronicle/v1/samples/reference_list_client_samples.cc index 2b37a4cef0f9c..a8f994d97724d 100644 --- a/google/cloud/chronicle/v1/samples/reference_list_client_samples.cc +++ b/google/cloud/chronicle/v1/samples/reference_list_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::chronicle_v1::ReferenceListServiceClient( + google::cloud::chronicle_v1::MakeReferenceListServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::chronicle_v1:: @@ -146,6 +167,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -155,6 +179,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/chronicle/v1/samples/rule_client_samples.cc b/google/cloud/chronicle/v1/samples/rule_client_samples.cc index 87f7b54f195cf..c9bf3cafd61b2 100644 --- a/google/cloud/chronicle/v1/samples/rule_client_samples.cc +++ b/google/cloud/chronicle/v1/samples/rule_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::chronicle_v1::RuleServiceClient( + google::cloud::chronicle_v1::MakeRuleServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::chronicle_v1:: RuleServiceConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/cloudbuild/doc/override-universe-domain.dox b/google/cloud/cloudbuild/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..3320147226bb1 --- /dev/null +++ b/google/cloud/cloudbuild/doc/override-universe-domain.dox @@ -0,0 +1,36 @@ +/*! +@page cloudbuild-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `cloudbuild_v1::CloudBuildClient`: + +@snippet cloud_build_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c cloudbuild_v1::CloudBuildClient](@ref cloudbuild_v1::CloudBuildClient-universe-domain-snippet) +- [\c cloudbuild_v2::RepositoryManagerClient](@ref cloudbuild_v2::RepositoryManagerClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page cloudbuild_v1::CloudBuildClient-universe-domain-snippet Override cloudbuild_v1::CloudBuildClient Universe Domain + +@snippet google/cloud/cloudbuild/v1/samples/cloud_build_client_samples.cc set-client-universe-domain + +*/ + +/*! @page cloudbuild_v2::RepositoryManagerClient-universe-domain-snippet Override cloudbuild_v2::RepositoryManagerClient Universe Domain + +@snippet google/cloud/cloudbuild/v2/samples/repository_manager_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/cloudbuild/v1/samples/cloud_build_client_samples.cc b/google/cloud/cloudbuild/v1/samples/cloud_build_client_samples.cc index 8c6ce80ce6592..51788423a1bb1 100644 --- a/google/cloud/cloudbuild/v1/samples/cloud_build_client_samples.cc +++ b/google/cloud/cloudbuild/v1/samples/cloud_build_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::cloudbuild_v1::CloudBuildClient( + google::cloud::cloudbuild_v1::MakeCloudBuildConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::cloudbuild_v1:: CloudBuildConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/cloudbuild/v2/samples/repository_manager_client_samples.cc b/google/cloud/cloudbuild/v2/samples/repository_manager_client_samples.cc index 4cce7fc8486cc..0071db03ec816 100644 --- a/google/cloud/cloudbuild/v2/samples/repository_manager_client_samples.cc +++ b/google/cloud/cloudbuild/v2/samples/repository_manager_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::cloudbuild_v2::RepositoryManagerClient( + google::cloud::cloudbuild_v2::MakeRepositoryManagerConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::cloudbuild_v2:: @@ -192,6 +213,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -202,6 +226,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/cloudcontrolspartner/doc/override-universe-domain.dox b/google/cloud/cloudcontrolspartner/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..fe545e455b741 --- /dev/null +++ b/google/cloud/cloudcontrolspartner/doc/override-universe-domain.dox @@ -0,0 +1,36 @@ +/*! +@page cloudcontrolspartner-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `cloudcontrolspartner_v1::CloudControlsPartnerCoreClient`: + +@snippet cloud_controls_partner_core_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c cloudcontrolspartner_v1::CloudControlsPartnerCoreClient](@ref cloudcontrolspartner_v1::CloudControlsPartnerCoreClient-universe-domain-snippet) +- [\c cloudcontrolspartner_v1::CloudControlsPartnerMonitoringClient](@ref cloudcontrolspartner_v1::CloudControlsPartnerMonitoringClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page cloudcontrolspartner_v1::CloudControlsPartnerCoreClient-universe-domain-snippet Override cloudcontrolspartner_v1::CloudControlsPartnerCoreClient Universe Domain + +@snippet google/cloud/cloudcontrolspartner/v1/samples/cloud_controls_partner_core_client_samples.cc set-client-universe-domain + +*/ + +/*! @page cloudcontrolspartner_v1::CloudControlsPartnerMonitoringClient-universe-domain-snippet Override cloudcontrolspartner_v1::CloudControlsPartnerMonitoringClient Universe Domain + +@snippet google/cloud/cloudcontrolspartner/v1/samples/cloud_controls_partner_monitoring_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/cloudcontrolspartner/v1/samples/cloud_controls_partner_core_client_samples.cc b/google/cloud/cloudcontrolspartner/v1/samples/cloud_controls_partner_core_client_samples.cc index e3b17e49c3bc2..cb5e78a557a2e 100644 --- a/google/cloud/cloudcontrolspartner/v1/samples/cloud_controls_partner_core_client_samples.cc +++ b/google/cloud/cloudcontrolspartner/v1/samples/cloud_controls_partner_core_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::cloudcontrolspartner_v1::CloudControlsPartnerCoreClient( + google::cloud::cloudcontrolspartner_v1:: + MakeCloudControlsPartnerCoreConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::cloudcontrolspartner_v1:: @@ -155,6 +177,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -164,6 +189,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/cloudcontrolspartner/v1/samples/cloud_controls_partner_monitoring_client_samples.cc b/google/cloud/cloudcontrolspartner/v1/samples/cloud_controls_partner_monitoring_client_samples.cc index 696c7f0c1c6f2..fb881803af844 100644 --- a/google/cloud/cloudcontrolspartner/v1/samples/cloud_controls_partner_monitoring_client_samples.cc +++ b/google/cloud/cloudcontrolspartner/v1/samples/cloud_controls_partner_monitoring_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::cloudcontrolspartner_v1:: + CloudControlsPartnerMonitoringClient( + google::cloud::cloudcontrolspartner_v1:: + MakeCloudControlsPartnerMonitoringConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::cloudcontrolspartner_v1:: @@ -154,6 +176,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -163,6 +188,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/cloudquotas/doc/override-universe-domain.dox b/google/cloud/cloudquotas/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..fcecedae43aa4 --- /dev/null +++ b/google/cloud/cloudquotas/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page cloudquotas-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `cloudquotas_v1::CloudQuotasClient`: + +@snippet cloud_quotas_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page cloudquotas_v1::CloudQuotasClient-universe-domain-snippet Override cloudquotas_v1::CloudQuotasClient Universe Domain + +@snippet google/cloud/cloudquotas/v1/samples/cloud_quotas_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/cloudquotas/v1/samples/cloud_quotas_client_samples.cc b/google/cloud/cloudquotas/v1/samples/cloud_quotas_client_samples.cc index cd3f7d08ff16a..83fa6f0ceb3a7 100644 --- a/google/cloud/cloudquotas/v1/samples/cloud_quotas_client_samples.cc +++ b/google/cloud/cloudquotas/v1/samples/cloud_quotas_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::cloudquotas_v1::CloudQuotasClient( + google::cloud::cloudquotas_v1::MakeCloudQuotasConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::cloudquotas_v1:: CloudQuotasConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/cloudsecuritycompliance/doc/override-universe-domain.dox b/google/cloud/cloudsecuritycompliance/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..1c9a03c8d12ed --- /dev/null +++ b/google/cloud/cloudsecuritycompliance/doc/override-universe-domain.dox @@ -0,0 +1,36 @@ +/*! +@page cloudsecuritycompliance-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `cloudsecuritycompliance_v1::ConfigClient`: + +@snippet config_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c cloudsecuritycompliance_v1::ConfigClient](@ref cloudsecuritycompliance_v1::ConfigClient-universe-domain-snippet) +- [\c cloudsecuritycompliance_v1::DeploymentClient](@ref cloudsecuritycompliance_v1::DeploymentClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page cloudsecuritycompliance_v1::ConfigClient-universe-domain-snippet Override cloudsecuritycompliance_v1::ConfigClient Universe Domain + +@snippet google/cloud/cloudsecuritycompliance/v1/samples/config_client_samples.cc set-client-universe-domain + +*/ + +/*! @page cloudsecuritycompliance_v1::DeploymentClient-universe-domain-snippet Override cloudsecuritycompliance_v1::DeploymentClient Universe Domain + +@snippet google/cloud/cloudsecuritycompliance/v1/samples/deployment_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/cloudsecuritycompliance/v1/samples/config_client_samples.cc b/google/cloud/cloudsecuritycompliance/v1/samples/config_client_samples.cc index 40525797a4f91..7a61432f6bbc6 100644 --- a/google/cloud/cloudsecuritycompliance/v1/samples/config_client_samples.cc +++ b/google/cloud/cloudsecuritycompliance/v1/samples/config_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::cloudsecuritycompliance_v1::ConfigClient( + google::cloud::cloudsecuritycompliance_v1::MakeConfigConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::cloudsecuritycompliance_v1:: @@ -145,6 +166,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -154,6 +178,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/cloudsecuritycompliance/v1/samples/deployment_client_samples.cc b/google/cloud/cloudsecuritycompliance/v1/samples/deployment_client_samples.cc index 8d5d79f1e4d2c..de4b4af44508c 100644 --- a/google/cloud/cloudsecuritycompliance/v1/samples/deployment_client_samples.cc +++ b/google/cloud/cloudsecuritycompliance/v1/samples/deployment_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::cloudsecuritycompliance_v1::DeploymentClient( + google::cloud::cloudsecuritycompliance_v1::MakeDeploymentConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::cloudsecuritycompliance_v1:: @@ -198,6 +219,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -208,6 +232,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/commerce/consumer/procurement/v1/samples/consumer_procurement_client_samples.cc b/google/cloud/commerce/consumer/procurement/v1/samples/consumer_procurement_client_samples.cc index 9faf0d0e00feb..c2d0403c76660 100644 --- a/google/cloud/commerce/consumer/procurement/v1/samples/consumer_procurement_client_samples.cc +++ b/google/cloud/commerce/consumer/procurement/v1/samples/consumer_procurement_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::commerce_consumer_procurement_v1:: + ConsumerProcurementServiceClient( + google::cloud::commerce_consumer_procurement_v1:: + MakeConsumerProcurementServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::commerce_consumer_procurement_v1:: @@ -202,6 +224,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -212,6 +237,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/commerce/doc/override-universe-domain.dox b/google/cloud/commerce/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..7d7226186ecb3 --- /dev/null +++ b/google/cloud/commerce/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page commerce-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `commerce_consumer_procurement_v1::ConsumerProcurementServiceClient`: + +@snippet consumer_procurement_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page commerce_consumer_procurement_v1::ConsumerProcurementServiceClient-universe-domain-snippet Override commerce_consumer_procurement_v1::ConsumerProcurementServiceClient Universe Domain + +@snippet google/cloud/commerce/consumer/procurement/v1/samples/consumer_procurement_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/composer/doc/override-universe-domain.dox b/google/cloud/composer/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..765fbdd59fdb9 --- /dev/null +++ b/google/cloud/composer/doc/override-universe-domain.dox @@ -0,0 +1,36 @@ +/*! +@page composer-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `composer_v1::EnvironmentsClient`: + +@snippet environments_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c composer_v1::EnvironmentsClient](@ref composer_v1::EnvironmentsClient-universe-domain-snippet) +- [\c composer_v1::ImageVersionsClient](@ref composer_v1::ImageVersionsClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page composer_v1::EnvironmentsClient-universe-domain-snippet Override composer_v1::EnvironmentsClient Universe Domain + +@snippet google/cloud/composer/v1/samples/environments_client_samples.cc set-client-universe-domain + +*/ + +/*! @page composer_v1::ImageVersionsClient-universe-domain-snippet Override composer_v1::ImageVersionsClient Universe Domain + +@snippet google/cloud/composer/v1/samples/image_versions_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/composer/v1/samples/environments_client_samples.cc b/google/cloud/composer/v1/samples/environments_client_samples.cc index f7bb6c4ddce77..32270d5856a81 100644 --- a/google/cloud/composer/v1/samples/environments_client_samples.cc +++ b/google/cloud/composer/v1/samples/environments_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::composer_v1::EnvironmentsClient( + google::cloud::composer_v1::MakeEnvironmentsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::composer_v1:: EnvironmentsConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/composer/v1/samples/image_versions_client_samples.cc b/google/cloud/composer/v1/samples/image_versions_client_samples.cc index 4047dd8596a17..b4d16616963a2 100644 --- a/google/cloud/composer/v1/samples/image_versions_client_samples.cc +++ b/google/cloud/composer/v1/samples/image_versions_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::composer_v1::ImageVersionsClient( + google::cloud::composer_v1::MakeImageVersionsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::composer_v1:: ImageVersionsConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/BUILD.bazel b/google/cloud/compute/BUILD.bazel index 48962c7e859f8..a7a8726b47934 100644 --- a/google/cloud/compute/BUILD.bazel +++ b/google/cloud/compute/BUILD.bazel @@ -38,6 +38,7 @@ operations = [":google_cloud_cpp_compute_" + d.replace("/v1/", "") for d in oper tags = ["integration-test"], deps = [ ":google_cloud_cpp_compute_" + sample[0:sample.find("/v")], + "//:universe_domain", "//google/cloud/testing_util:google_cloud_cpp_testing_private", ], ) for sample in glob([d + "samples/*.cc" for d in service_dirs + operation_service_dirs])] diff --git a/google/cloud/compute/accelerator_types/v1/samples/accelerator_types_client_samples.cc b/google/cloud/compute/accelerator_types/v1/samples/accelerator_types_client_samples.cc index b33f76159d18e..c3be3dae07d6f 100644 --- a/google/cloud/compute/accelerator_types/v1/samples/accelerator_types_client_samples.cc +++ b/google/cloud/compute/accelerator_types/v1/samples/accelerator_types_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_accelerator_types_v1::AcceleratorTypesClient( + google::cloud::compute_accelerator_types_v1:: + MakeAcceleratorTypesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_accelerator_types_v1:: @@ -150,6 +172,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -159,6 +184,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/addresses/v1/samples/addresses_client_samples.cc b/google/cloud/compute/addresses/v1/samples/addresses_client_samples.cc index e0b5dd6d665e5..76cd1df524372 100644 --- a/google/cloud/compute/addresses/v1/samples/addresses_client_samples.cc +++ b/google/cloud/compute/addresses/v1/samples/addresses_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_addresses_v1::AddressesClient( + google::cloud::compute_addresses_v1::MakeAddressesConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_addresses_v1:: AddressesConnectionIdempotencyPolicy { @@ -190,6 +211,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -200,6 +224,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/autoscalers/v1/samples/autoscalers_client_samples.cc b/google/cloud/compute/autoscalers/v1/samples/autoscalers_client_samples.cc index 1858a5cfc231a..865d641ffac0d 100644 --- a/google/cloud/compute/autoscalers/v1/samples/autoscalers_client_samples.cc +++ b/google/cloud/compute/autoscalers/v1/samples/autoscalers_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_autoscalers_v1::AutoscalersClient( + google::cloud::compute_autoscalers_v1::MakeAutoscalersConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_autoscalers_v1:: AutoscalersConnectionIdempotencyPolicy { @@ -197,6 +218,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -207,6 +231,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/backend_buckets/v1/samples/backend_buckets_client_samples.cc b/google/cloud/compute/backend_buckets/v1/samples/backend_buckets_client_samples.cc index e948d9c8bb68f..884567497a5f0 100644 --- a/google/cloud/compute/backend_buckets/v1/samples/backend_buckets_client_samples.cc +++ b/google/cloud/compute/backend_buckets/v1/samples/backend_buckets_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_backend_buckets_v1::BackendBucketsClient( + google::cloud::compute_backend_buckets_v1:: + MakeBackendBucketsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_backend_buckets_v1:: @@ -197,6 +219,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -207,6 +232,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/backend_services/v1/samples/backend_services_client_samples.cc b/google/cloud/compute/backend_services/v1/samples/backend_services_client_samples.cc index 54f6da1884ac1..9a0a85742573d 100644 --- a/google/cloud/compute/backend_services/v1/samples/backend_services_client_samples.cc +++ b/google/cloud/compute/backend_services/v1/samples/backend_services_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_backend_services_v1::BackendServicesClient( + google::cloud::compute_backend_services_v1:: + MakeBackendServicesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_backend_services_v1:: @@ -197,6 +219,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -207,6 +232,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/disk_types/v1/samples/disk_types_client_samples.cc b/google/cloud/compute/disk_types/v1/samples/disk_types_client_samples.cc index e6d8cafb9ad63..0d3774308546b 100644 --- a/google/cloud/compute/disk_types/v1/samples/disk_types_client_samples.cc +++ b/google/cloud/compute/disk_types/v1/samples/disk_types_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_disk_types_v1::DiskTypesClient( + google::cloud::compute_disk_types_v1::MakeDiskTypesConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_disk_types_v1:: DiskTypesConnectionIdempotencyPolicy { @@ -147,6 +168,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -156,6 +180,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/disks/v1/samples/disks_client_samples.cc b/google/cloud/compute/disks/v1/samples/disks_client_samples.cc index 265953884908f..151fbda7340b7 100644 --- a/google/cloud/compute/disks/v1/samples/disks_client_samples.cc +++ b/google/cloud/compute/disks/v1/samples/disks_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_disks_v1::DisksClient( + google::cloud::compute_disks_v1::MakeDisksConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_disks_v1::DisksConnectionIdempotencyPolicy { @@ -184,6 +204,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -194,6 +217,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/doc/override-universe-domain.dox b/google/cloud/compute/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..2074ffa8c63dc --- /dev/null +++ b/google/cloud/compute/doc/override-universe-domain.dox @@ -0,0 +1,757 @@ +/*! +@page compute-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `compute_accelerator_types_v1::AcceleratorTypesClient`: + +@snippet accelerator_types_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c compute_accelerator_types_v1::AcceleratorTypesClient](@ref compute_accelerator_types_v1::AcceleratorTypesClient-universe-domain-snippet) +- [\c compute_addresses_v1::AddressesClient](@ref compute_addresses_v1::AddressesClient-universe-domain-snippet) +- [\c compute_autoscalers_v1::AutoscalersClient](@ref compute_autoscalers_v1::AutoscalersClient-universe-domain-snippet) +- [\c compute_backend_buckets_v1::BackendBucketsClient](@ref compute_backend_buckets_v1::BackendBucketsClient-universe-domain-snippet) +- [\c compute_backend_services_v1::BackendServicesClient](@ref compute_backend_services_v1::BackendServicesClient-universe-domain-snippet) +- [\c compute_disk_types_v1::DiskTypesClient](@ref compute_disk_types_v1::DiskTypesClient-universe-domain-snippet) +- [\c compute_disks_v1::DisksClient](@ref compute_disks_v1::DisksClient-universe-domain-snippet) +- [\c compute_external_vpn_gateways_v1::ExternalVpnGatewaysClient](@ref compute_external_vpn_gateways_v1::ExternalVpnGatewaysClient-universe-domain-snippet) +- [\c compute_firewall_policies_v1::FirewallPoliciesClient](@ref compute_firewall_policies_v1::FirewallPoliciesClient-universe-domain-snippet) +- [\c compute_firewalls_v1::FirewallsClient](@ref compute_firewalls_v1::FirewallsClient-universe-domain-snippet) +- [\c compute_forwarding_rules_v1::ForwardingRulesClient](@ref compute_forwarding_rules_v1::ForwardingRulesClient-universe-domain-snippet) +- [\c compute_global_addresses_v1::GlobalAddressesClient](@ref compute_global_addresses_v1::GlobalAddressesClient-universe-domain-snippet) +- [\c compute_global_forwarding_rules_v1::GlobalForwardingRulesClient](@ref compute_global_forwarding_rules_v1::GlobalForwardingRulesClient-universe-domain-snippet) +- [\c compute_global_network_endpoint_groups_v1::GlobalNetworkEndpointGroupsClient](@ref compute_global_network_endpoint_groups_v1::GlobalNetworkEndpointGroupsClient-universe-domain-snippet) +- [\c compute_global_operations_v1::GlobalOperationsClient](@ref compute_global_operations_v1::GlobalOperationsClient-universe-domain-snippet) +- [\c compute_global_organization_operations_v1::GlobalOrganizationOperationsClient](@ref compute_global_organization_operations_v1::GlobalOrganizationOperationsClient-universe-domain-snippet) +- [\c compute_global_public_delegated_prefixes_v1::GlobalPublicDelegatedPrefixesClient](@ref compute_global_public_delegated_prefixes_v1::GlobalPublicDelegatedPrefixesClient-universe-domain-snippet) +- [\c compute_health_checks_v1::HealthChecksClient](@ref compute_health_checks_v1::HealthChecksClient-universe-domain-snippet) +- [\c compute_http_health_checks_v1::HttpHealthChecksClient](@ref compute_http_health_checks_v1::HttpHealthChecksClient-universe-domain-snippet) +- [\c compute_https_health_checks_v1::HttpsHealthChecksClient](@ref compute_https_health_checks_v1::HttpsHealthChecksClient-universe-domain-snippet) +- [\c compute_image_family_views_v1::ImageFamilyViewsClient](@ref compute_image_family_views_v1::ImageFamilyViewsClient-universe-domain-snippet) +- [\c compute_images_v1::ImagesClient](@ref compute_images_v1::ImagesClient-universe-domain-snippet) +- [\c compute_instance_group_manager_resize_requests_v1::InstanceGroupManagerResizeRequestsClient](@ref compute_instance_group_manager_resize_requests_v1::InstanceGroupManagerResizeRequestsClient-universe-domain-snippet) +- [\c compute_instance_group_managers_v1::InstanceGroupManagersClient](@ref compute_instance_group_managers_v1::InstanceGroupManagersClient-universe-domain-snippet) +- [\c compute_instance_groups_v1::InstanceGroupsClient](@ref compute_instance_groups_v1::InstanceGroupsClient-universe-domain-snippet) +- [\c compute_instance_settings_v1::InstanceSettingsClient](@ref compute_instance_settings_v1::InstanceSettingsClient-universe-domain-snippet) +- [\c compute_instance_templates_v1::InstanceTemplatesClient](@ref compute_instance_templates_v1::InstanceTemplatesClient-universe-domain-snippet) +- [\c compute_instances_v1::InstancesClient](@ref compute_instances_v1::InstancesClient-universe-domain-snippet) +- [\c compute_instant_snapshots_v1::InstantSnapshotsClient](@ref compute_instant_snapshots_v1::InstantSnapshotsClient-universe-domain-snippet) +- [\c compute_interconnect_attachment_groups_v1::InterconnectAttachmentGroupsClient](@ref compute_interconnect_attachment_groups_v1::InterconnectAttachmentGroupsClient-universe-domain-snippet) +- [\c compute_interconnect_attachments_v1::InterconnectAttachmentsClient](@ref compute_interconnect_attachments_v1::InterconnectAttachmentsClient-universe-domain-snippet) +- [\c compute_interconnect_groups_v1::InterconnectGroupsClient](@ref compute_interconnect_groups_v1::InterconnectGroupsClient-universe-domain-snippet) +- [\c compute_interconnect_locations_v1::InterconnectLocationsClient](@ref compute_interconnect_locations_v1::InterconnectLocationsClient-universe-domain-snippet) +- [\c compute_interconnect_remote_locations_v1::InterconnectRemoteLocationsClient](@ref compute_interconnect_remote_locations_v1::InterconnectRemoteLocationsClient-universe-domain-snippet) +- [\c compute_interconnects_v1::InterconnectsClient](@ref compute_interconnects_v1::InterconnectsClient-universe-domain-snippet) +- [\c compute_license_codes_v1::LicenseCodesClient](@ref compute_license_codes_v1::LicenseCodesClient-universe-domain-snippet) +- [\c compute_licenses_v1::LicensesClient](@ref compute_licenses_v1::LicensesClient-universe-domain-snippet) +- [\c compute_machine_images_v1::MachineImagesClient](@ref compute_machine_images_v1::MachineImagesClient-universe-domain-snippet) +- [\c compute_machine_types_v1::MachineTypesClient](@ref compute_machine_types_v1::MachineTypesClient-universe-domain-snippet) +- [\c compute_network_attachments_v1::NetworkAttachmentsClient](@ref compute_network_attachments_v1::NetworkAttachmentsClient-universe-domain-snippet) +- [\c compute_network_edge_security_services_v1::NetworkEdgeSecurityServicesClient](@ref compute_network_edge_security_services_v1::NetworkEdgeSecurityServicesClient-universe-domain-snippet) +- [\c compute_network_endpoint_groups_v1::NetworkEndpointGroupsClient](@ref compute_network_endpoint_groups_v1::NetworkEndpointGroupsClient-universe-domain-snippet) +- [\c compute_network_firewall_policies_v1::NetworkFirewallPoliciesClient](@ref compute_network_firewall_policies_v1::NetworkFirewallPoliciesClient-universe-domain-snippet) +- [\c compute_network_profiles_v1::NetworkProfilesClient](@ref compute_network_profiles_v1::NetworkProfilesClient-universe-domain-snippet) +- [\c compute_networks_v1::NetworksClient](@ref compute_networks_v1::NetworksClient-universe-domain-snippet) +- [\c compute_node_groups_v1::NodeGroupsClient](@ref compute_node_groups_v1::NodeGroupsClient-universe-domain-snippet) +- [\c compute_node_templates_v1::NodeTemplatesClient](@ref compute_node_templates_v1::NodeTemplatesClient-universe-domain-snippet) +- [\c compute_node_types_v1::NodeTypesClient](@ref compute_node_types_v1::NodeTypesClient-universe-domain-snippet) +- [\c compute_packet_mirrorings_v1::PacketMirroringsClient](@ref compute_packet_mirrorings_v1::PacketMirroringsClient-universe-domain-snippet) +- [\c compute_projects_v1::ProjectsClient](@ref compute_projects_v1::ProjectsClient-universe-domain-snippet) +- [\c compute_public_advertised_prefixes_v1::PublicAdvertisedPrefixesClient](@ref compute_public_advertised_prefixes_v1::PublicAdvertisedPrefixesClient-universe-domain-snippet) +- [\c compute_public_delegated_prefixes_v1::PublicDelegatedPrefixesClient](@ref compute_public_delegated_prefixes_v1::PublicDelegatedPrefixesClient-universe-domain-snippet) +- [\c compute_region_autoscalers_v1::RegionAutoscalersClient](@ref compute_region_autoscalers_v1::RegionAutoscalersClient-universe-domain-snippet) +- [\c compute_region_backend_services_v1::RegionBackendServicesClient](@ref compute_region_backend_services_v1::RegionBackendServicesClient-universe-domain-snippet) +- [\c compute_region_commitments_v1::RegionCommitmentsClient](@ref compute_region_commitments_v1::RegionCommitmentsClient-universe-domain-snippet) +- [\c compute_region_disk_types_v1::RegionDiskTypesClient](@ref compute_region_disk_types_v1::RegionDiskTypesClient-universe-domain-snippet) +- [\c compute_region_disks_v1::RegionDisksClient](@ref compute_region_disks_v1::RegionDisksClient-universe-domain-snippet) +- [\c compute_region_health_check_services_v1::RegionHealthCheckServicesClient](@ref compute_region_health_check_services_v1::RegionHealthCheckServicesClient-universe-domain-snippet) +- [\c compute_region_health_checks_v1::RegionHealthChecksClient](@ref compute_region_health_checks_v1::RegionHealthChecksClient-universe-domain-snippet) +- [\c compute_region_instance_group_managers_v1::RegionInstanceGroupManagersClient](@ref compute_region_instance_group_managers_v1::RegionInstanceGroupManagersClient-universe-domain-snippet) +- [\c compute_region_instance_groups_v1::RegionInstanceGroupsClient](@ref compute_region_instance_groups_v1::RegionInstanceGroupsClient-universe-domain-snippet) +- [\c compute_region_instance_templates_v1::RegionInstanceTemplatesClient](@ref compute_region_instance_templates_v1::RegionInstanceTemplatesClient-universe-domain-snippet) +- [\c compute_region_instances_v1::RegionInstancesClient](@ref compute_region_instances_v1::RegionInstancesClient-universe-domain-snippet) +- [\c compute_region_instant_snapshots_v1::RegionInstantSnapshotsClient](@ref compute_region_instant_snapshots_v1::RegionInstantSnapshotsClient-universe-domain-snippet) +- [\c compute_region_network_endpoint_groups_v1::RegionNetworkEndpointGroupsClient](@ref compute_region_network_endpoint_groups_v1::RegionNetworkEndpointGroupsClient-universe-domain-snippet) +- [\c compute_region_network_firewall_policies_v1::RegionNetworkFirewallPoliciesClient](@ref compute_region_network_firewall_policies_v1::RegionNetworkFirewallPoliciesClient-universe-domain-snippet) +- [\c compute_region_notification_endpoints_v1::RegionNotificationEndpointsClient](@ref compute_region_notification_endpoints_v1::RegionNotificationEndpointsClient-universe-domain-snippet) +- [\c compute_region_operations_v1::RegionOperationsClient](@ref compute_region_operations_v1::RegionOperationsClient-universe-domain-snippet) +- [\c compute_region_security_policies_v1::RegionSecurityPoliciesClient](@ref compute_region_security_policies_v1::RegionSecurityPoliciesClient-universe-domain-snippet) +- [\c compute_region_ssl_certificates_v1::RegionSslCertificatesClient](@ref compute_region_ssl_certificates_v1::RegionSslCertificatesClient-universe-domain-snippet) +- [\c compute_region_ssl_policies_v1::RegionSslPoliciesClient](@ref compute_region_ssl_policies_v1::RegionSslPoliciesClient-universe-domain-snippet) +- [\c compute_region_target_http_proxies_v1::RegionTargetHttpProxiesClient](@ref compute_region_target_http_proxies_v1::RegionTargetHttpProxiesClient-universe-domain-snippet) +- [\c compute_region_target_https_proxies_v1::RegionTargetHttpsProxiesClient](@ref compute_region_target_https_proxies_v1::RegionTargetHttpsProxiesClient-universe-domain-snippet) +- [\c compute_region_target_tcp_proxies_v1::RegionTargetTcpProxiesClient](@ref compute_region_target_tcp_proxies_v1::RegionTargetTcpProxiesClient-universe-domain-snippet) +- [\c compute_region_url_maps_v1::RegionUrlMapsClient](@ref compute_region_url_maps_v1::RegionUrlMapsClient-universe-domain-snippet) +- [\c compute_region_zones_v1::RegionZonesClient](@ref compute_region_zones_v1::RegionZonesClient-universe-domain-snippet) +- [\c compute_regions_v1::RegionsClient](@ref compute_regions_v1::RegionsClient-universe-domain-snippet) +- [\c compute_reservation_blocks_v1::ReservationBlocksClient](@ref compute_reservation_blocks_v1::ReservationBlocksClient-universe-domain-snippet) +- [\c compute_reservation_sub_blocks_v1::ReservationSubBlocksClient](@ref compute_reservation_sub_blocks_v1::ReservationSubBlocksClient-universe-domain-snippet) +- [\c compute_reservations_v1::ReservationsClient](@ref compute_reservations_v1::ReservationsClient-universe-domain-snippet) +- [\c compute_resource_policies_v1::ResourcePoliciesClient](@ref compute_resource_policies_v1::ResourcePoliciesClient-universe-domain-snippet) +- [\c compute_routers_v1::RoutersClient](@ref compute_routers_v1::RoutersClient-universe-domain-snippet) +- [\c compute_routes_v1::RoutesClient](@ref compute_routes_v1::RoutesClient-universe-domain-snippet) +- [\c compute_security_policies_v1::SecurityPoliciesClient](@ref compute_security_policies_v1::SecurityPoliciesClient-universe-domain-snippet) +- [\c compute_service_attachments_v1::ServiceAttachmentsClient](@ref compute_service_attachments_v1::ServiceAttachmentsClient-universe-domain-snippet) +- [\c compute_snapshot_settings_v1::SnapshotSettingsClient](@ref compute_snapshot_settings_v1::SnapshotSettingsClient-universe-domain-snippet) +- [\c compute_snapshots_v1::SnapshotsClient](@ref compute_snapshots_v1::SnapshotsClient-universe-domain-snippet) +- [\c compute_ssl_certificates_v1::SslCertificatesClient](@ref compute_ssl_certificates_v1::SslCertificatesClient-universe-domain-snippet) +- [\c compute_ssl_policies_v1::SslPoliciesClient](@ref compute_ssl_policies_v1::SslPoliciesClient-universe-domain-snippet) +- [\c compute_storage_pool_types_v1::StoragePoolTypesClient](@ref compute_storage_pool_types_v1::StoragePoolTypesClient-universe-domain-snippet) +- [\c compute_storage_pools_v1::StoragePoolsClient](@ref compute_storage_pools_v1::StoragePoolsClient-universe-domain-snippet) +- [\c compute_subnetworks_v1::SubnetworksClient](@ref compute_subnetworks_v1::SubnetworksClient-universe-domain-snippet) +- [\c compute_target_grpc_proxies_v1::TargetGrpcProxiesClient](@ref compute_target_grpc_proxies_v1::TargetGrpcProxiesClient-universe-domain-snippet) +- [\c compute_target_http_proxies_v1::TargetHttpProxiesClient](@ref compute_target_http_proxies_v1::TargetHttpProxiesClient-universe-domain-snippet) +- [\c compute_target_https_proxies_v1::TargetHttpsProxiesClient](@ref compute_target_https_proxies_v1::TargetHttpsProxiesClient-universe-domain-snippet) +- [\c compute_target_instances_v1::TargetInstancesClient](@ref compute_target_instances_v1::TargetInstancesClient-universe-domain-snippet) +- [\c compute_target_pools_v1::TargetPoolsClient](@ref compute_target_pools_v1::TargetPoolsClient-universe-domain-snippet) +- [\c compute_target_ssl_proxies_v1::TargetSslProxiesClient](@ref compute_target_ssl_proxies_v1::TargetSslProxiesClient-universe-domain-snippet) +- [\c compute_target_tcp_proxies_v1::TargetTcpProxiesClient](@ref compute_target_tcp_proxies_v1::TargetTcpProxiesClient-universe-domain-snippet) +- [\c compute_target_vpn_gateways_v1::TargetVpnGatewaysClient](@ref compute_target_vpn_gateways_v1::TargetVpnGatewaysClient-universe-domain-snippet) +- [\c compute_url_maps_v1::UrlMapsClient](@ref compute_url_maps_v1::UrlMapsClient-universe-domain-snippet) +- [\c compute_vpn_gateways_v1::VpnGatewaysClient](@ref compute_vpn_gateways_v1::VpnGatewaysClient-universe-domain-snippet) +- [\c compute_vpn_tunnels_v1::VpnTunnelsClient](@ref compute_vpn_tunnels_v1::VpnTunnelsClient-universe-domain-snippet) +- [\c compute_zone_operations_v1::ZoneOperationsClient](@ref compute_zone_operations_v1::ZoneOperationsClient-universe-domain-snippet) +- [\c compute_zones_v1::ZonesClient](@ref compute_zones_v1::ZonesClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page compute_accelerator_types_v1::AcceleratorTypesClient-universe-domain-snippet Override compute_accelerator_types_v1::AcceleratorTypesClient Universe Domain + +@snippet google/cloud/compute/accelerator_types/v1/samples/accelerator_types_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_addresses_v1::AddressesClient-universe-domain-snippet Override compute_addresses_v1::AddressesClient Universe Domain + +@snippet google/cloud/compute/addresses/v1/samples/addresses_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_autoscalers_v1::AutoscalersClient-universe-domain-snippet Override compute_autoscalers_v1::AutoscalersClient Universe Domain + +@snippet google/cloud/compute/autoscalers/v1/samples/autoscalers_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_backend_buckets_v1::BackendBucketsClient-universe-domain-snippet Override compute_backend_buckets_v1::BackendBucketsClient Universe Domain + +@snippet google/cloud/compute/backend_buckets/v1/samples/backend_buckets_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_backend_services_v1::BackendServicesClient-universe-domain-snippet Override compute_backend_services_v1::BackendServicesClient Universe Domain + +@snippet google/cloud/compute/backend_services/v1/samples/backend_services_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_disk_types_v1::DiskTypesClient-universe-domain-snippet Override compute_disk_types_v1::DiskTypesClient Universe Domain + +@snippet google/cloud/compute/disk_types/v1/samples/disk_types_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_disks_v1::DisksClient-universe-domain-snippet Override compute_disks_v1::DisksClient Universe Domain + +@snippet google/cloud/compute/disks/v1/samples/disks_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_external_vpn_gateways_v1::ExternalVpnGatewaysClient-universe-domain-snippet Override compute_external_vpn_gateways_v1::ExternalVpnGatewaysClient Universe Domain + +@snippet google/cloud/compute/external_vpn_gateways/v1/samples/external_vpn_gateways_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_firewall_policies_v1::FirewallPoliciesClient-universe-domain-snippet Override compute_firewall_policies_v1::FirewallPoliciesClient Universe Domain + +@snippet google/cloud/compute/firewall_policies/v1/samples/firewall_policies_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_firewalls_v1::FirewallsClient-universe-domain-snippet Override compute_firewalls_v1::FirewallsClient Universe Domain + +@snippet google/cloud/compute/firewalls/v1/samples/firewalls_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_forwarding_rules_v1::ForwardingRulesClient-universe-domain-snippet Override compute_forwarding_rules_v1::ForwardingRulesClient Universe Domain + +@snippet google/cloud/compute/forwarding_rules/v1/samples/forwarding_rules_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_global_addresses_v1::GlobalAddressesClient-universe-domain-snippet Override compute_global_addresses_v1::GlobalAddressesClient Universe Domain + +@snippet google/cloud/compute/global_addresses/v1/samples/global_addresses_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_global_forwarding_rules_v1::GlobalForwardingRulesClient-universe-domain-snippet Override compute_global_forwarding_rules_v1::GlobalForwardingRulesClient Universe Domain + +@snippet google/cloud/compute/global_forwarding_rules/v1/samples/global_forwarding_rules_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_global_network_endpoint_groups_v1::GlobalNetworkEndpointGroupsClient-universe-domain-snippet Override compute_global_network_endpoint_groups_v1::GlobalNetworkEndpointGroupsClient Universe Domain + +@snippet google/cloud/compute/global_network_endpoint_groups/v1/samples/global_network_endpoint_groups_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_global_operations_v1::GlobalOperationsClient-universe-domain-snippet Override compute_global_operations_v1::GlobalOperationsClient Universe Domain + +@snippet google/cloud/compute/global_operations/v1/samples/global_operations_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_global_organization_operations_v1::GlobalOrganizationOperationsClient-universe-domain-snippet Override compute_global_organization_operations_v1::GlobalOrganizationOperationsClient Universe Domain + +@snippet google/cloud/compute/global_organization_operations/v1/samples/global_organization_operations_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_global_public_delegated_prefixes_v1::GlobalPublicDelegatedPrefixesClient-universe-domain-snippet Override compute_global_public_delegated_prefixes_v1::GlobalPublicDelegatedPrefixesClient Universe Domain + +@snippet google/cloud/compute/global_public_delegated_prefixes/v1/samples/global_public_delegated_prefixes_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_health_checks_v1::HealthChecksClient-universe-domain-snippet Override compute_health_checks_v1::HealthChecksClient Universe Domain + +@snippet google/cloud/compute/health_checks/v1/samples/health_checks_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_http_health_checks_v1::HttpHealthChecksClient-universe-domain-snippet Override compute_http_health_checks_v1::HttpHealthChecksClient Universe Domain + +@snippet google/cloud/compute/http_health_checks/v1/samples/http_health_checks_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_https_health_checks_v1::HttpsHealthChecksClient-universe-domain-snippet Override compute_https_health_checks_v1::HttpsHealthChecksClient Universe Domain + +@snippet google/cloud/compute/https_health_checks/v1/samples/https_health_checks_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_image_family_views_v1::ImageFamilyViewsClient-universe-domain-snippet Override compute_image_family_views_v1::ImageFamilyViewsClient Universe Domain + +@snippet google/cloud/compute/image_family_views/v1/samples/image_family_views_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_images_v1::ImagesClient-universe-domain-snippet Override compute_images_v1::ImagesClient Universe Domain + +@snippet google/cloud/compute/images/v1/samples/images_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_instance_group_manager_resize_requests_v1::InstanceGroupManagerResizeRequestsClient-universe-domain-snippet Override compute_instance_group_manager_resize_requests_v1::InstanceGroupManagerResizeRequestsClient Universe Domain + +@snippet google/cloud/compute/instance_group_manager_resize_requests/v1/samples/instance_group_manager_resize_requests_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_instance_group_managers_v1::InstanceGroupManagersClient-universe-domain-snippet Override compute_instance_group_managers_v1::InstanceGroupManagersClient Universe Domain + +@snippet google/cloud/compute/instance_group_managers/v1/samples/instance_group_managers_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_instance_groups_v1::InstanceGroupsClient-universe-domain-snippet Override compute_instance_groups_v1::InstanceGroupsClient Universe Domain + +@snippet google/cloud/compute/instance_groups/v1/samples/instance_groups_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_instance_settings_v1::InstanceSettingsClient-universe-domain-snippet Override compute_instance_settings_v1::InstanceSettingsClient Universe Domain + +@snippet google/cloud/compute/instance_settings/v1/samples/instance_settings_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_instance_templates_v1::InstanceTemplatesClient-universe-domain-snippet Override compute_instance_templates_v1::InstanceTemplatesClient Universe Domain + +@snippet google/cloud/compute/instance_templates/v1/samples/instance_templates_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_instances_v1::InstancesClient-universe-domain-snippet Override compute_instances_v1::InstancesClient Universe Domain + +@snippet google/cloud/compute/instances/v1/samples/instances_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_instant_snapshots_v1::InstantSnapshotsClient-universe-domain-snippet Override compute_instant_snapshots_v1::InstantSnapshotsClient Universe Domain + +@snippet google/cloud/compute/instant_snapshots/v1/samples/instant_snapshots_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_interconnect_attachment_groups_v1::InterconnectAttachmentGroupsClient-universe-domain-snippet Override compute_interconnect_attachment_groups_v1::InterconnectAttachmentGroupsClient Universe Domain + +@snippet google/cloud/compute/interconnect_attachment_groups/v1/samples/interconnect_attachment_groups_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_interconnect_attachments_v1::InterconnectAttachmentsClient-universe-domain-snippet Override compute_interconnect_attachments_v1::InterconnectAttachmentsClient Universe Domain + +@snippet google/cloud/compute/interconnect_attachments/v1/samples/interconnect_attachments_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_interconnect_groups_v1::InterconnectGroupsClient-universe-domain-snippet Override compute_interconnect_groups_v1::InterconnectGroupsClient Universe Domain + +@snippet google/cloud/compute/interconnect_groups/v1/samples/interconnect_groups_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_interconnect_locations_v1::InterconnectLocationsClient-universe-domain-snippet Override compute_interconnect_locations_v1::InterconnectLocationsClient Universe Domain + +@snippet google/cloud/compute/interconnect_locations/v1/samples/interconnect_locations_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_interconnect_remote_locations_v1::InterconnectRemoteLocationsClient-universe-domain-snippet Override compute_interconnect_remote_locations_v1::InterconnectRemoteLocationsClient Universe Domain + +@snippet google/cloud/compute/interconnect_remote_locations/v1/samples/interconnect_remote_locations_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_interconnects_v1::InterconnectsClient-universe-domain-snippet Override compute_interconnects_v1::InterconnectsClient Universe Domain + +@snippet google/cloud/compute/interconnects/v1/samples/interconnects_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_license_codes_v1::LicenseCodesClient-universe-domain-snippet Override compute_license_codes_v1::LicenseCodesClient Universe Domain + +@snippet google/cloud/compute/license_codes/v1/samples/license_codes_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_licenses_v1::LicensesClient-universe-domain-snippet Override compute_licenses_v1::LicensesClient Universe Domain + +@snippet google/cloud/compute/licenses/v1/samples/licenses_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_machine_images_v1::MachineImagesClient-universe-domain-snippet Override compute_machine_images_v1::MachineImagesClient Universe Domain + +@snippet google/cloud/compute/machine_images/v1/samples/machine_images_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_machine_types_v1::MachineTypesClient-universe-domain-snippet Override compute_machine_types_v1::MachineTypesClient Universe Domain + +@snippet google/cloud/compute/machine_types/v1/samples/machine_types_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_network_attachments_v1::NetworkAttachmentsClient-universe-domain-snippet Override compute_network_attachments_v1::NetworkAttachmentsClient Universe Domain + +@snippet google/cloud/compute/network_attachments/v1/samples/network_attachments_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_network_edge_security_services_v1::NetworkEdgeSecurityServicesClient-universe-domain-snippet Override compute_network_edge_security_services_v1::NetworkEdgeSecurityServicesClient Universe Domain + +@snippet google/cloud/compute/network_edge_security_services/v1/samples/network_edge_security_services_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_network_endpoint_groups_v1::NetworkEndpointGroupsClient-universe-domain-snippet Override compute_network_endpoint_groups_v1::NetworkEndpointGroupsClient Universe Domain + +@snippet google/cloud/compute/network_endpoint_groups/v1/samples/network_endpoint_groups_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_network_firewall_policies_v1::NetworkFirewallPoliciesClient-universe-domain-snippet Override compute_network_firewall_policies_v1::NetworkFirewallPoliciesClient Universe Domain + +@snippet google/cloud/compute/network_firewall_policies/v1/samples/network_firewall_policies_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_network_profiles_v1::NetworkProfilesClient-universe-domain-snippet Override compute_network_profiles_v1::NetworkProfilesClient Universe Domain + +@snippet google/cloud/compute/network_profiles/v1/samples/network_profiles_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_networks_v1::NetworksClient-universe-domain-snippet Override compute_networks_v1::NetworksClient Universe Domain + +@snippet google/cloud/compute/networks/v1/samples/networks_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_node_groups_v1::NodeGroupsClient-universe-domain-snippet Override compute_node_groups_v1::NodeGroupsClient Universe Domain + +@snippet google/cloud/compute/node_groups/v1/samples/node_groups_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_node_templates_v1::NodeTemplatesClient-universe-domain-snippet Override compute_node_templates_v1::NodeTemplatesClient Universe Domain + +@snippet google/cloud/compute/node_templates/v1/samples/node_templates_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_node_types_v1::NodeTypesClient-universe-domain-snippet Override compute_node_types_v1::NodeTypesClient Universe Domain + +@snippet google/cloud/compute/node_types/v1/samples/node_types_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_packet_mirrorings_v1::PacketMirroringsClient-universe-domain-snippet Override compute_packet_mirrorings_v1::PacketMirroringsClient Universe Domain + +@snippet google/cloud/compute/packet_mirrorings/v1/samples/packet_mirrorings_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_projects_v1::ProjectsClient-universe-domain-snippet Override compute_projects_v1::ProjectsClient Universe Domain + +@snippet google/cloud/compute/projects/v1/samples/projects_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_public_advertised_prefixes_v1::PublicAdvertisedPrefixesClient-universe-domain-snippet Override compute_public_advertised_prefixes_v1::PublicAdvertisedPrefixesClient Universe Domain + +@snippet google/cloud/compute/public_advertised_prefixes/v1/samples/public_advertised_prefixes_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_public_delegated_prefixes_v1::PublicDelegatedPrefixesClient-universe-domain-snippet Override compute_public_delegated_prefixes_v1::PublicDelegatedPrefixesClient Universe Domain + +@snippet google/cloud/compute/public_delegated_prefixes/v1/samples/public_delegated_prefixes_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_region_autoscalers_v1::RegionAutoscalersClient-universe-domain-snippet Override compute_region_autoscalers_v1::RegionAutoscalersClient Universe Domain + +@snippet google/cloud/compute/region_autoscalers/v1/samples/region_autoscalers_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_region_backend_services_v1::RegionBackendServicesClient-universe-domain-snippet Override compute_region_backend_services_v1::RegionBackendServicesClient Universe Domain + +@snippet google/cloud/compute/region_backend_services/v1/samples/region_backend_services_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_region_commitments_v1::RegionCommitmentsClient-universe-domain-snippet Override compute_region_commitments_v1::RegionCommitmentsClient Universe Domain + +@snippet google/cloud/compute/region_commitments/v1/samples/region_commitments_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_region_disk_types_v1::RegionDiskTypesClient-universe-domain-snippet Override compute_region_disk_types_v1::RegionDiskTypesClient Universe Domain + +@snippet google/cloud/compute/region_disk_types/v1/samples/region_disk_types_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_region_disks_v1::RegionDisksClient-universe-domain-snippet Override compute_region_disks_v1::RegionDisksClient Universe Domain + +@snippet google/cloud/compute/region_disks/v1/samples/region_disks_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_region_health_check_services_v1::RegionHealthCheckServicesClient-universe-domain-snippet Override compute_region_health_check_services_v1::RegionHealthCheckServicesClient Universe Domain + +@snippet google/cloud/compute/region_health_check_services/v1/samples/region_health_check_services_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_region_health_checks_v1::RegionHealthChecksClient-universe-domain-snippet Override compute_region_health_checks_v1::RegionHealthChecksClient Universe Domain + +@snippet google/cloud/compute/region_health_checks/v1/samples/region_health_checks_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_region_instance_group_managers_v1::RegionInstanceGroupManagersClient-universe-domain-snippet Override compute_region_instance_group_managers_v1::RegionInstanceGroupManagersClient Universe Domain + +@snippet google/cloud/compute/region_instance_group_managers/v1/samples/region_instance_group_managers_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_region_instance_groups_v1::RegionInstanceGroupsClient-universe-domain-snippet Override compute_region_instance_groups_v1::RegionInstanceGroupsClient Universe Domain + +@snippet google/cloud/compute/region_instance_groups/v1/samples/region_instance_groups_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_region_instance_templates_v1::RegionInstanceTemplatesClient-universe-domain-snippet Override compute_region_instance_templates_v1::RegionInstanceTemplatesClient Universe Domain + +@snippet google/cloud/compute/region_instance_templates/v1/samples/region_instance_templates_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_region_instances_v1::RegionInstancesClient-universe-domain-snippet Override compute_region_instances_v1::RegionInstancesClient Universe Domain + +@snippet google/cloud/compute/region_instances/v1/samples/region_instances_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_region_instant_snapshots_v1::RegionInstantSnapshotsClient-universe-domain-snippet Override compute_region_instant_snapshots_v1::RegionInstantSnapshotsClient Universe Domain + +@snippet google/cloud/compute/region_instant_snapshots/v1/samples/region_instant_snapshots_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_region_network_endpoint_groups_v1::RegionNetworkEndpointGroupsClient-universe-domain-snippet Override compute_region_network_endpoint_groups_v1::RegionNetworkEndpointGroupsClient Universe Domain + +@snippet google/cloud/compute/region_network_endpoint_groups/v1/samples/region_network_endpoint_groups_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_region_network_firewall_policies_v1::RegionNetworkFirewallPoliciesClient-universe-domain-snippet Override compute_region_network_firewall_policies_v1::RegionNetworkFirewallPoliciesClient Universe Domain + +@snippet google/cloud/compute/region_network_firewall_policies/v1/samples/region_network_firewall_policies_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_region_notification_endpoints_v1::RegionNotificationEndpointsClient-universe-domain-snippet Override compute_region_notification_endpoints_v1::RegionNotificationEndpointsClient Universe Domain + +@snippet google/cloud/compute/region_notification_endpoints/v1/samples/region_notification_endpoints_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_region_operations_v1::RegionOperationsClient-universe-domain-snippet Override compute_region_operations_v1::RegionOperationsClient Universe Domain + +@snippet google/cloud/compute/region_operations/v1/samples/region_operations_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_region_security_policies_v1::RegionSecurityPoliciesClient-universe-domain-snippet Override compute_region_security_policies_v1::RegionSecurityPoliciesClient Universe Domain + +@snippet google/cloud/compute/region_security_policies/v1/samples/region_security_policies_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_region_ssl_certificates_v1::RegionSslCertificatesClient-universe-domain-snippet Override compute_region_ssl_certificates_v1::RegionSslCertificatesClient Universe Domain + +@snippet google/cloud/compute/region_ssl_certificates/v1/samples/region_ssl_certificates_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_region_ssl_policies_v1::RegionSslPoliciesClient-universe-domain-snippet Override compute_region_ssl_policies_v1::RegionSslPoliciesClient Universe Domain + +@snippet google/cloud/compute/region_ssl_policies/v1/samples/region_ssl_policies_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_region_target_http_proxies_v1::RegionTargetHttpProxiesClient-universe-domain-snippet Override compute_region_target_http_proxies_v1::RegionTargetHttpProxiesClient Universe Domain + +@snippet google/cloud/compute/region_target_http_proxies/v1/samples/region_target_http_proxies_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_region_target_https_proxies_v1::RegionTargetHttpsProxiesClient-universe-domain-snippet Override compute_region_target_https_proxies_v1::RegionTargetHttpsProxiesClient Universe Domain + +@snippet google/cloud/compute/region_target_https_proxies/v1/samples/region_target_https_proxies_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_region_target_tcp_proxies_v1::RegionTargetTcpProxiesClient-universe-domain-snippet Override compute_region_target_tcp_proxies_v1::RegionTargetTcpProxiesClient Universe Domain + +@snippet google/cloud/compute/region_target_tcp_proxies/v1/samples/region_target_tcp_proxies_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_region_url_maps_v1::RegionUrlMapsClient-universe-domain-snippet Override compute_region_url_maps_v1::RegionUrlMapsClient Universe Domain + +@snippet google/cloud/compute/region_url_maps/v1/samples/region_url_maps_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_region_zones_v1::RegionZonesClient-universe-domain-snippet Override compute_region_zones_v1::RegionZonesClient Universe Domain + +@snippet google/cloud/compute/region_zones/v1/samples/region_zones_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_regions_v1::RegionsClient-universe-domain-snippet Override compute_regions_v1::RegionsClient Universe Domain + +@snippet google/cloud/compute/regions/v1/samples/regions_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_reservation_blocks_v1::ReservationBlocksClient-universe-domain-snippet Override compute_reservation_blocks_v1::ReservationBlocksClient Universe Domain + +@snippet google/cloud/compute/reservation_blocks/v1/samples/reservation_blocks_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_reservation_sub_blocks_v1::ReservationSubBlocksClient-universe-domain-snippet Override compute_reservation_sub_blocks_v1::ReservationSubBlocksClient Universe Domain + +@snippet google/cloud/compute/reservation_sub_blocks/v1/samples/reservation_sub_blocks_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_reservations_v1::ReservationsClient-universe-domain-snippet Override compute_reservations_v1::ReservationsClient Universe Domain + +@snippet google/cloud/compute/reservations/v1/samples/reservations_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_resource_policies_v1::ResourcePoliciesClient-universe-domain-snippet Override compute_resource_policies_v1::ResourcePoliciesClient Universe Domain + +@snippet google/cloud/compute/resource_policies/v1/samples/resource_policies_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_routers_v1::RoutersClient-universe-domain-snippet Override compute_routers_v1::RoutersClient Universe Domain + +@snippet google/cloud/compute/routers/v1/samples/routers_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_routes_v1::RoutesClient-universe-domain-snippet Override compute_routes_v1::RoutesClient Universe Domain + +@snippet google/cloud/compute/routes/v1/samples/routes_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_security_policies_v1::SecurityPoliciesClient-universe-domain-snippet Override compute_security_policies_v1::SecurityPoliciesClient Universe Domain + +@snippet google/cloud/compute/security_policies/v1/samples/security_policies_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_service_attachments_v1::ServiceAttachmentsClient-universe-domain-snippet Override compute_service_attachments_v1::ServiceAttachmentsClient Universe Domain + +@snippet google/cloud/compute/service_attachments/v1/samples/service_attachments_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_snapshot_settings_v1::SnapshotSettingsClient-universe-domain-snippet Override compute_snapshot_settings_v1::SnapshotSettingsClient Universe Domain + +@snippet google/cloud/compute/snapshot_settings/v1/samples/snapshot_settings_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_snapshots_v1::SnapshotsClient-universe-domain-snippet Override compute_snapshots_v1::SnapshotsClient Universe Domain + +@snippet google/cloud/compute/snapshots/v1/samples/snapshots_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_ssl_certificates_v1::SslCertificatesClient-universe-domain-snippet Override compute_ssl_certificates_v1::SslCertificatesClient Universe Domain + +@snippet google/cloud/compute/ssl_certificates/v1/samples/ssl_certificates_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_ssl_policies_v1::SslPoliciesClient-universe-domain-snippet Override compute_ssl_policies_v1::SslPoliciesClient Universe Domain + +@snippet google/cloud/compute/ssl_policies/v1/samples/ssl_policies_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_storage_pool_types_v1::StoragePoolTypesClient-universe-domain-snippet Override compute_storage_pool_types_v1::StoragePoolTypesClient Universe Domain + +@snippet google/cloud/compute/storage_pool_types/v1/samples/storage_pool_types_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_storage_pools_v1::StoragePoolsClient-universe-domain-snippet Override compute_storage_pools_v1::StoragePoolsClient Universe Domain + +@snippet google/cloud/compute/storage_pools/v1/samples/storage_pools_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_subnetworks_v1::SubnetworksClient-universe-domain-snippet Override compute_subnetworks_v1::SubnetworksClient Universe Domain + +@snippet google/cloud/compute/subnetworks/v1/samples/subnetworks_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_target_grpc_proxies_v1::TargetGrpcProxiesClient-universe-domain-snippet Override compute_target_grpc_proxies_v1::TargetGrpcProxiesClient Universe Domain + +@snippet google/cloud/compute/target_grpc_proxies/v1/samples/target_grpc_proxies_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_target_http_proxies_v1::TargetHttpProxiesClient-universe-domain-snippet Override compute_target_http_proxies_v1::TargetHttpProxiesClient Universe Domain + +@snippet google/cloud/compute/target_http_proxies/v1/samples/target_http_proxies_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_target_https_proxies_v1::TargetHttpsProxiesClient-universe-domain-snippet Override compute_target_https_proxies_v1::TargetHttpsProxiesClient Universe Domain + +@snippet google/cloud/compute/target_https_proxies/v1/samples/target_https_proxies_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_target_instances_v1::TargetInstancesClient-universe-domain-snippet Override compute_target_instances_v1::TargetInstancesClient Universe Domain + +@snippet google/cloud/compute/target_instances/v1/samples/target_instances_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_target_pools_v1::TargetPoolsClient-universe-domain-snippet Override compute_target_pools_v1::TargetPoolsClient Universe Domain + +@snippet google/cloud/compute/target_pools/v1/samples/target_pools_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_target_ssl_proxies_v1::TargetSslProxiesClient-universe-domain-snippet Override compute_target_ssl_proxies_v1::TargetSslProxiesClient Universe Domain + +@snippet google/cloud/compute/target_ssl_proxies/v1/samples/target_ssl_proxies_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_target_tcp_proxies_v1::TargetTcpProxiesClient-universe-domain-snippet Override compute_target_tcp_proxies_v1::TargetTcpProxiesClient Universe Domain + +@snippet google/cloud/compute/target_tcp_proxies/v1/samples/target_tcp_proxies_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_target_vpn_gateways_v1::TargetVpnGatewaysClient-universe-domain-snippet Override compute_target_vpn_gateways_v1::TargetVpnGatewaysClient Universe Domain + +@snippet google/cloud/compute/target_vpn_gateways/v1/samples/target_vpn_gateways_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_url_maps_v1::UrlMapsClient-universe-domain-snippet Override compute_url_maps_v1::UrlMapsClient Universe Domain + +@snippet google/cloud/compute/url_maps/v1/samples/url_maps_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_vpn_gateways_v1::VpnGatewaysClient-universe-domain-snippet Override compute_vpn_gateways_v1::VpnGatewaysClient Universe Domain + +@snippet google/cloud/compute/vpn_gateways/v1/samples/vpn_gateways_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_vpn_tunnels_v1::VpnTunnelsClient-universe-domain-snippet Override compute_vpn_tunnels_v1::VpnTunnelsClient Universe Domain + +@snippet google/cloud/compute/vpn_tunnels/v1/samples/vpn_tunnels_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_zone_operations_v1::ZoneOperationsClient-universe-domain-snippet Override compute_zone_operations_v1::ZoneOperationsClient Universe Domain + +@snippet google/cloud/compute/zone_operations/v1/samples/zone_operations_client_samples.cc set-client-universe-domain + +*/ + +/*! @page compute_zones_v1::ZonesClient-universe-domain-snippet Override compute_zones_v1::ZonesClient Universe Domain + +@snippet google/cloud/compute/zones/v1/samples/zones_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/compute/external_vpn_gateways/v1/samples/external_vpn_gateways_client_samples.cc b/google/cloud/compute/external_vpn_gateways/v1/samples/external_vpn_gateways_client_samples.cc index fde6ec42329f6..2067be3d17a48 100644 --- a/google/cloud/compute/external_vpn_gateways/v1/samples/external_vpn_gateways_client_samples.cc +++ b/google/cloud/compute/external_vpn_gateways/v1/samples/external_vpn_gateways_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_external_vpn_gateways_v1:: + ExternalVpnGatewaysClient( + google::cloud::compute_external_vpn_gateways_v1:: + MakeExternalVpnGatewaysConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_external_vpn_gateways_v1:: @@ -201,6 +223,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -211,6 +236,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/firewall_policies/v1/samples/firewall_policies_client_samples.cc b/google/cloud/compute/firewall_policies/v1/samples/firewall_policies_client_samples.cc index 1af6c6e476bd0..ba909f69a21bc 100644 --- a/google/cloud/compute/firewall_policies/v1/samples/firewall_policies_client_samples.cc +++ b/google/cloud/compute/firewall_policies/v1/samples/firewall_policies_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_firewall_policies_v1::FirewallPoliciesClient( + google::cloud::compute_firewall_policies_v1:: + MakeFirewallPoliciesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_firewall_policies_v1:: @@ -198,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -208,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/firewalls/v1/samples/firewalls_client_samples.cc b/google/cloud/compute/firewalls/v1/samples/firewalls_client_samples.cc index 5853a92cc5441..9418854ffd836 100644 --- a/google/cloud/compute/firewalls/v1/samples/firewalls_client_samples.cc +++ b/google/cloud/compute/firewalls/v1/samples/firewalls_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_firewalls_v1::FirewallsClient( + google::cloud::compute_firewalls_v1::MakeFirewallsConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_firewalls_v1:: FirewallsConnectionIdempotencyPolicy { @@ -190,6 +211,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -200,6 +224,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/forwarding_rules/v1/samples/forwarding_rules_client_samples.cc b/google/cloud/compute/forwarding_rules/v1/samples/forwarding_rules_client_samples.cc index 75c8198a03cd1..2f99e59bea7b4 100644 --- a/google/cloud/compute/forwarding_rules/v1/samples/forwarding_rules_client_samples.cc +++ b/google/cloud/compute/forwarding_rules/v1/samples/forwarding_rules_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_forwarding_rules_v1::ForwardingRulesClient( + google::cloud::compute_forwarding_rules_v1:: + MakeForwardingRulesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_forwarding_rules_v1:: @@ -197,6 +219,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -207,6 +232,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/global_addresses/v1/samples/global_addresses_client_samples.cc b/google/cloud/compute/global_addresses/v1/samples/global_addresses_client_samples.cc index b7ce5e47dc626..77287922589a9 100644 --- a/google/cloud/compute/global_addresses/v1/samples/global_addresses_client_samples.cc +++ b/google/cloud/compute/global_addresses/v1/samples/global_addresses_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_global_addresses_v1::GlobalAddressesClient( + google::cloud::compute_global_addresses_v1:: + MakeGlobalAddressesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_global_addresses_v1:: @@ -197,6 +219,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -207,6 +232,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/global_forwarding_rules/v1/samples/global_forwarding_rules_client_samples.cc b/google/cloud/compute/global_forwarding_rules/v1/samples/global_forwarding_rules_client_samples.cc index 2159974fc79a0..ff1cbd46aa1c0 100644 --- a/google/cloud/compute/global_forwarding_rules/v1/samples/global_forwarding_rules_client_samples.cc +++ b/google/cloud/compute/global_forwarding_rules/v1/samples/global_forwarding_rules_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_global_forwarding_rules_v1:: + GlobalForwardingRulesClient( + google::cloud::compute_global_forwarding_rules_v1:: + MakeGlobalForwardingRulesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_global_forwarding_rules_v1:: @@ -202,6 +224,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -212,6 +237,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/global_network_endpoint_groups/v1/samples/global_network_endpoint_groups_client_samples.cc b/google/cloud/compute/global_network_endpoint_groups/v1/samples/global_network_endpoint_groups_client_samples.cc index ed15af832bffd..4e676a991c75e 100644 --- a/google/cloud/compute/global_network_endpoint_groups/v1/samples/global_network_endpoint_groups_client_samples.cc +++ b/google/cloud/compute/global_network_endpoint_groups/v1/samples/global_network_endpoint_groups_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_global_network_endpoint_groups_v1:: + GlobalNetworkEndpointGroupsClient( + google::cloud::compute_global_network_endpoint_groups_v1:: + MakeGlobalNetworkEndpointGroupsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_global_network_endpoint_groups_v1:: @@ -203,6 +225,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -213,6 +238,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/global_operations/v1/samples/global_operations_client_samples.cc b/google/cloud/compute/global_operations/v1/samples/global_operations_client_samples.cc index 33a91743e8c95..e8cd3ffd6e10a 100644 --- a/google/cloud/compute/global_operations/v1/samples/global_operations_client_samples.cc +++ b/google/cloud/compute/global_operations/v1/samples/global_operations_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_global_operations_v1::GlobalOperationsClient( + google::cloud::compute_global_operations_v1:: + MakeGlobalOperationsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_global_operations_v1:: @@ -150,6 +172,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -159,6 +184,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/global_organization_operations/v1/samples/global_organization_operations_client_samples.cc b/google/cloud/compute/global_organization_operations/v1/samples/global_organization_operations_client_samples.cc index a5424a917072d..6bf2fd11f25a3 100644 --- a/google/cloud/compute/global_organization_operations/v1/samples/global_organization_operations_client_samples.cc +++ b/google/cloud/compute/global_organization_operations/v1/samples/global_organization_operations_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_global_organization_operations_v1:: + GlobalOrganizationOperationsClient( + google::cloud::compute_global_organization_operations_v1:: + MakeGlobalOrganizationOperationsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_global_organization_operations_v1:: @@ -155,6 +177,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -164,6 +189,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/global_public_delegated_prefixes/v1/samples/global_public_delegated_prefixes_client_samples.cc b/google/cloud/compute/global_public_delegated_prefixes/v1/samples/global_public_delegated_prefixes_client_samples.cc index 29604cbec70eb..2a3a82137ea2e 100644 --- a/google/cloud/compute/global_public_delegated_prefixes/v1/samples/global_public_delegated_prefixes_client_samples.cc +++ b/google/cloud/compute/global_public_delegated_prefixes/v1/samples/global_public_delegated_prefixes_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_global_public_delegated_prefixes_v1:: + GlobalPublicDelegatedPrefixesClient( + google::cloud::compute_global_public_delegated_prefixes_v1:: + MakeGlobalPublicDelegatedPrefixesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_global_public_delegated_prefixes_v1:: @@ -203,6 +225,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -213,6 +238,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/health_checks/v1/samples/health_checks_client_samples.cc b/google/cloud/compute/health_checks/v1/samples/health_checks_client_samples.cc index 91214170a7bf7..e44f5c4ff41b4 100644 --- a/google/cloud/compute/health_checks/v1/samples/health_checks_client_samples.cc +++ b/google/cloud/compute/health_checks/v1/samples/health_checks_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_health_checks_v1::HealthChecksClient( + google::cloud::compute_health_checks_v1::MakeHealthChecksConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_health_checks_v1:: HealthChecksConnectionIdempotencyPolicy { @@ -197,6 +218,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -207,6 +231,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/http_health_checks/v1/samples/http_health_checks_client_samples.cc b/google/cloud/compute/http_health_checks/v1/samples/http_health_checks_client_samples.cc index bc2d93e12a4df..3756c4becefd7 100644 --- a/google/cloud/compute/http_health_checks/v1/samples/http_health_checks_client_samples.cc +++ b/google/cloud/compute/http_health_checks/v1/samples/http_health_checks_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_http_health_checks_v1::HttpHealthChecksClient( + google::cloud::compute_http_health_checks_v1:: + MakeHttpHealthChecksConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_http_health_checks_v1:: @@ -203,6 +225,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -213,6 +238,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/https_health_checks/v1/samples/https_health_checks_client_samples.cc b/google/cloud/compute/https_health_checks/v1/samples/https_health_checks_client_samples.cc index b6ac55af36a92..4ec10cd2b077b 100644 --- a/google/cloud/compute/https_health_checks/v1/samples/https_health_checks_client_samples.cc +++ b/google/cloud/compute/https_health_checks/v1/samples/https_health_checks_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_https_health_checks_v1::HttpsHealthChecksClient( + google::cloud::compute_https_health_checks_v1:: + MakeHttpsHealthChecksConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_https_health_checks_v1:: @@ -204,6 +226,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -214,6 +239,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/image_family_views/v1/samples/image_family_views_client_samples.cc b/google/cloud/compute/image_family_views/v1/samples/image_family_views_client_samples.cc index 078ada243a204..d1c7cc5035345 100644 --- a/google/cloud/compute/image_family_views/v1/samples/image_family_views_client_samples.cc +++ b/google/cloud/compute/image_family_views/v1/samples/image_family_views_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_image_family_views_v1::ImageFamilyViewsClient( + google::cloud::compute_image_family_views_v1:: + MakeImageFamilyViewsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_image_family_views_v1:: @@ -153,6 +175,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -162,6 +187,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/images/v1/samples/images_client_samples.cc b/google/cloud/compute/images/v1/samples/images_client_samples.cc index 0c2435bad8b4b..7e2cd009c2514 100644 --- a/google/cloud/compute/images/v1/samples/images_client_samples.cc +++ b/google/cloud/compute/images/v1/samples/images_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_images_v1::ImagesClient( + google::cloud::compute_images_v1::MakeImagesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_images_v1:: ImagesConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/instance_group_manager_resize_requests/v1/samples/instance_group_manager_resize_requests_client_samples.cc b/google/cloud/compute/instance_group_manager_resize_requests/v1/samples/instance_group_manager_resize_requests_client_samples.cc index 1740837dc2f42..7368739edc6a9 100644 --- a/google/cloud/compute/instance_group_manager_resize_requests/v1/samples/instance_group_manager_resize_requests_client_samples.cc +++ b/google/cloud/compute/instance_group_manager_resize_requests/v1/samples/instance_group_manager_resize_requests_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -54,6 +55,29 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_instance_group_manager_resize_requests_v1:: + InstanceGroupManagerResizeRequestsClient( + google::cloud::compute_instance_group_manager_resize_requests_v1:: + MakeInstanceGroupManagerResizeRequestsConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_instance_group_manager_resize_requests_v1:: @@ -219,6 +243,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -229,6 +256,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/instance_group_managers/v1/samples/instance_group_managers_client_samples.cc b/google/cloud/compute/instance_group_managers/v1/samples/instance_group_managers_client_samples.cc index b5679a90ac372..f169562ae1875 100644 --- a/google/cloud/compute/instance_group_managers/v1/samples/instance_group_managers_client_samples.cc +++ b/google/cloud/compute/instance_group_managers/v1/samples/instance_group_managers_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_instance_group_managers_v1:: + InstanceGroupManagersClient( + google::cloud::compute_instance_group_managers_v1:: + MakeInstanceGroupManagersConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_instance_group_managers_v1:: @@ -202,6 +224,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -212,6 +237,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/instance_groups/v1/samples/instance_groups_client_samples.cc b/google/cloud/compute/instance_groups/v1/samples/instance_groups_client_samples.cc index ec300748d4bfe..1f74dd25824e6 100644 --- a/google/cloud/compute/instance_groups/v1/samples/instance_groups_client_samples.cc +++ b/google/cloud/compute/instance_groups/v1/samples/instance_groups_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_instance_groups_v1::InstanceGroupsClient( + google::cloud::compute_instance_groups_v1:: + MakeInstanceGroupsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_instance_groups_v1:: @@ -197,6 +219,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -207,6 +232,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/instance_settings/v1/samples/instance_settings_client_samples.cc b/google/cloud/compute/instance_settings/v1/samples/instance_settings_client_samples.cc index 1f84ee29a3c5f..231f82dfc427f 100644 --- a/google/cloud/compute/instance_settings/v1/samples/instance_settings_client_samples.cc +++ b/google/cloud/compute/instance_settings/v1/samples/instance_settings_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_instance_settings_v1::InstanceSettingsClient( + google::cloud::compute_instance_settings_v1:: + MakeInstanceSettingsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_instance_settings_v1:: @@ -198,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -208,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/instance_templates/v1/samples/instance_templates_client_samples.cc b/google/cloud/compute/instance_templates/v1/samples/instance_templates_client_samples.cc index 30b940c4f2681..f76861bf53f85 100644 --- a/google/cloud/compute/instance_templates/v1/samples/instance_templates_client_samples.cc +++ b/google/cloud/compute/instance_templates/v1/samples/instance_templates_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_instance_templates_v1::InstanceTemplatesClient( + google::cloud::compute_instance_templates_v1:: + MakeInstanceTemplatesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_instance_templates_v1:: @@ -204,6 +226,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -214,6 +239,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/instances/v1/samples/instances_client_samples.cc b/google/cloud/compute/instances/v1/samples/instances_client_samples.cc index 09fbe73f52f0a..623993c7e0175 100644 --- a/google/cloud/compute/instances/v1/samples/instances_client_samples.cc +++ b/google/cloud/compute/instances/v1/samples/instances_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_instances_v1::InstancesClient( + google::cloud::compute_instances_v1::MakeInstancesConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_instances_v1:: InstancesConnectionIdempotencyPolicy { @@ -190,6 +211,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -200,6 +224,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/instant_snapshots/v1/samples/instant_snapshots_client_samples.cc b/google/cloud/compute/instant_snapshots/v1/samples/instant_snapshots_client_samples.cc index 07ee81dd62232..35257b4d098b4 100644 --- a/google/cloud/compute/instant_snapshots/v1/samples/instant_snapshots_client_samples.cc +++ b/google/cloud/compute/instant_snapshots/v1/samples/instant_snapshots_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_instant_snapshots_v1::InstantSnapshotsClient( + google::cloud::compute_instant_snapshots_v1:: + MakeInstantSnapshotsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_instant_snapshots_v1:: @@ -198,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -208,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/interconnect_attachment_groups/v1/samples/interconnect_attachment_groups_client_samples.cc b/google/cloud/compute/interconnect_attachment_groups/v1/samples/interconnect_attachment_groups_client_samples.cc index bfd45b1f04883..f75bc643ab3b8 100644 --- a/google/cloud/compute/interconnect_attachment_groups/v1/samples/interconnect_attachment_groups_client_samples.cc +++ b/google/cloud/compute/interconnect_attachment_groups/v1/samples/interconnect_attachment_groups_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_interconnect_attachment_groups_v1:: + InterconnectAttachmentGroupsClient( + google::cloud::compute_interconnect_attachment_groups_v1:: + MakeInterconnectAttachmentGroupsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_interconnect_attachment_groups_v1:: @@ -203,6 +225,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -213,6 +238,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/interconnect_attachments/v1/samples/interconnect_attachments_client_samples.cc b/google/cloud/compute/interconnect_attachments/v1/samples/interconnect_attachments_client_samples.cc index de4cd592ef67c..6942a01877ce3 100644 --- a/google/cloud/compute/interconnect_attachments/v1/samples/interconnect_attachments_client_samples.cc +++ b/google/cloud/compute/interconnect_attachments/v1/samples/interconnect_attachments_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_interconnect_attachments_v1:: + InterconnectAttachmentsClient( + google::cloud::compute_interconnect_attachments_v1:: + MakeInterconnectAttachmentsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_interconnect_attachments_v1:: @@ -202,6 +224,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -212,6 +237,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/interconnect_groups/v1/samples/interconnect_groups_client_samples.cc b/google/cloud/compute/interconnect_groups/v1/samples/interconnect_groups_client_samples.cc index bc759d5df59e3..b52d38e020eda 100644 --- a/google/cloud/compute/interconnect_groups/v1/samples/interconnect_groups_client_samples.cc +++ b/google/cloud/compute/interconnect_groups/v1/samples/interconnect_groups_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_interconnect_groups_v1::InterconnectGroupsClient( + google::cloud::compute_interconnect_groups_v1:: + MakeInterconnectGroupsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_interconnect_groups_v1:: @@ -204,6 +226,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -214,6 +239,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/interconnect_locations/v1/samples/interconnect_locations_client_samples.cc b/google/cloud/compute/interconnect_locations/v1/samples/interconnect_locations_client_samples.cc index 32c1aead690e6..4e1bb7615d989 100644 --- a/google/cloud/compute/interconnect_locations/v1/samples/interconnect_locations_client_samples.cc +++ b/google/cloud/compute/interconnect_locations/v1/samples/interconnect_locations_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_interconnect_locations_v1:: + InterconnectLocationsClient( + google::cloud::compute_interconnect_locations_v1:: + MakeInterconnectLocationsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_interconnect_locations_v1:: @@ -154,6 +176,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -163,6 +188,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/interconnect_remote_locations/v1/samples/interconnect_remote_locations_client_samples.cc b/google/cloud/compute/interconnect_remote_locations/v1/samples/interconnect_remote_locations_client_samples.cc index 0773c8d6a460d..b99bfbd0b0fec 100644 --- a/google/cloud/compute/interconnect_remote_locations/v1/samples/interconnect_remote_locations_client_samples.cc +++ b/google/cloud/compute/interconnect_remote_locations/v1/samples/interconnect_remote_locations_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_interconnect_remote_locations_v1:: + InterconnectRemoteLocationsClient( + google::cloud::compute_interconnect_remote_locations_v1:: + MakeInterconnectRemoteLocationsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_interconnect_remote_locations_v1:: @@ -155,6 +177,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -164,6 +189,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/interconnects/v1/samples/interconnects_client_samples.cc b/google/cloud/compute/interconnects/v1/samples/interconnects_client_samples.cc index f3ff3cea8bd11..08560f30a05f4 100644 --- a/google/cloud/compute/interconnects/v1/samples/interconnects_client_samples.cc +++ b/google/cloud/compute/interconnects/v1/samples/interconnects_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_interconnects_v1::InterconnectsClient( + google::cloud::compute_interconnects_v1::MakeInterconnectsConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_interconnects_v1:: InterconnectsConnectionIdempotencyPolicy { @@ -198,6 +219,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -208,6 +232,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/license_codes/v1/samples/license_codes_client_samples.cc b/google/cloud/compute/license_codes/v1/samples/license_codes_client_samples.cc index eced0fe9a5edd..8e98a27004edd 100644 --- a/google/cloud/compute/license_codes/v1/samples/license_codes_client_samples.cc +++ b/google/cloud/compute/license_codes/v1/samples/license_codes_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_license_codes_v1::LicenseCodesClient( + google::cloud::compute_license_codes_v1::MakeLicenseCodesConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_license_codes_v1:: LicenseCodesConnectionIdempotencyPolicy { @@ -148,6 +169,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -157,6 +181,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/licenses/v1/samples/licenses_client_samples.cc b/google/cloud/compute/licenses/v1/samples/licenses_client_samples.cc index 7b4c10205bb69..6d641b3864ffa 100644 --- a/google/cloud/compute/licenses/v1/samples/licenses_client_samples.cc +++ b/google/cloud/compute/licenses/v1/samples/licenses_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_licenses_v1::LicensesClient( + google::cloud::compute_licenses_v1::MakeLicensesConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_licenses_v1:: LicensesConnectionIdempotencyPolicy { @@ -187,6 +208,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -197,6 +221,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/machine_images/v1/samples/machine_images_client_samples.cc b/google/cloud/compute/machine_images/v1/samples/machine_images_client_samples.cc index 310e5b89f356e..36ab4ccdc1cf4 100644 --- a/google/cloud/compute/machine_images/v1/samples/machine_images_client_samples.cc +++ b/google/cloud/compute/machine_images/v1/samples/machine_images_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_machine_images_v1::MachineImagesClient( + google::cloud::compute_machine_images_v1:: + MakeMachineImagesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_machine_images_v1:: @@ -199,6 +221,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -209,6 +234,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/machine_types/v1/samples/machine_types_client_samples.cc b/google/cloud/compute/machine_types/v1/samples/machine_types_client_samples.cc index 012dadc17362f..780d1c8e4b52e 100644 --- a/google/cloud/compute/machine_types/v1/samples/machine_types_client_samples.cc +++ b/google/cloud/compute/machine_types/v1/samples/machine_types_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_machine_types_v1::MachineTypesClient( + google::cloud::compute_machine_types_v1::MakeMachineTypesConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_machine_types_v1:: MachineTypesConnectionIdempotencyPolicy { @@ -148,6 +169,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -157,6 +181,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/network_attachments/v1/samples/network_attachments_client_samples.cc b/google/cloud/compute/network_attachments/v1/samples/network_attachments_client_samples.cc index 08f5ff079efe6..33697170c12a5 100644 --- a/google/cloud/compute/network_attachments/v1/samples/network_attachments_client_samples.cc +++ b/google/cloud/compute/network_attachments/v1/samples/network_attachments_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_network_attachments_v1::NetworkAttachmentsClient( + google::cloud::compute_network_attachments_v1:: + MakeNetworkAttachmentsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_network_attachments_v1:: @@ -204,6 +226,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -214,6 +239,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/network_edge_security_services/v1/samples/network_edge_security_services_client_samples.cc b/google/cloud/compute/network_edge_security_services/v1/samples/network_edge_security_services_client_samples.cc index ecc39f3e9394e..13acc8a30819e 100644 --- a/google/cloud/compute/network_edge_security_services/v1/samples/network_edge_security_services_client_samples.cc +++ b/google/cloud/compute/network_edge_security_services/v1/samples/network_edge_security_services_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_network_edge_security_services_v1:: + NetworkEdgeSecurityServicesClient( + google::cloud::compute_network_edge_security_services_v1:: + MakeNetworkEdgeSecurityServicesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_network_edge_security_services_v1:: @@ -203,6 +225,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -213,6 +238,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/network_endpoint_groups/v1/samples/network_endpoint_groups_client_samples.cc b/google/cloud/compute/network_endpoint_groups/v1/samples/network_endpoint_groups_client_samples.cc index 04bf3edaa8ae7..37001238ad0e1 100644 --- a/google/cloud/compute/network_endpoint_groups/v1/samples/network_endpoint_groups_client_samples.cc +++ b/google/cloud/compute/network_endpoint_groups/v1/samples/network_endpoint_groups_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_network_endpoint_groups_v1:: + NetworkEndpointGroupsClient( + google::cloud::compute_network_endpoint_groups_v1:: + MakeNetworkEndpointGroupsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_network_endpoint_groups_v1:: @@ -202,6 +224,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -212,6 +237,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/network_firewall_policies/v1/samples/network_firewall_policies_client_samples.cc b/google/cloud/compute/network_firewall_policies/v1/samples/network_firewall_policies_client_samples.cc index 915ec4aff208e..a5f946f262c17 100644 --- a/google/cloud/compute/network_firewall_policies/v1/samples/network_firewall_policies_client_samples.cc +++ b/google/cloud/compute/network_firewall_policies/v1/samples/network_firewall_policies_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_network_firewall_policies_v1:: + NetworkFirewallPoliciesClient( + google::cloud::compute_network_firewall_policies_v1:: + MakeNetworkFirewallPoliciesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_network_firewall_policies_v1:: @@ -202,6 +224,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -212,6 +237,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/network_profiles/v1/samples/network_profiles_client_samples.cc b/google/cloud/compute/network_profiles/v1/samples/network_profiles_client_samples.cc index 9cadc6f946de5..522e6d368d503 100644 --- a/google/cloud/compute/network_profiles/v1/samples/network_profiles_client_samples.cc +++ b/google/cloud/compute/network_profiles/v1/samples/network_profiles_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_network_profiles_v1::NetworkProfilesClient( + google::cloud::compute_network_profiles_v1:: + MakeNetworkProfilesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_network_profiles_v1:: @@ -149,6 +171,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -158,6 +183,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/networks/v1/samples/networks_client_samples.cc b/google/cloud/compute/networks/v1/samples/networks_client_samples.cc index 09c61b745cda9..4a0daa0099679 100644 --- a/google/cloud/compute/networks/v1/samples/networks_client_samples.cc +++ b/google/cloud/compute/networks/v1/samples/networks_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_networks_v1::NetworksClient( + google::cloud::compute_networks_v1::MakeNetworksConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_networks_v1:: NetworksConnectionIdempotencyPolicy { @@ -187,6 +208,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -197,6 +221,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/node_groups/v1/samples/node_groups_client_samples.cc b/google/cloud/compute/node_groups/v1/samples/node_groups_client_samples.cc index 11030367fd687..68c00577b5987 100644 --- a/google/cloud/compute/node_groups/v1/samples/node_groups_client_samples.cc +++ b/google/cloud/compute/node_groups/v1/samples/node_groups_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_node_groups_v1::NodeGroupsClient( + google::cloud::compute_node_groups_v1::MakeNodeGroupsConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_node_groups_v1:: NodeGroupsConnectionIdempotencyPolicy { @@ -193,6 +214,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -203,6 +227,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/node_templates/v1/samples/node_templates_client_samples.cc b/google/cloud/compute/node_templates/v1/samples/node_templates_client_samples.cc index b306f99f323cb..1e95dfc4f643e 100644 --- a/google/cloud/compute/node_templates/v1/samples/node_templates_client_samples.cc +++ b/google/cloud/compute/node_templates/v1/samples/node_templates_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_node_templates_v1::NodeTemplatesClient( + google::cloud::compute_node_templates_v1:: + MakeNodeTemplatesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_node_templates_v1:: @@ -199,6 +221,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -209,6 +234,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/node_types/v1/samples/node_types_client_samples.cc b/google/cloud/compute/node_types/v1/samples/node_types_client_samples.cc index 71a11acfe6693..cf832f75270a2 100644 --- a/google/cloud/compute/node_types/v1/samples/node_types_client_samples.cc +++ b/google/cloud/compute/node_types/v1/samples/node_types_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_node_types_v1::NodeTypesClient( + google::cloud::compute_node_types_v1::MakeNodeTypesConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_node_types_v1:: NodeTypesConnectionIdempotencyPolicy { @@ -147,6 +168,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -156,6 +180,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/packet_mirrorings/v1/samples/packet_mirrorings_client_samples.cc b/google/cloud/compute/packet_mirrorings/v1/samples/packet_mirrorings_client_samples.cc index fea35c2d2f5ce..86e51d76ba3f1 100644 --- a/google/cloud/compute/packet_mirrorings/v1/samples/packet_mirrorings_client_samples.cc +++ b/google/cloud/compute/packet_mirrorings/v1/samples/packet_mirrorings_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_packet_mirrorings_v1::PacketMirroringsClient( + google::cloud::compute_packet_mirrorings_v1:: + MakePacketMirroringsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_packet_mirrorings_v1:: @@ -198,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -208,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/projects/v1/samples/projects_client_samples.cc b/google/cloud/compute/projects/v1/samples/projects_client_samples.cc index 6f9ad26d0c822..881ddeb9832e4 100644 --- a/google/cloud/compute/projects/v1/samples/projects_client_samples.cc +++ b/google/cloud/compute/projects/v1/samples/projects_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_projects_v1::ProjectsClient( + google::cloud::compute_projects_v1::MakeProjectsConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_projects_v1:: ProjectsConnectionIdempotencyPolicy { @@ -187,6 +208,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -197,6 +221,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/public_advertised_prefixes/v1/samples/public_advertised_prefixes_client_samples.cc b/google/cloud/compute/public_advertised_prefixes/v1/samples/public_advertised_prefixes_client_samples.cc index d93da619bd9fd..e2415ee4b90d9 100644 --- a/google/cloud/compute/public_advertised_prefixes/v1/samples/public_advertised_prefixes_client_samples.cc +++ b/google/cloud/compute/public_advertised_prefixes/v1/samples/public_advertised_prefixes_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_public_advertised_prefixes_v1:: + PublicAdvertisedPrefixesClient( + google::cloud::compute_public_advertised_prefixes_v1:: + MakePublicAdvertisedPrefixesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_public_advertised_prefixes_v1:: @@ -202,6 +224,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -212,6 +237,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/public_delegated_prefixes/v1/samples/public_delegated_prefixes_client_samples.cc b/google/cloud/compute/public_delegated_prefixes/v1/samples/public_delegated_prefixes_client_samples.cc index c82b6bb3677f4..fe21974e31c2c 100644 --- a/google/cloud/compute/public_delegated_prefixes/v1/samples/public_delegated_prefixes_client_samples.cc +++ b/google/cloud/compute/public_delegated_prefixes/v1/samples/public_delegated_prefixes_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_public_delegated_prefixes_v1:: + PublicDelegatedPrefixesClient( + google::cloud::compute_public_delegated_prefixes_v1:: + MakePublicDelegatedPrefixesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_public_delegated_prefixes_v1:: @@ -202,6 +224,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -212,6 +237,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/region_autoscalers/v1/samples/region_autoscalers_client_samples.cc b/google/cloud/compute/region_autoscalers/v1/samples/region_autoscalers_client_samples.cc index bbadfe7053a4e..38363795dafb0 100644 --- a/google/cloud/compute/region_autoscalers/v1/samples/region_autoscalers_client_samples.cc +++ b/google/cloud/compute/region_autoscalers/v1/samples/region_autoscalers_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_region_autoscalers_v1::RegionAutoscalersClient( + google::cloud::compute_region_autoscalers_v1:: + MakeRegionAutoscalersConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_region_autoscalers_v1:: @@ -204,6 +226,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -214,6 +239,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/region_backend_services/v1/samples/region_backend_services_client_samples.cc b/google/cloud/compute/region_backend_services/v1/samples/region_backend_services_client_samples.cc index 2d1055a789daa..08ec08eaea8a0 100644 --- a/google/cloud/compute/region_backend_services/v1/samples/region_backend_services_client_samples.cc +++ b/google/cloud/compute/region_backend_services/v1/samples/region_backend_services_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_region_backend_services_v1:: + RegionBackendServicesClient( + google::cloud::compute_region_backend_services_v1:: + MakeRegionBackendServicesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_region_backend_services_v1:: @@ -202,6 +224,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -212,6 +237,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/region_commitments/v1/samples/region_commitments_client_samples.cc b/google/cloud/compute/region_commitments/v1/samples/region_commitments_client_samples.cc index 7ece45997bac9..a83b75dd541dc 100644 --- a/google/cloud/compute/region_commitments/v1/samples/region_commitments_client_samples.cc +++ b/google/cloud/compute/region_commitments/v1/samples/region_commitments_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_region_commitments_v1::RegionCommitmentsClient( + google::cloud::compute_region_commitments_v1:: + MakeRegionCommitmentsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_region_commitments_v1:: @@ -204,6 +226,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -214,6 +239,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/region_disk_types/v1/samples/region_disk_types_client_samples.cc b/google/cloud/compute/region_disk_types/v1/samples/region_disk_types_client_samples.cc index 6e63b3eb13428..6791711d5e60e 100644 --- a/google/cloud/compute/region_disk_types/v1/samples/region_disk_types_client_samples.cc +++ b/google/cloud/compute/region_disk_types/v1/samples/region_disk_types_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_region_disk_types_v1::RegionDiskTypesClient( + google::cloud::compute_region_disk_types_v1:: + MakeRegionDiskTypesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_region_disk_types_v1:: @@ -149,6 +171,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -158,6 +183,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/region_disks/v1/samples/region_disks_client_samples.cc b/google/cloud/compute/region_disks/v1/samples/region_disks_client_samples.cc index b4202ec1c3e06..2409a9fc5577f 100644 --- a/google/cloud/compute/region_disks/v1/samples/region_disks_client_samples.cc +++ b/google/cloud/compute/region_disks/v1/samples/region_disks_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_region_disks_v1::RegionDisksClient( + google::cloud::compute_region_disks_v1::MakeRegionDisksConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_region_disks_v1:: RegionDisksConnectionIdempotencyPolicy { @@ -197,6 +218,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -207,6 +231,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/region_health_check_services/v1/samples/region_health_check_services_client_samples.cc b/google/cloud/compute/region_health_check_services/v1/samples/region_health_check_services_client_samples.cc index 55e1b60425615..5e61c56d02b96 100644 --- a/google/cloud/compute/region_health_check_services/v1/samples/region_health_check_services_client_samples.cc +++ b/google/cloud/compute/region_health_check_services/v1/samples/region_health_check_services_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_region_health_check_services_v1:: + RegionHealthCheckServicesClient( + google::cloud::compute_region_health_check_services_v1:: + MakeRegionHealthCheckServicesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_region_health_check_services_v1:: @@ -202,6 +224,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -212,6 +237,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/region_health_checks/v1/samples/region_health_checks_client_samples.cc b/google/cloud/compute/region_health_checks/v1/samples/region_health_checks_client_samples.cc index 3c40ae5c8fc97..efa5063ed2973 100644 --- a/google/cloud/compute/region_health_checks/v1/samples/region_health_checks_client_samples.cc +++ b/google/cloud/compute/region_health_checks/v1/samples/region_health_checks_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_region_health_checks_v1::RegionHealthChecksClient( + google::cloud::compute_region_health_checks_v1:: + MakeRegionHealthChecksConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_region_health_checks_v1:: @@ -205,6 +227,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -215,6 +240,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/region_instance_group_managers/v1/samples/region_instance_group_managers_client_samples.cc b/google/cloud/compute/region_instance_group_managers/v1/samples/region_instance_group_managers_client_samples.cc index 008a6b490e734..b980d95c5ba46 100644 --- a/google/cloud/compute/region_instance_group_managers/v1/samples/region_instance_group_managers_client_samples.cc +++ b/google/cloud/compute/region_instance_group_managers/v1/samples/region_instance_group_managers_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_region_instance_group_managers_v1:: + RegionInstanceGroupManagersClient( + google::cloud::compute_region_instance_group_managers_v1:: + MakeRegionInstanceGroupManagersConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_region_instance_group_managers_v1:: @@ -203,6 +225,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -213,6 +238,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/region_instance_groups/v1/samples/region_instance_groups_client_samples.cc b/google/cloud/compute/region_instance_groups/v1/samples/region_instance_groups_client_samples.cc index dab12985fb090..636e6a3ac1a78 100644 --- a/google/cloud/compute/region_instance_groups/v1/samples/region_instance_groups_client_samples.cc +++ b/google/cloud/compute/region_instance_groups/v1/samples/region_instance_groups_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_region_instance_groups_v1:: + RegionInstanceGroupsClient( + google::cloud::compute_region_instance_groups_v1:: + MakeRegionInstanceGroupsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_region_instance_groups_v1:: @@ -202,6 +224,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -212,6 +237,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/region_instance_templates/v1/samples/region_instance_templates_client_samples.cc b/google/cloud/compute/region_instance_templates/v1/samples/region_instance_templates_client_samples.cc index 7b71190010c0a..1924598f9698b 100644 --- a/google/cloud/compute/region_instance_templates/v1/samples/region_instance_templates_client_samples.cc +++ b/google/cloud/compute/region_instance_templates/v1/samples/region_instance_templates_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_region_instance_templates_v1:: + RegionInstanceTemplatesClient( + google::cloud::compute_region_instance_templates_v1:: + MakeRegionInstanceTemplatesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_region_instance_templates_v1:: @@ -202,6 +224,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -212,6 +237,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/region_instances/v1/samples/region_instances_client_samples.cc b/google/cloud/compute/region_instances/v1/samples/region_instances_client_samples.cc index 9a12588ca18da..3f3ffcf7e48d0 100644 --- a/google/cloud/compute/region_instances/v1/samples/region_instances_client_samples.cc +++ b/google/cloud/compute/region_instances/v1/samples/region_instances_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_region_instances_v1::RegionInstancesClient( + google::cloud::compute_region_instances_v1:: + MakeRegionInstancesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_region_instances_v1:: @@ -197,6 +219,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -207,6 +232,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/region_instant_snapshots/v1/samples/region_instant_snapshots_client_samples.cc b/google/cloud/compute/region_instant_snapshots/v1/samples/region_instant_snapshots_client_samples.cc index 696eeac689f21..fff8b2621f856 100644 --- a/google/cloud/compute/region_instant_snapshots/v1/samples/region_instant_snapshots_client_samples.cc +++ b/google/cloud/compute/region_instant_snapshots/v1/samples/region_instant_snapshots_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_region_instant_snapshots_v1:: + RegionInstantSnapshotsClient( + google::cloud::compute_region_instant_snapshots_v1:: + MakeRegionInstantSnapshotsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_region_instant_snapshots_v1:: @@ -202,6 +224,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -212,6 +237,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/region_network_endpoint_groups/v1/samples/region_network_endpoint_groups_client_samples.cc b/google/cloud/compute/region_network_endpoint_groups/v1/samples/region_network_endpoint_groups_client_samples.cc index 1433c415c7d01..d906c12918872 100644 --- a/google/cloud/compute/region_network_endpoint_groups/v1/samples/region_network_endpoint_groups_client_samples.cc +++ b/google/cloud/compute/region_network_endpoint_groups/v1/samples/region_network_endpoint_groups_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_region_network_endpoint_groups_v1:: + RegionNetworkEndpointGroupsClient( + google::cloud::compute_region_network_endpoint_groups_v1:: + MakeRegionNetworkEndpointGroupsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_region_network_endpoint_groups_v1:: @@ -203,6 +225,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -213,6 +238,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/region_network_firewall_policies/v1/samples/region_network_firewall_policies_client_samples.cc b/google/cloud/compute/region_network_firewall_policies/v1/samples/region_network_firewall_policies_client_samples.cc index 43c0bf185780b..911743745ca90 100644 --- a/google/cloud/compute/region_network_firewall_policies/v1/samples/region_network_firewall_policies_client_samples.cc +++ b/google/cloud/compute/region_network_firewall_policies/v1/samples/region_network_firewall_policies_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_region_network_firewall_policies_v1:: + RegionNetworkFirewallPoliciesClient( + google::cloud::compute_region_network_firewall_policies_v1:: + MakeRegionNetworkFirewallPoliciesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_region_network_firewall_policies_v1:: @@ -203,6 +225,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -213,6 +238,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/region_notification_endpoints/v1/samples/region_notification_endpoints_client_samples.cc b/google/cloud/compute/region_notification_endpoints/v1/samples/region_notification_endpoints_client_samples.cc index a188df199d619..e0811ccc390f7 100644 --- a/google/cloud/compute/region_notification_endpoints/v1/samples/region_notification_endpoints_client_samples.cc +++ b/google/cloud/compute/region_notification_endpoints/v1/samples/region_notification_endpoints_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_region_notification_endpoints_v1:: + RegionNotificationEndpointsClient( + google::cloud::compute_region_notification_endpoints_v1:: + MakeRegionNotificationEndpointsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_region_notification_endpoints_v1:: @@ -203,6 +225,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -213,6 +238,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/region_operations/v1/samples/region_operations_client_samples.cc b/google/cloud/compute/region_operations/v1/samples/region_operations_client_samples.cc index 5022f6be7beeb..46726ee574962 100644 --- a/google/cloud/compute/region_operations/v1/samples/region_operations_client_samples.cc +++ b/google/cloud/compute/region_operations/v1/samples/region_operations_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_region_operations_v1::RegionOperationsClient( + google::cloud::compute_region_operations_v1:: + MakeRegionOperationsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_region_operations_v1:: @@ -150,6 +172,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -159,6 +184,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/region_security_policies/v1/samples/region_security_policies_client_samples.cc b/google/cloud/compute/region_security_policies/v1/samples/region_security_policies_client_samples.cc index 4b2ef18d0d00e..37b701249f018 100644 --- a/google/cloud/compute/region_security_policies/v1/samples/region_security_policies_client_samples.cc +++ b/google/cloud/compute/region_security_policies/v1/samples/region_security_policies_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_region_security_policies_v1:: + RegionSecurityPoliciesClient( + google::cloud::compute_region_security_policies_v1:: + MakeRegionSecurityPoliciesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_region_security_policies_v1:: @@ -202,6 +224,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -212,6 +237,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/region_ssl_certificates/v1/samples/region_ssl_certificates_client_samples.cc b/google/cloud/compute/region_ssl_certificates/v1/samples/region_ssl_certificates_client_samples.cc index 78276284e6af8..02d1034102e97 100644 --- a/google/cloud/compute/region_ssl_certificates/v1/samples/region_ssl_certificates_client_samples.cc +++ b/google/cloud/compute/region_ssl_certificates/v1/samples/region_ssl_certificates_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_region_ssl_certificates_v1:: + RegionSslCertificatesClient( + google::cloud::compute_region_ssl_certificates_v1:: + MakeRegionSslCertificatesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_region_ssl_certificates_v1:: @@ -202,6 +224,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -212,6 +237,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/region_ssl_policies/v1/samples/region_ssl_policies_client_samples.cc b/google/cloud/compute/region_ssl_policies/v1/samples/region_ssl_policies_client_samples.cc index 05f39b9639da6..f77bfa9336e18 100644 --- a/google/cloud/compute/region_ssl_policies/v1/samples/region_ssl_policies_client_samples.cc +++ b/google/cloud/compute/region_ssl_policies/v1/samples/region_ssl_policies_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_region_ssl_policies_v1::RegionSslPoliciesClient( + google::cloud::compute_region_ssl_policies_v1:: + MakeRegionSslPoliciesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_region_ssl_policies_v1:: @@ -204,6 +226,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -214,6 +239,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/region_target_http_proxies/v1/samples/region_target_http_proxies_client_samples.cc b/google/cloud/compute/region_target_http_proxies/v1/samples/region_target_http_proxies_client_samples.cc index 6d65a623e2477..67e7867c5eea8 100644 --- a/google/cloud/compute/region_target_http_proxies/v1/samples/region_target_http_proxies_client_samples.cc +++ b/google/cloud/compute/region_target_http_proxies/v1/samples/region_target_http_proxies_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_region_target_http_proxies_v1:: + RegionTargetHttpProxiesClient( + google::cloud::compute_region_target_http_proxies_v1:: + MakeRegionTargetHttpProxiesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_region_target_http_proxies_v1:: @@ -202,6 +224,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -212,6 +237,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/region_target_https_proxies/v1/samples/region_target_https_proxies_client_samples.cc b/google/cloud/compute/region_target_https_proxies/v1/samples/region_target_https_proxies_client_samples.cc index 2b77dfd5de56c..44061f22c10a9 100644 --- a/google/cloud/compute/region_target_https_proxies/v1/samples/region_target_https_proxies_client_samples.cc +++ b/google/cloud/compute/region_target_https_proxies/v1/samples/region_target_https_proxies_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_region_target_https_proxies_v1:: + RegionTargetHttpsProxiesClient( + google::cloud::compute_region_target_https_proxies_v1:: + MakeRegionTargetHttpsProxiesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_region_target_https_proxies_v1:: @@ -202,6 +224,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -212,6 +237,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/region_target_tcp_proxies/v1/samples/region_target_tcp_proxies_client_samples.cc b/google/cloud/compute/region_target_tcp_proxies/v1/samples/region_target_tcp_proxies_client_samples.cc index 404992dae9cc5..4f35645032ab5 100644 --- a/google/cloud/compute/region_target_tcp_proxies/v1/samples/region_target_tcp_proxies_client_samples.cc +++ b/google/cloud/compute/region_target_tcp_proxies/v1/samples/region_target_tcp_proxies_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_region_target_tcp_proxies_v1:: + RegionTargetTcpProxiesClient( + google::cloud::compute_region_target_tcp_proxies_v1:: + MakeRegionTargetTcpProxiesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_region_target_tcp_proxies_v1:: @@ -202,6 +224,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -212,6 +237,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/region_url_maps/v1/samples/region_url_maps_client_samples.cc b/google/cloud/compute/region_url_maps/v1/samples/region_url_maps_client_samples.cc index b83412a102e74..bde9358af3b4c 100644 --- a/google/cloud/compute/region_url_maps/v1/samples/region_url_maps_client_samples.cc +++ b/google/cloud/compute/region_url_maps/v1/samples/region_url_maps_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_region_url_maps_v1::RegionUrlMapsClient( + google::cloud::compute_region_url_maps_v1:: + MakeRegionUrlMapsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_region_url_maps_v1:: @@ -197,6 +219,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -207,6 +232,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/region_zones/v1/samples/region_zones_client_samples.cc b/google/cloud/compute/region_zones/v1/samples/region_zones_client_samples.cc index 56350908a60cf..695da1cd45abb 100644 --- a/google/cloud/compute/region_zones/v1/samples/region_zones_client_samples.cc +++ b/google/cloud/compute/region_zones/v1/samples/region_zones_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_region_zones_v1::RegionZonesClient( + google::cloud::compute_region_zones_v1::MakeRegionZonesConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_region_zones_v1:: RegionZonesConnectionIdempotencyPolicy { @@ -148,6 +169,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -157,6 +181,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/regions/v1/samples/regions_client_samples.cc b/google/cloud/compute/regions/v1/samples/regions_client_samples.cc index 5359b72adb26a..fb350f34e0a91 100644 --- a/google/cloud/compute/regions/v1/samples/regions_client_samples.cc +++ b/google/cloud/compute/regions/v1/samples/regions_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_regions_v1::RegionsClient( + google::cloud::compute_regions_v1::MakeRegionsConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_regions_v1:: RegionsConnectionIdempotencyPolicy { @@ -141,6 +162,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +174,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/reservation_blocks/v1/samples/reservation_blocks_client_samples.cc b/google/cloud/compute/reservation_blocks/v1/samples/reservation_blocks_client_samples.cc index 3709724233793..f10b35ab05af3 100644 --- a/google/cloud/compute/reservation_blocks/v1/samples/reservation_blocks_client_samples.cc +++ b/google/cloud/compute/reservation_blocks/v1/samples/reservation_blocks_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_reservation_blocks_v1::ReservationBlocksClient( + google::cloud::compute_reservation_blocks_v1:: + MakeReservationBlocksConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_reservation_blocks_v1:: @@ -204,6 +226,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -214,6 +239,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/reservation_sub_blocks/v1/samples/reservation_sub_blocks_client_samples.cc b/google/cloud/compute/reservation_sub_blocks/v1/samples/reservation_sub_blocks_client_samples.cc index 24810cde49b37..fc8b4ec15b751 100644 --- a/google/cloud/compute/reservation_sub_blocks/v1/samples/reservation_sub_blocks_client_samples.cc +++ b/google/cloud/compute/reservation_sub_blocks/v1/samples/reservation_sub_blocks_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_reservation_sub_blocks_v1:: + ReservationSubBlocksClient( + google::cloud::compute_reservation_sub_blocks_v1:: + MakeReservationSubBlocksConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_reservation_sub_blocks_v1:: @@ -154,6 +176,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -163,6 +188,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/reservations/v1/samples/reservations_client_samples.cc b/google/cloud/compute/reservations/v1/samples/reservations_client_samples.cc index 35aa5649e0cf3..59298e9432bcb 100644 --- a/google/cloud/compute/reservations/v1/samples/reservations_client_samples.cc +++ b/google/cloud/compute/reservations/v1/samples/reservations_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_reservations_v1::ReservationsClient( + google::cloud::compute_reservations_v1::MakeReservationsConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_reservations_v1:: ReservationsConnectionIdempotencyPolicy { @@ -197,6 +218,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -207,6 +231,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/resource_policies/v1/samples/resource_policies_client_samples.cc b/google/cloud/compute/resource_policies/v1/samples/resource_policies_client_samples.cc index 3acb284fabb09..dd52e8606ff3d 100644 --- a/google/cloud/compute/resource_policies/v1/samples/resource_policies_client_samples.cc +++ b/google/cloud/compute/resource_policies/v1/samples/resource_policies_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_resource_policies_v1::ResourcePoliciesClient( + google::cloud::compute_resource_policies_v1:: + MakeResourcePoliciesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_resource_policies_v1:: @@ -198,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -208,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/routers/v1/samples/routers_client_samples.cc b/google/cloud/compute/routers/v1/samples/routers_client_samples.cc index e0e06b42cd659..f4c693cea7ed6 100644 --- a/google/cloud/compute/routers/v1/samples/routers_client_samples.cc +++ b/google/cloud/compute/routers/v1/samples/routers_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_routers_v1::RoutersClient( + google::cloud::compute_routers_v1::MakeRoutersConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_routers_v1:: RoutersConnectionIdempotencyPolicy { @@ -186,6 +207,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +220,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/routes/v1/samples/routes_client_samples.cc b/google/cloud/compute/routes/v1/samples/routes_client_samples.cc index 1e4132efc7278..f1d2915f2f646 100644 --- a/google/cloud/compute/routes/v1/samples/routes_client_samples.cc +++ b/google/cloud/compute/routes/v1/samples/routes_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_routes_v1::RoutesClient( + google::cloud::compute_routes_v1::MakeRoutesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_routes_v1:: RoutesConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/security_policies/v1/samples/security_policies_client_samples.cc b/google/cloud/compute/security_policies/v1/samples/security_policies_client_samples.cc index 97c4214349330..aaeda4e4cb895 100644 --- a/google/cloud/compute/security_policies/v1/samples/security_policies_client_samples.cc +++ b/google/cloud/compute/security_policies/v1/samples/security_policies_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_security_policies_v1::SecurityPoliciesClient( + google::cloud::compute_security_policies_v1:: + MakeSecurityPoliciesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_security_policies_v1:: @@ -198,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -208,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/service_attachments/v1/samples/service_attachments_client_samples.cc b/google/cloud/compute/service_attachments/v1/samples/service_attachments_client_samples.cc index dc12205bb24da..8ef4c14c262bd 100644 --- a/google/cloud/compute/service_attachments/v1/samples/service_attachments_client_samples.cc +++ b/google/cloud/compute/service_attachments/v1/samples/service_attachments_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_service_attachments_v1::ServiceAttachmentsClient( + google::cloud::compute_service_attachments_v1:: + MakeServiceAttachmentsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_service_attachments_v1:: @@ -204,6 +226,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -214,6 +239,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/snapshot_settings/v1/samples/snapshot_settings_client_samples.cc b/google/cloud/compute/snapshot_settings/v1/samples/snapshot_settings_client_samples.cc index 6ea91cb0fe0fa..58f7b290b4b73 100644 --- a/google/cloud/compute/snapshot_settings/v1/samples/snapshot_settings_client_samples.cc +++ b/google/cloud/compute/snapshot_settings/v1/samples/snapshot_settings_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_snapshot_settings_v1::SnapshotSettingsClient( + google::cloud::compute_snapshot_settings_v1:: + MakeSnapshotSettingsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_snapshot_settings_v1:: @@ -198,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -208,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/snapshots/v1/samples/snapshots_client_samples.cc b/google/cloud/compute/snapshots/v1/samples/snapshots_client_samples.cc index 26f375cb1e09b..390b03997dff6 100644 --- a/google/cloud/compute/snapshots/v1/samples/snapshots_client_samples.cc +++ b/google/cloud/compute/snapshots/v1/samples/snapshots_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_snapshots_v1::SnapshotsClient( + google::cloud::compute_snapshots_v1::MakeSnapshotsConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_snapshots_v1:: SnapshotsConnectionIdempotencyPolicy { @@ -190,6 +211,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -200,6 +224,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/ssl_certificates/v1/samples/ssl_certificates_client_samples.cc b/google/cloud/compute/ssl_certificates/v1/samples/ssl_certificates_client_samples.cc index 9c6dd21cde479..6524d539ae324 100644 --- a/google/cloud/compute/ssl_certificates/v1/samples/ssl_certificates_client_samples.cc +++ b/google/cloud/compute/ssl_certificates/v1/samples/ssl_certificates_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_ssl_certificates_v1::SslCertificatesClient( + google::cloud::compute_ssl_certificates_v1:: + MakeSslCertificatesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_ssl_certificates_v1:: @@ -197,6 +219,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -207,6 +232,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/ssl_policies/v1/samples/ssl_policies_client_samples.cc b/google/cloud/compute/ssl_policies/v1/samples/ssl_policies_client_samples.cc index e89a2c9635fdf..370bb81ae516d 100644 --- a/google/cloud/compute/ssl_policies/v1/samples/ssl_policies_client_samples.cc +++ b/google/cloud/compute/ssl_policies/v1/samples/ssl_policies_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_ssl_policies_v1::SslPoliciesClient( + google::cloud::compute_ssl_policies_v1::MakeSslPoliciesConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_ssl_policies_v1:: SslPoliciesConnectionIdempotencyPolicy { @@ -197,6 +218,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -207,6 +231,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/storage_pool_types/v1/samples/storage_pool_types_client_samples.cc b/google/cloud/compute/storage_pool_types/v1/samples/storage_pool_types_client_samples.cc index 0e18e938cb3ef..797903dbeafce 100644 --- a/google/cloud/compute/storage_pool_types/v1/samples/storage_pool_types_client_samples.cc +++ b/google/cloud/compute/storage_pool_types/v1/samples/storage_pool_types_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_storage_pool_types_v1::StoragePoolTypesClient( + google::cloud::compute_storage_pool_types_v1:: + MakeStoragePoolTypesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_storage_pool_types_v1:: @@ -153,6 +175,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -162,6 +187,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/storage_pools/v1/samples/storage_pools_client_samples.cc b/google/cloud/compute/storage_pools/v1/samples/storage_pools_client_samples.cc index 845859967d9dd..41aa1a966995a 100644 --- a/google/cloud/compute/storage_pools/v1/samples/storage_pools_client_samples.cc +++ b/google/cloud/compute/storage_pools/v1/samples/storage_pools_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_storage_pools_v1::StoragePoolsClient( + google::cloud::compute_storage_pools_v1::MakeStoragePoolsConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_storage_pools_v1:: StoragePoolsConnectionIdempotencyPolicy { @@ -197,6 +218,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -207,6 +231,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/subnetworks/v1/samples/subnetworks_client_samples.cc b/google/cloud/compute/subnetworks/v1/samples/subnetworks_client_samples.cc index cd1c2493cce7c..a72a706efb414 100644 --- a/google/cloud/compute/subnetworks/v1/samples/subnetworks_client_samples.cc +++ b/google/cloud/compute/subnetworks/v1/samples/subnetworks_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_subnetworks_v1::SubnetworksClient( + google::cloud::compute_subnetworks_v1::MakeSubnetworksConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_subnetworks_v1:: SubnetworksConnectionIdempotencyPolicy { @@ -197,6 +218,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -207,6 +231,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/target_grpc_proxies/v1/samples/target_grpc_proxies_client_samples.cc b/google/cloud/compute/target_grpc_proxies/v1/samples/target_grpc_proxies_client_samples.cc index 004d5fabbd1ae..11e4c09c3f046 100644 --- a/google/cloud/compute/target_grpc_proxies/v1/samples/target_grpc_proxies_client_samples.cc +++ b/google/cloud/compute/target_grpc_proxies/v1/samples/target_grpc_proxies_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_target_grpc_proxies_v1::TargetGrpcProxiesClient( + google::cloud::compute_target_grpc_proxies_v1:: + MakeTargetGrpcProxiesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_target_grpc_proxies_v1:: @@ -204,6 +226,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -214,6 +239,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/target_http_proxies/v1/samples/target_http_proxies_client_samples.cc b/google/cloud/compute/target_http_proxies/v1/samples/target_http_proxies_client_samples.cc index 96ee00cd9257d..3693372673c6a 100644 --- a/google/cloud/compute/target_http_proxies/v1/samples/target_http_proxies_client_samples.cc +++ b/google/cloud/compute/target_http_proxies/v1/samples/target_http_proxies_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_target_http_proxies_v1::TargetHttpProxiesClient( + google::cloud::compute_target_http_proxies_v1:: + MakeTargetHttpProxiesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_target_http_proxies_v1:: @@ -204,6 +226,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -214,6 +239,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/target_https_proxies/v1/samples/target_https_proxies_client_samples.cc b/google/cloud/compute/target_https_proxies/v1/samples/target_https_proxies_client_samples.cc index de290becb956a..6d8dce6746a82 100644 --- a/google/cloud/compute/target_https_proxies/v1/samples/target_https_proxies_client_samples.cc +++ b/google/cloud/compute/target_https_proxies/v1/samples/target_https_proxies_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_target_https_proxies_v1::TargetHttpsProxiesClient( + google::cloud::compute_target_https_proxies_v1:: + MakeTargetHttpsProxiesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_target_https_proxies_v1:: @@ -205,6 +227,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -215,6 +240,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/target_instances/v1/samples/target_instances_client_samples.cc b/google/cloud/compute/target_instances/v1/samples/target_instances_client_samples.cc index d59e06ac93307..80b6e9e6d5c28 100644 --- a/google/cloud/compute/target_instances/v1/samples/target_instances_client_samples.cc +++ b/google/cloud/compute/target_instances/v1/samples/target_instances_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_target_instances_v1::TargetInstancesClient( + google::cloud::compute_target_instances_v1:: + MakeTargetInstancesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_target_instances_v1:: @@ -197,6 +219,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -207,6 +232,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/target_pools/v1/samples/target_pools_client_samples.cc b/google/cloud/compute/target_pools/v1/samples/target_pools_client_samples.cc index 0ff9751582b4b..d94020ebd62ba 100644 --- a/google/cloud/compute/target_pools/v1/samples/target_pools_client_samples.cc +++ b/google/cloud/compute/target_pools/v1/samples/target_pools_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_target_pools_v1::TargetPoolsClient( + google::cloud::compute_target_pools_v1::MakeTargetPoolsConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_target_pools_v1:: TargetPoolsConnectionIdempotencyPolicy { @@ -197,6 +218,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -207,6 +231,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/target_ssl_proxies/v1/samples/target_ssl_proxies_client_samples.cc b/google/cloud/compute/target_ssl_proxies/v1/samples/target_ssl_proxies_client_samples.cc index 231d0ea4b7434..ef2cc8a92ba94 100644 --- a/google/cloud/compute/target_ssl_proxies/v1/samples/target_ssl_proxies_client_samples.cc +++ b/google/cloud/compute/target_ssl_proxies/v1/samples/target_ssl_proxies_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_target_ssl_proxies_v1::TargetSslProxiesClient( + google::cloud::compute_target_ssl_proxies_v1:: + MakeTargetSslProxiesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_target_ssl_proxies_v1:: @@ -203,6 +225,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -213,6 +238,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/target_tcp_proxies/v1/samples/target_tcp_proxies_client_samples.cc b/google/cloud/compute/target_tcp_proxies/v1/samples/target_tcp_proxies_client_samples.cc index 7f7c4e7d7c4aa..7e798f99c1bd0 100644 --- a/google/cloud/compute/target_tcp_proxies/v1/samples/target_tcp_proxies_client_samples.cc +++ b/google/cloud/compute/target_tcp_proxies/v1/samples/target_tcp_proxies_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_target_tcp_proxies_v1::TargetTcpProxiesClient( + google::cloud::compute_target_tcp_proxies_v1:: + MakeTargetTcpProxiesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_target_tcp_proxies_v1:: @@ -203,6 +225,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -213,6 +238,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/target_vpn_gateways/v1/samples/target_vpn_gateways_client_samples.cc b/google/cloud/compute/target_vpn_gateways/v1/samples/target_vpn_gateways_client_samples.cc index e2bc2bf188086..09563b8437843 100644 --- a/google/cloud/compute/target_vpn_gateways/v1/samples/target_vpn_gateways_client_samples.cc +++ b/google/cloud/compute/target_vpn_gateways/v1/samples/target_vpn_gateways_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_target_vpn_gateways_v1::TargetVpnGatewaysClient( + google::cloud::compute_target_vpn_gateways_v1:: + MakeTargetVpnGatewaysConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_target_vpn_gateways_v1:: @@ -204,6 +226,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -214,6 +239,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/url_maps/v1/samples/url_maps_client_samples.cc b/google/cloud/compute/url_maps/v1/samples/url_maps_client_samples.cc index 704b6c9a752ad..a028351b3301f 100644 --- a/google/cloud/compute/url_maps/v1/samples/url_maps_client_samples.cc +++ b/google/cloud/compute/url_maps/v1/samples/url_maps_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_url_maps_v1::UrlMapsClient( + google::cloud::compute_url_maps_v1::MakeUrlMapsConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_url_maps_v1:: UrlMapsConnectionIdempotencyPolicy { @@ -186,6 +207,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +220,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/vpn_gateways/v1/samples/vpn_gateways_client_samples.cc b/google/cloud/compute/vpn_gateways/v1/samples/vpn_gateways_client_samples.cc index 697b83c8bd59c..12e2e2863f111 100644 --- a/google/cloud/compute/vpn_gateways/v1/samples/vpn_gateways_client_samples.cc +++ b/google/cloud/compute/vpn_gateways/v1/samples/vpn_gateways_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_vpn_gateways_v1::VpnGatewaysClient( + google::cloud::compute_vpn_gateways_v1::MakeVpnGatewaysConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_vpn_gateways_v1:: VpnGatewaysConnectionIdempotencyPolicy { @@ -197,6 +218,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -207,6 +231,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/vpn_tunnels/v1/samples/vpn_tunnels_client_samples.cc b/google/cloud/compute/vpn_tunnels/v1/samples/vpn_tunnels_client_samples.cc index 50112c11d89a9..a84f2745b3a57 100644 --- a/google/cloud/compute/vpn_tunnels/v1/samples/vpn_tunnels_client_samples.cc +++ b/google/cloud/compute/vpn_tunnels/v1/samples/vpn_tunnels_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_vpn_tunnels_v1::VpnTunnelsClient( + google::cloud::compute_vpn_tunnels_v1::MakeVpnTunnelsConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_vpn_tunnels_v1:: VpnTunnelsConnectionIdempotencyPolicy { @@ -193,6 +214,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -203,6 +227,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/zone_operations/v1/samples/zone_operations_client_samples.cc b/google/cloud/compute/zone_operations/v1/samples/zone_operations_client_samples.cc index 6325e12975b97..c5772694d4a18 100644 --- a/google/cloud/compute/zone_operations/v1/samples/zone_operations_client_samples.cc +++ b/google/cloud/compute/zone_operations/v1/samples/zone_operations_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::compute_zone_operations_v1::ZoneOperationsClient( + google::cloud::compute_zone_operations_v1:: + MakeZoneOperationsConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_zone_operations_v1:: @@ -149,6 +171,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -158,6 +183,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/compute/zones/v1/samples/zones_client_samples.cc b/google/cloud/compute/zones/v1/samples/zones_client_samples.cc index cdf63b6482433..b89087d4ee80d 100644 --- a/google/cloud/compute/zones/v1/samples/zones_client_samples.cc +++ b/google/cloud/compute/zones/v1/samples/zones_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::compute_zones_v1::ZonesClient( + google::cloud::compute_zones_v1::MakeZonesConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::compute_zones_v1::ZonesConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/confidentialcomputing/doc/override-universe-domain.dox b/google/cloud/confidentialcomputing/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..a4ca290a02cf0 --- /dev/null +++ b/google/cloud/confidentialcomputing/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page confidentialcomputing-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `confidentialcomputing_v1::ConfidentialComputingClient`: + +@snippet confidential_computing_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page confidentialcomputing_v1::ConfidentialComputingClient-universe-domain-snippet Override confidentialcomputing_v1::ConfidentialComputingClient Universe Domain + +@snippet google/cloud/confidentialcomputing/v1/samples/confidential_computing_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/confidentialcomputing/v1/samples/confidential_computing_client_samples.cc b/google/cloud/confidentialcomputing/v1/samples/confidential_computing_client_samples.cc index 75773577200ab..2c7c0ab31e48c 100644 --- a/google/cloud/confidentialcomputing/v1/samples/confidential_computing_client_samples.cc +++ b/google/cloud/confidentialcomputing/v1/samples/confidential_computing_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::confidentialcomputing_v1::ConfidentialComputingClient( + google::cloud::confidentialcomputing_v1:: + MakeConfidentialComputingConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::confidentialcomputing_v1:: @@ -153,6 +175,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -162,6 +187,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/config/doc/override-universe-domain.dox b/google/cloud/config/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..e71e6467fda80 --- /dev/null +++ b/google/cloud/config/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page config-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `config_v1::ConfigClient`: + +@snippet config_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page config_v1::ConfigClient-universe-domain-snippet Override config_v1::ConfigClient Universe Domain + +@snippet google/cloud/config/v1/samples/config_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/config/v1/samples/config_client_samples.cc b/google/cloud/config/v1/samples/config_client_samples.cc index 036ac0b5ef372..e138ba590d8c7 100644 --- a/google/cloud/config/v1/samples/config_client_samples.cc +++ b/google/cloud/config/v1/samples/config_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::config_v1::ConfigClient( + google::cloud::config_v1::MakeConfigConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::config_v1::ConfigConnectionIdempotencyPolicy { @@ -179,6 +199,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -189,6 +212,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/configdelivery/doc/override-universe-domain.dox b/google/cloud/configdelivery/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..7eeae264295aa --- /dev/null +++ b/google/cloud/configdelivery/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page configdelivery-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `configdelivery_v1::ConfigDeliveryClient`: + +@snippet config_delivery_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page configdelivery_v1::ConfigDeliveryClient-universe-domain-snippet Override configdelivery_v1::ConfigDeliveryClient Universe Domain + +@snippet google/cloud/configdelivery/v1/samples/config_delivery_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/configdelivery/v1/samples/config_delivery_client_samples.cc b/google/cloud/configdelivery/v1/samples/config_delivery_client_samples.cc index 541cf01279783..0370de56d81e2 100644 --- a/google/cloud/configdelivery/v1/samples/config_delivery_client_samples.cc +++ b/google/cloud/configdelivery/v1/samples/config_delivery_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::configdelivery_v1::ConfigDeliveryClient( + google::cloud::configdelivery_v1::MakeConfigDeliveryConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::configdelivery_v1:: ConfigDeliveryConnectionIdempotencyPolicy { @@ -190,6 +211,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -200,6 +224,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/connectors/doc/override-universe-domain.dox b/google/cloud/connectors/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..0ca6687b7ea8a --- /dev/null +++ b/google/cloud/connectors/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page connectors-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `connectors_v1::ConnectorsClient`: + +@snippet connectors_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page connectors_v1::ConnectorsClient-universe-domain-snippet Override connectors_v1::ConnectorsClient Universe Domain + +@snippet google/cloud/connectors/v1/samples/connectors_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/connectors/v1/samples/connectors_client_samples.cc b/google/cloud/connectors/v1/samples/connectors_client_samples.cc index e0fb14c29c9fd..6cf91d1c5408f 100644 --- a/google/cloud/connectors/v1/samples/connectors_client_samples.cc +++ b/google/cloud/connectors/v1/samples/connectors_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::connectors_v1::ConnectorsClient( + google::cloud::connectors_v1::MakeConnectorsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::connectors_v1:: ConnectorsConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/contactcenterinsights/doc/override-universe-domain.dox b/google/cloud/contactcenterinsights/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..0681a9c44f043 --- /dev/null +++ b/google/cloud/contactcenterinsights/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page contactcenterinsights-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `contactcenterinsights_v1::ContactCenterInsightsClient`: + +@snippet contact_center_insights_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page contactcenterinsights_v1::ContactCenterInsightsClient-universe-domain-snippet Override contactcenterinsights_v1::ContactCenterInsightsClient Universe Domain + +@snippet google/cloud/contactcenterinsights/v1/samples/contact_center_insights_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/contactcenterinsights/v1/samples/contact_center_insights_client_samples.cc b/google/cloud/contactcenterinsights/v1/samples/contact_center_insights_client_samples.cc index 2d9c168f9c0be..1561cc479607e 100644 --- a/google/cloud/contactcenterinsights/v1/samples/contact_center_insights_client_samples.cc +++ b/google/cloud/contactcenterinsights/v1/samples/contact_center_insights_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::contactcenterinsights_v1::ContactCenterInsightsClient( + google::cloud::contactcenterinsights_v1:: + MakeContactCenterInsightsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::contactcenterinsights_v1:: @@ -203,6 +225,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -213,6 +238,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/container/doc/override-universe-domain.dox b/google/cloud/container/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..b04884ec48c32 --- /dev/null +++ b/google/cloud/container/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page container-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `container_v1::ClusterManagerClient`: + +@snippet cluster_manager_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page container_v1::ClusterManagerClient-universe-domain-snippet Override container_v1::ClusterManagerClient Universe Domain + +@snippet google/cloud/container/v1/samples/cluster_manager_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/container/v1/samples/cluster_manager_client_samples.cc b/google/cloud/container/v1/samples/cluster_manager_client_samples.cc index b271bddaef74f..fe41525d9b6f5 100644 --- a/google/cloud/container/v1/samples/cluster_manager_client_samples.cc +++ b/google/cloud/container/v1/samples/cluster_manager_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::container_v1::ClusterManagerClient( + google::cloud::container_v1::MakeClusterManagerConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::container_v1:: ClusterManagerConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/containeranalysis/doc/override-universe-domain.dox b/google/cloud/containeranalysis/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..f7429bf8a7b75 --- /dev/null +++ b/google/cloud/containeranalysis/doc/override-universe-domain.dox @@ -0,0 +1,36 @@ +/*! +@page containeranalysis-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `containeranalysis_v1::ContainerAnalysisClient`: + +@snippet container_analysis_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c containeranalysis_v1::ContainerAnalysisClient](@ref containeranalysis_v1::ContainerAnalysisClient-universe-domain-snippet) +- [\c containeranalysis_v1::GrafeasClient](@ref containeranalysis_v1::GrafeasClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page containeranalysis_v1::ContainerAnalysisClient-universe-domain-snippet Override containeranalysis_v1::ContainerAnalysisClient Universe Domain + +@snippet google/cloud/containeranalysis/v1/samples/container_analysis_client_samples.cc set-client-universe-domain + +*/ + +/*! @page containeranalysis_v1::GrafeasClient-universe-domain-snippet Override containeranalysis_v1::GrafeasClient Universe Domain + +@snippet google/cloud/containeranalysis/v1/samples/grafeas_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/containeranalysis/v1/samples/container_analysis_client_samples.cc b/google/cloud/containeranalysis/v1/samples/container_analysis_client_samples.cc index 3b636e01cae5f..ec6781cf8f70f 100644 --- a/google/cloud/containeranalysis/v1/samples/container_analysis_client_samples.cc +++ b/google/cloud/containeranalysis/v1/samples/container_analysis_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::containeranalysis_v1::ContainerAnalysisClient( + google::cloud::containeranalysis_v1::MakeContainerAnalysisConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::containeranalysis_v1:: @@ -151,6 +172,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -160,6 +184,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/containeranalysis/v1/samples/grafeas_client_samples.cc b/google/cloud/containeranalysis/v1/samples/grafeas_client_samples.cc index a7dda7aad330a..147aea892646a 100644 --- a/google/cloud/containeranalysis/v1/samples/grafeas_client_samples.cc +++ b/google/cloud/containeranalysis/v1/samples/grafeas_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::containeranalysis_v1::GrafeasClient( + google::cloud::containeranalysis_v1::MakeGrafeasConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::containeranalysis_v1:: GrafeasConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/contentwarehouse/doc/override-universe-domain.dox b/google/cloud/contentwarehouse/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..3d5af071a43e4 --- /dev/null +++ b/google/cloud/contentwarehouse/doc/override-universe-domain.dox @@ -0,0 +1,64 @@ +/*! +@page contentwarehouse-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `contentwarehouse_v1::DocumentServiceClient`: + +@snippet document_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c contentwarehouse_v1::DocumentServiceClient](@ref contentwarehouse_v1::DocumentServiceClient-universe-domain-snippet) +- [\c contentwarehouse_v1::DocumentLinkServiceClient](@ref contentwarehouse_v1::DocumentLinkServiceClient-universe-domain-snippet) +- [\c contentwarehouse_v1::DocumentSchemaServiceClient](@ref contentwarehouse_v1::DocumentSchemaServiceClient-universe-domain-snippet) +- [\c contentwarehouse_v1::PipelineServiceClient](@ref contentwarehouse_v1::PipelineServiceClient-universe-domain-snippet) +- [\c contentwarehouse_v1::RuleSetServiceClient](@ref contentwarehouse_v1::RuleSetServiceClient-universe-domain-snippet) +- [\c contentwarehouse_v1::SynonymSetServiceClient](@ref contentwarehouse_v1::SynonymSetServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page contentwarehouse_v1::DocumentServiceClient-universe-domain-snippet Override contentwarehouse_v1::DocumentServiceClient Universe Domain + +@snippet google/cloud/contentwarehouse/v1/samples/document_client_samples.cc set-client-universe-domain + +*/ + +/*! @page contentwarehouse_v1::DocumentLinkServiceClient-universe-domain-snippet Override contentwarehouse_v1::DocumentLinkServiceClient Universe Domain + +@snippet google/cloud/contentwarehouse/v1/samples/document_link_client_samples.cc set-client-universe-domain + +*/ + +/*! @page contentwarehouse_v1::DocumentSchemaServiceClient-universe-domain-snippet Override contentwarehouse_v1::DocumentSchemaServiceClient Universe Domain + +@snippet google/cloud/contentwarehouse/v1/samples/document_schema_client_samples.cc set-client-universe-domain + +*/ + +/*! @page contentwarehouse_v1::PipelineServiceClient-universe-domain-snippet Override contentwarehouse_v1::PipelineServiceClient Universe Domain + +@snippet google/cloud/contentwarehouse/v1/samples/pipeline_client_samples.cc set-client-universe-domain + +*/ + +/*! @page contentwarehouse_v1::RuleSetServiceClient-universe-domain-snippet Override contentwarehouse_v1::RuleSetServiceClient Universe Domain + +@snippet google/cloud/contentwarehouse/v1/samples/rule_set_client_samples.cc set-client-universe-domain + +*/ + +/*! @page contentwarehouse_v1::SynonymSetServiceClient-universe-domain-snippet Override contentwarehouse_v1::SynonymSetServiceClient Universe Domain + +@snippet google/cloud/contentwarehouse/v1/samples/synonym_set_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/contentwarehouse/v1/samples/document_client_samples.cc b/google/cloud/contentwarehouse/v1/samples/document_client_samples.cc index 632afd9918e6f..1cec639c8aa34 100644 --- a/google/cloud/contentwarehouse/v1/samples/document_client_samples.cc +++ b/google/cloud/contentwarehouse/v1/samples/document_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::contentwarehouse_v1::DocumentServiceClient( + google::cloud::contentwarehouse_v1::MakeDocumentServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::contentwarehouse_v1:: DocumentServiceConnectionIdempotencyPolicy { @@ -148,6 +169,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -157,6 +181,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/contentwarehouse/v1/samples/document_link_client_samples.cc b/google/cloud/contentwarehouse/v1/samples/document_link_client_samples.cc index c0eddc11e8651..c98dcaf439234 100644 --- a/google/cloud/contentwarehouse/v1/samples/document_link_client_samples.cc +++ b/google/cloud/contentwarehouse/v1/samples/document_link_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::contentwarehouse_v1::DocumentLinkServiceClient( + google::cloud::contentwarehouse_v1::MakeDocumentLinkServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::contentwarehouse_v1:: @@ -151,6 +173,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -160,6 +185,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/contentwarehouse/v1/samples/document_schema_client_samples.cc b/google/cloud/contentwarehouse/v1/samples/document_schema_client_samples.cc index 91c2e4c07f98d..74ed9e56aae4e 100644 --- a/google/cloud/contentwarehouse/v1/samples/document_schema_client_samples.cc +++ b/google/cloud/contentwarehouse/v1/samples/document_schema_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::contentwarehouse_v1::DocumentSchemaServiceClient( + google::cloud::contentwarehouse_v1:: + MakeDocumentSchemaServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::contentwarehouse_v1:: @@ -151,6 +173,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -160,6 +185,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/contentwarehouse/v1/samples/pipeline_client_samples.cc b/google/cloud/contentwarehouse/v1/samples/pipeline_client_samples.cc index c756ae7c798e2..ad426392bea48 100644 --- a/google/cloud/contentwarehouse/v1/samples/pipeline_client_samples.cc +++ b/google/cloud/contentwarehouse/v1/samples/pipeline_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::contentwarehouse_v1::PipelineServiceClient( + google::cloud::contentwarehouse_v1::MakePipelineServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::contentwarehouse_v1:: PipelineServiceConnectionIdempotencyPolicy { @@ -197,6 +218,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -207,6 +231,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/contentwarehouse/v1/samples/rule_set_client_samples.cc b/google/cloud/contentwarehouse/v1/samples/rule_set_client_samples.cc index b05921bce0841..8d3863604920f 100644 --- a/google/cloud/contentwarehouse/v1/samples/rule_set_client_samples.cc +++ b/google/cloud/contentwarehouse/v1/samples/rule_set_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::contentwarehouse_v1::RuleSetServiceClient( + google::cloud::contentwarehouse_v1::MakeRuleSetServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::contentwarehouse_v1:: RuleSetServiceConnectionIdempotencyPolicy { @@ -147,6 +168,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -156,6 +180,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/contentwarehouse/v1/samples/synonym_set_client_samples.cc b/google/cloud/contentwarehouse/v1/samples/synonym_set_client_samples.cc index 97a581610b68a..b37b654ddbcd9 100644 --- a/google/cloud/contentwarehouse/v1/samples/synonym_set_client_samples.cc +++ b/google/cloud/contentwarehouse/v1/samples/synonym_set_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::contentwarehouse_v1::SynonymSetServiceClient( + google::cloud::contentwarehouse_v1::MakeSynonymSetServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::contentwarehouse_v1:: @@ -150,6 +171,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -159,6 +183,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/datacatalog/doc/override-universe-domain.dox b/google/cloud/datacatalog/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..9d9e1e4b22ee4 --- /dev/null +++ b/google/cloud/datacatalog/doc/override-universe-domain.dox @@ -0,0 +1,50 @@ +/*! +@page datacatalog-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `datacatalog_lineage_v1::LineageClient`: + +@snippet lineage_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c datacatalog_lineage_v1::LineageClient](@ref datacatalog_lineage_v1::LineageClient-universe-domain-snippet) +- [\c datacatalog_v1::DataCatalogClient](@ref datacatalog_v1::DataCatalogClient-universe-domain-snippet) +- [\c datacatalog_v1::PolicyTagManagerClient](@ref datacatalog_v1::PolicyTagManagerClient-universe-domain-snippet) +- [\c datacatalog_v1::PolicyTagManagerSerializationClient](@ref datacatalog_v1::PolicyTagManagerSerializationClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page datacatalog_lineage_v1::LineageClient-universe-domain-snippet Override datacatalog_lineage_v1::LineageClient Universe Domain + +@snippet google/cloud/datacatalog/lineage/v1/samples/lineage_client_samples.cc set-client-universe-domain + +*/ + +/*! @page datacatalog_v1::DataCatalogClient-universe-domain-snippet Override datacatalog_v1::DataCatalogClient Universe Domain + +@snippet google/cloud/datacatalog/v1/samples/data_catalog_client_samples.cc set-client-universe-domain + +*/ + +/*! @page datacatalog_v1::PolicyTagManagerClient-universe-domain-snippet Override datacatalog_v1::PolicyTagManagerClient Universe Domain + +@snippet google/cloud/datacatalog/v1/samples/policy_tag_manager_client_samples.cc set-client-universe-domain + +*/ + +/*! @page datacatalog_v1::PolicyTagManagerSerializationClient-universe-domain-snippet Override datacatalog_v1::PolicyTagManagerSerializationClient Universe Domain + +@snippet google/cloud/datacatalog/v1/samples/policy_tag_manager_serialization_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/datacatalog/lineage/v1/samples/lineage_client_samples.cc b/google/cloud/datacatalog/lineage/v1/samples/lineage_client_samples.cc index 2ea98d77154e3..1bedd0d2f53cc 100644 --- a/google/cloud/datacatalog/lineage/v1/samples/lineage_client_samples.cc +++ b/google/cloud/datacatalog/lineage/v1/samples/lineage_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::datacatalog_lineage_v1::LineageClient( + google::cloud::datacatalog_lineage_v1::MakeLineageConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::datacatalog_lineage_v1:: LineageConnectionIdempotencyPolicy { @@ -188,6 +209,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -198,6 +222,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/datacatalog/v1/samples/data_catalog_client_samples.cc b/google/cloud/datacatalog/v1/samples/data_catalog_client_samples.cc index ca1a753392739..cb73b580e304e 100644 --- a/google/cloud/datacatalog/v1/samples/data_catalog_client_samples.cc +++ b/google/cloud/datacatalog/v1/samples/data_catalog_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::datacatalog_v1::DataCatalogClient( + google::cloud::datacatalog_v1::MakeDataCatalogConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::datacatalog_v1:: DataCatalogConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/datacatalog/v1/samples/policy_tag_manager_client_samples.cc b/google/cloud/datacatalog/v1/samples/policy_tag_manager_client_samples.cc index fe211814ed8c2..c9aca510d56b8 100644 --- a/google/cloud/datacatalog/v1/samples/policy_tag_manager_client_samples.cc +++ b/google/cloud/datacatalog/v1/samples/policy_tag_manager_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::datacatalog_v1::PolicyTagManagerClient( + google::cloud::datacatalog_v1::MakePolicyTagManagerConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::datacatalog_v1:: @@ -146,6 +167,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -155,6 +179,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/datacatalog/v1/samples/policy_tag_manager_serialization_client_samples.cc b/google/cloud/datacatalog/v1/samples/policy_tag_manager_serialization_client_samples.cc index 45627707a26f2..d8b279ac51aa6 100644 --- a/google/cloud/datacatalog/v1/samples/policy_tag_manager_serialization_client_samples.cc +++ b/google/cloud/datacatalog/v1/samples/policy_tag_manager_serialization_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::datacatalog_v1::PolicyTagManagerSerializationClient( + google::cloud::datacatalog_v1:: + MakePolicyTagManagerSerializationConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::datacatalog_v1:: @@ -152,6 +174,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -161,6 +186,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dataform/doc/override-universe-domain.dox b/google/cloud/dataform/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..e700a852c97ea --- /dev/null +++ b/google/cloud/dataform/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page dataform-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `dataform_v1::DataformClient`: + +@snippet dataform_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page dataform_v1::DataformClient-universe-domain-snippet Override dataform_v1::DataformClient Universe Domain + +@snippet google/cloud/dataform/v1/samples/dataform_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/dataform/v1/samples/dataform_client_samples.cc b/google/cloud/dataform/v1/samples/dataform_client_samples.cc index 924d72d59242d..50877c33f51a3 100644 --- a/google/cloud/dataform/v1/samples/dataform_client_samples.cc +++ b/google/cloud/dataform/v1/samples/dataform_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dataform_v1::DataformClient( + google::cloud::dataform_v1::MakeDataformConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dataform_v1::DataformConnectionIdempotencyPolicy { @@ -140,6 +160,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -149,6 +172,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/datafusion/doc/override-universe-domain.dox b/google/cloud/datafusion/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..5a8fa21927c60 --- /dev/null +++ b/google/cloud/datafusion/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page datafusion-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `datafusion_v1::DataFusionClient`: + +@snippet data_fusion_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page datafusion_v1::DataFusionClient-universe-domain-snippet Override datafusion_v1::DataFusionClient Universe Domain + +@snippet google/cloud/datafusion/v1/samples/data_fusion_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/datafusion/v1/samples/data_fusion_client_samples.cc b/google/cloud/datafusion/v1/samples/data_fusion_client_samples.cc index 3491899eb0cfe..63de62626a4c7 100644 --- a/google/cloud/datafusion/v1/samples/data_fusion_client_samples.cc +++ b/google/cloud/datafusion/v1/samples/data_fusion_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::datafusion_v1::DataFusionClient( + google::cloud::datafusion_v1::MakeDataFusionConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::datafusion_v1:: DataFusionConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/datamigration/doc/override-universe-domain.dox b/google/cloud/datamigration/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..bb0881891d648 --- /dev/null +++ b/google/cloud/datamigration/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page datamigration-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `datamigration_v1::DataMigrationServiceClient`: + +@snippet data_migration_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page datamigration_v1::DataMigrationServiceClient-universe-domain-snippet Override datamigration_v1::DataMigrationServiceClient Universe Domain + +@snippet google/cloud/datamigration/v1/samples/data_migration_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/datamigration/v1/samples/data_migration_client_samples.cc b/google/cloud/datamigration/v1/samples/data_migration_client_samples.cc index 59bd982d2c5c1..28d135431d229 100644 --- a/google/cloud/datamigration/v1/samples/data_migration_client_samples.cc +++ b/google/cloud/datamigration/v1/samples/data_migration_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::datamigration_v1::DataMigrationServiceClient( + google::cloud::datamigration_v1::MakeDataMigrationServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::datamigration_v1:: @@ -199,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -209,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dataplex/doc/override-universe-domain.dox b/google/cloud/dataplex/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..13d45df9e04f4 --- /dev/null +++ b/google/cloud/dataplex/doc/override-universe-domain.dox @@ -0,0 +1,64 @@ +/*! +@page dataplex-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `dataplex_v1::CatalogServiceClient`: + +@snippet catalog_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c dataplex_v1::CatalogServiceClient](@ref dataplex_v1::CatalogServiceClient-universe-domain-snippet) +- [\c dataplex_v1::ContentServiceClient](@ref dataplex_v1::ContentServiceClient-universe-domain-snippet) +- [\c dataplex_v1::DataScanServiceClient](@ref dataplex_v1::DataScanServiceClient-universe-domain-snippet) +- [\c dataplex_v1::DataTaxonomyServiceClient](@ref dataplex_v1::DataTaxonomyServiceClient-universe-domain-snippet) +- [\c dataplex_v1::DataplexServiceClient](@ref dataplex_v1::DataplexServiceClient-universe-domain-snippet) +- [\c dataplex_v1::MetadataServiceClient](@ref dataplex_v1::MetadataServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page dataplex_v1::CatalogServiceClient-universe-domain-snippet Override dataplex_v1::CatalogServiceClient Universe Domain + +@snippet google/cloud/dataplex/v1/samples/catalog_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dataplex_v1::ContentServiceClient-universe-domain-snippet Override dataplex_v1::ContentServiceClient Universe Domain + +@snippet google/cloud/dataplex/v1/samples/content_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dataplex_v1::DataScanServiceClient-universe-domain-snippet Override dataplex_v1::DataScanServiceClient Universe Domain + +@snippet google/cloud/dataplex/v1/samples/data_scan_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dataplex_v1::DataTaxonomyServiceClient-universe-domain-snippet Override dataplex_v1::DataTaxonomyServiceClient Universe Domain + +@snippet google/cloud/dataplex/v1/samples/data_taxonomy_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dataplex_v1::DataplexServiceClient-universe-domain-snippet Override dataplex_v1::DataplexServiceClient Universe Domain + +@snippet google/cloud/dataplex/v1/samples/dataplex_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dataplex_v1::MetadataServiceClient-universe-domain-snippet Override dataplex_v1::MetadataServiceClient Universe Domain + +@snippet google/cloud/dataplex/v1/samples/metadata_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/dataplex/v1/samples/catalog_client_samples.cc b/google/cloud/dataplex/v1/samples/catalog_client_samples.cc index 1cd354175f2bc..18a700645addf 100644 --- a/google/cloud/dataplex/v1/samples/catalog_client_samples.cc +++ b/google/cloud/dataplex/v1/samples/catalog_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dataplex_v1::CatalogServiceClient( + google::cloud::dataplex_v1::MakeCatalogServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dataplex_v1:: CatalogServiceConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dataplex/v1/samples/content_client_samples.cc b/google/cloud/dataplex/v1/samples/content_client_samples.cc index 375f748c4d7e2..f7319a87e8254 100644 --- a/google/cloud/dataplex/v1/samples/content_client_samples.cc +++ b/google/cloud/dataplex/v1/samples/content_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dataplex_v1::ContentServiceClient( + google::cloud::dataplex_v1::MakeContentServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dataplex_v1:: ContentServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dataplex/v1/samples/data_scan_client_samples.cc b/google/cloud/dataplex/v1/samples/data_scan_client_samples.cc index e9b48dd670003..a9350375d4cb9 100644 --- a/google/cloud/dataplex/v1/samples/data_scan_client_samples.cc +++ b/google/cloud/dataplex/v1/samples/data_scan_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dataplex_v1::DataScanServiceClient( + google::cloud::dataplex_v1::MakeDataScanServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dataplex_v1:: DataScanServiceConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dataplex/v1/samples/data_taxonomy_client_samples.cc b/google/cloud/dataplex/v1/samples/data_taxonomy_client_samples.cc index 0d2b469c7ede0..1b6dbd1d1b383 100644 --- a/google/cloud/dataplex/v1/samples/data_taxonomy_client_samples.cc +++ b/google/cloud/dataplex/v1/samples/data_taxonomy_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dataplex_v1::DataTaxonomyServiceClient( + google::cloud::dataplex_v1::MakeDataTaxonomyServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dataplex_v1:: @@ -192,6 +213,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -202,6 +226,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dataplex/v1/samples/dataplex_client_samples.cc b/google/cloud/dataplex/v1/samples/dataplex_client_samples.cc index 3ed7deab89ae7..87bef511464cf 100644 --- a/google/cloud/dataplex/v1/samples/dataplex_client_samples.cc +++ b/google/cloud/dataplex/v1/samples/dataplex_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dataplex_v1::DataplexServiceClient( + google::cloud::dataplex_v1::MakeDataplexServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dataplex_v1:: DataplexServiceConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dataplex/v1/samples/metadata_client_samples.cc b/google/cloud/dataplex/v1/samples/metadata_client_samples.cc index 648e069af63f7..23ee127c79330 100644 --- a/google/cloud/dataplex/v1/samples/metadata_client_samples.cc +++ b/google/cloud/dataplex/v1/samples/metadata_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dataplex_v1::MetadataServiceClient( + google::cloud::dataplex_v1::MakeMetadataServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dataplex_v1:: MetadataServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dataproc/doc/override-universe-domain.dox b/google/cloud/dataproc/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..1c504489b74db --- /dev/null +++ b/google/cloud/dataproc/doc/override-universe-domain.dox @@ -0,0 +1,78 @@ +/*! +@page dataproc-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `dataproc_v1::AutoscalingPolicyServiceClient`: + +@snippet autoscaling_policy_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c dataproc_v1::AutoscalingPolicyServiceClient](@ref dataproc_v1::AutoscalingPolicyServiceClient-universe-domain-snippet) +- [\c dataproc_v1::BatchControllerClient](@ref dataproc_v1::BatchControllerClient-universe-domain-snippet) +- [\c dataproc_v1::ClusterControllerClient](@ref dataproc_v1::ClusterControllerClient-universe-domain-snippet) +- [\c dataproc_v1::JobControllerClient](@ref dataproc_v1::JobControllerClient-universe-domain-snippet) +- [\c dataproc_v1::NodeGroupControllerClient](@ref dataproc_v1::NodeGroupControllerClient-universe-domain-snippet) +- [\c dataproc_v1::SessionControllerClient](@ref dataproc_v1::SessionControllerClient-universe-domain-snippet) +- [\c dataproc_v1::SessionTemplateControllerClient](@ref dataproc_v1::SessionTemplateControllerClient-universe-domain-snippet) +- [\c dataproc_v1::WorkflowTemplateServiceClient](@ref dataproc_v1::WorkflowTemplateServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page dataproc_v1::AutoscalingPolicyServiceClient-universe-domain-snippet Override dataproc_v1::AutoscalingPolicyServiceClient Universe Domain + +@snippet google/cloud/dataproc/v1/samples/autoscaling_policy_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dataproc_v1::BatchControllerClient-universe-domain-snippet Override dataproc_v1::BatchControllerClient Universe Domain + +@snippet google/cloud/dataproc/v1/samples/batch_controller_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dataproc_v1::ClusterControllerClient-universe-domain-snippet Override dataproc_v1::ClusterControllerClient Universe Domain + +@snippet google/cloud/dataproc/v1/samples/cluster_controller_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dataproc_v1::JobControllerClient-universe-domain-snippet Override dataproc_v1::JobControllerClient Universe Domain + +@snippet google/cloud/dataproc/v1/samples/job_controller_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dataproc_v1::NodeGroupControllerClient-universe-domain-snippet Override dataproc_v1::NodeGroupControllerClient Universe Domain + +@snippet google/cloud/dataproc/v1/samples/node_group_controller_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dataproc_v1::SessionControllerClient-universe-domain-snippet Override dataproc_v1::SessionControllerClient Universe Domain + +@snippet google/cloud/dataproc/v1/samples/session_controller_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dataproc_v1::SessionTemplateControllerClient-universe-domain-snippet Override dataproc_v1::SessionTemplateControllerClient Universe Domain + +@snippet google/cloud/dataproc/v1/samples/session_template_controller_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dataproc_v1::WorkflowTemplateServiceClient-universe-domain-snippet Override dataproc_v1::WorkflowTemplateServiceClient Universe Domain + +@snippet google/cloud/dataproc/v1/samples/workflow_template_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/dataproc/v1/samples/autoscaling_policy_client_samples.cc b/google/cloud/dataproc/v1/samples/autoscaling_policy_client_samples.cc index c2abac838dd80..f85baad8ea865 100644 --- a/google/cloud/dataproc/v1/samples/autoscaling_policy_client_samples.cc +++ b/google/cloud/dataproc/v1/samples/autoscaling_policy_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dataproc_v1::AutoscalingPolicyServiceClient( + google::cloud::dataproc_v1::MakeAutoscalingPolicyServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dataproc_v1:: @@ -150,6 +171,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -159,6 +183,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dataproc/v1/samples/batch_controller_client_samples.cc b/google/cloud/dataproc/v1/samples/batch_controller_client_samples.cc index 41c09333a2335..b98054ee8fab0 100644 --- a/google/cloud/dataproc/v1/samples/batch_controller_client_samples.cc +++ b/google/cloud/dataproc/v1/samples/batch_controller_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dataproc_v1::BatchControllerClient( + google::cloud::dataproc_v1::MakeBatchControllerConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dataproc_v1:: BatchControllerConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dataproc/v1/samples/cluster_controller_client_samples.cc b/google/cloud/dataproc/v1/samples/cluster_controller_client_samples.cc index ff5d9d4b042e9..bfab95d6f2efb 100644 --- a/google/cloud/dataproc/v1/samples/cluster_controller_client_samples.cc +++ b/google/cloud/dataproc/v1/samples/cluster_controller_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dataproc_v1::ClusterControllerClient( + google::cloud::dataproc_v1::MakeClusterControllerConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dataproc_v1:: @@ -190,6 +210,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -200,6 +223,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dataproc/v1/samples/job_controller_client_samples.cc b/google/cloud/dataproc/v1/samples/job_controller_client_samples.cc index ed1c98bcb6225..c465a855f3dba 100644 --- a/google/cloud/dataproc/v1/samples/job_controller_client_samples.cc +++ b/google/cloud/dataproc/v1/samples/job_controller_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dataproc_v1::JobControllerClient( + google::cloud::dataproc_v1::MakeJobControllerConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dataproc_v1:: JobControllerConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dataproc/v1/samples/node_group_controller_client_samples.cc b/google/cloud/dataproc/v1/samples/node_group_controller_client_samples.cc index a866f342e7c70..50e45598d11b1 100644 --- a/google/cloud/dataproc/v1/samples/node_group_controller_client_samples.cc +++ b/google/cloud/dataproc/v1/samples/node_group_controller_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dataproc_v1::NodeGroupControllerClient( + google::cloud::dataproc_v1::MakeNodeGroupControllerConnection( + "unused", *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dataproc_v1:: @@ -196,6 +217,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -206,6 +230,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dataproc/v1/samples/session_controller_client_samples.cc b/google/cloud/dataproc/v1/samples/session_controller_client_samples.cc index feb513054e363..f40f1d5c03a48 100644 --- a/google/cloud/dataproc/v1/samples/session_controller_client_samples.cc +++ b/google/cloud/dataproc/v1/samples/session_controller_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dataproc_v1::SessionControllerClient( + google::cloud::dataproc_v1::MakeSessionControllerConnection("unused", + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dataproc_v1:: @@ -192,6 +213,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -202,6 +226,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dataproc/v1/samples/session_template_controller_client_samples.cc b/google/cloud/dataproc/v1/samples/session_template_controller_client_samples.cc index 36673edfb0baa..18e88a2169623 100644 --- a/google/cloud/dataproc/v1/samples/session_template_controller_client_samples.cc +++ b/google/cloud/dataproc/v1/samples/session_template_controller_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dataproc_v1::SessionTemplateControllerClient( + google::cloud::dataproc_v1::MakeSessionTemplateControllerConnection( + "unused", *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dataproc_v1:: @@ -150,6 +171,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -159,6 +183,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dataproc/v1/samples/workflow_template_client_samples.cc b/google/cloud/dataproc/v1/samples/workflow_template_client_samples.cc index b2d037e740de1..fc7b8c7370147 100644 --- a/google/cloud/dataproc/v1/samples/workflow_template_client_samples.cc +++ b/google/cloud/dataproc/v1/samples/workflow_template_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dataproc_v1::WorkflowTemplateServiceClient( + google::cloud::dataproc_v1::MakeWorkflowTemplateServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dataproc_v1:: @@ -199,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -209,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/datastore/admin/v1/samples/datastore_admin_client_samples.cc b/google/cloud/datastore/admin/v1/samples/datastore_admin_client_samples.cc index 01a5d7a1ebc5e..05ede3054d0e0 100644 --- a/google/cloud/datastore/admin/v1/samples/datastore_admin_client_samples.cc +++ b/google/cloud/datastore/admin/v1/samples/datastore_admin_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::datastore_admin_v1::DatastoreAdminClient( + google::cloud::datastore_admin_v1::MakeDatastoreAdminConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::datastore_admin_v1:: DatastoreAdminConnectionIdempotencyPolicy { @@ -190,6 +211,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -200,6 +224,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/datastore/doc/override-universe-domain.dox b/google/cloud/datastore/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..93a28078ddb6b --- /dev/null +++ b/google/cloud/datastore/doc/override-universe-domain.dox @@ -0,0 +1,36 @@ +/*! +@page datastore-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `datastore_admin_v1::DatastoreAdminClient`: + +@snippet datastore_admin_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c datastore_admin_v1::DatastoreAdminClient](@ref datastore_admin_v1::DatastoreAdminClient-universe-domain-snippet) +- [\c datastore_v1::DatastoreClient](@ref datastore_v1::DatastoreClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page datastore_admin_v1::DatastoreAdminClient-universe-domain-snippet Override datastore_admin_v1::DatastoreAdminClient Universe Domain + +@snippet google/cloud/datastore/admin/v1/samples/datastore_admin_client_samples.cc set-client-universe-domain + +*/ + +/*! @page datastore_v1::DatastoreClient-universe-domain-snippet Override datastore_v1::DatastoreClient Universe Domain + +@snippet google/cloud/datastore/v1/samples/datastore_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/datastore/v1/samples/datastore_client_samples.cc b/google/cloud/datastore/v1/samples/datastore_client_samples.cc index 92beb024ef710..6acd9d72df14e 100644 --- a/google/cloud/datastore/v1/samples/datastore_client_samples.cc +++ b/google/cloud/datastore/v1/samples/datastore_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::datastore_v1::DatastoreClient( + google::cloud::datastore_v1::MakeDatastoreConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::datastore_v1::DatastoreConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/datastream/doc/override-universe-domain.dox b/google/cloud/datastream/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..b0330caa69aed --- /dev/null +++ b/google/cloud/datastream/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page datastream-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `datastream_v1::DatastreamClient`: + +@snippet datastream_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page datastream_v1::DatastreamClient-universe-domain-snippet Override datastream_v1::DatastreamClient Universe Domain + +@snippet google/cloud/datastream/v1/samples/datastream_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/datastream/v1/samples/datastream_client_samples.cc b/google/cloud/datastream/v1/samples/datastream_client_samples.cc index a6c2d37bc7407..c00f258cf098f 100644 --- a/google/cloud/datastream/v1/samples/datastream_client_samples.cc +++ b/google/cloud/datastream/v1/samples/datastream_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::datastream_v1::DatastreamClient( + google::cloud::datastream_v1::MakeDatastreamConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::datastream_v1:: DatastreamConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/deploy/doc/override-universe-domain.dox b/google/cloud/deploy/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..bdd22fcdc57a8 --- /dev/null +++ b/google/cloud/deploy/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page deploy-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `deploy_v1::CloudDeployClient`: + +@snippet cloud_deploy_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page deploy_v1::CloudDeployClient-universe-domain-snippet Override deploy_v1::CloudDeployClient Universe Domain + +@snippet google/cloud/deploy/v1/samples/cloud_deploy_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/deploy/v1/samples/cloud_deploy_client_samples.cc b/google/cloud/deploy/v1/samples/cloud_deploy_client_samples.cc index c19da7c70e5bb..c8fab7abb7a0e 100644 --- a/google/cloud/deploy/v1/samples/cloud_deploy_client_samples.cc +++ b/google/cloud/deploy/v1/samples/cloud_deploy_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::deploy_v1::CloudDeployClient( + google::cloud::deploy_v1::MakeCloudDeployConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::deploy_v1::CloudDeployConnectionIdempotencyPolicy { @@ -184,6 +204,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -194,6 +217,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/developerconnect/doc/override-universe-domain.dox b/google/cloud/developerconnect/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..741019c5f8019 --- /dev/null +++ b/google/cloud/developerconnect/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page developerconnect-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `developerconnect_v1::DeveloperConnectClient`: + +@snippet developer_connect_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page developerconnect_v1::DeveloperConnectClient-universe-domain-snippet Override developerconnect_v1::DeveloperConnectClient Universe Domain + +@snippet google/cloud/developerconnect/v1/samples/developer_connect_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/developerconnect/v1/samples/developer_connect_client_samples.cc b/google/cloud/developerconnect/v1/samples/developer_connect_client_samples.cc index 01b8199f84715..4cded65b03eed 100644 --- a/google/cloud/developerconnect/v1/samples/developer_connect_client_samples.cc +++ b/google/cloud/developerconnect/v1/samples/developer_connect_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::developerconnect_v1::DeveloperConnectClient( + google::cloud::developerconnect_v1::MakeDeveloperConnectConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::developerconnect_v1:: @@ -199,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -209,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/devicestreaming/doc/override-universe-domain.dox b/google/cloud/devicestreaming/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..840113a470979 --- /dev/null +++ b/google/cloud/devicestreaming/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page devicestreaming-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `devicestreaming_v1::DirectAccessServiceClient`: + +@snippet direct_access_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page devicestreaming_v1::DirectAccessServiceClient-universe-domain-snippet Override devicestreaming_v1::DirectAccessServiceClient Universe Domain + +@snippet google/cloud/devicestreaming/v1/samples/direct_access_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/devicestreaming/v1/samples/direct_access_client_samples.cc b/google/cloud/devicestreaming/v1/samples/direct_access_client_samples.cc index 7577796edcdd1..b38da6aadda83 100644 --- a/google/cloud/devicestreaming/v1/samples/direct_access_client_samples.cc +++ b/google/cloud/devicestreaming/v1/samples/direct_access_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::devicestreaming_v1::DirectAccessServiceClient( + google::cloud::devicestreaming_v1::MakeDirectAccessServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::devicestreaming_v1:: @@ -151,6 +172,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -160,6 +184,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_cx/doc/override-universe-domain.dox b/google/cloud/dialogflow_cx/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..a1da8ca2f1ab8 --- /dev/null +++ b/google/cloud/dialogflow_cx/doc/override-universe-domain.dox @@ -0,0 +1,141 @@ +/*! +@page dialogflow_cx-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `dialogflow_cx::AgentsClient`: + +@snippet agents_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c dialogflow_cx::AgentsClient](@ref dialogflow_cx::AgentsClient-universe-domain-snippet) +- [\c dialogflow_cx::ChangelogsClient](@ref dialogflow_cx::ChangelogsClient-universe-domain-snippet) +- [\c dialogflow_cx::DeploymentsClient](@ref dialogflow_cx::DeploymentsClient-universe-domain-snippet) +- [\c dialogflow_cx::EntityTypesClient](@ref dialogflow_cx::EntityTypesClient-universe-domain-snippet) +- [\c dialogflow_cx::EnvironmentsClient](@ref dialogflow_cx::EnvironmentsClient-universe-domain-snippet) +- [\c dialogflow_cx::ExperimentsClient](@ref dialogflow_cx::ExperimentsClient-universe-domain-snippet) +- [\c dialogflow_cx::FlowsClient](@ref dialogflow_cx::FlowsClient-universe-domain-snippet) +- [\c dialogflow_cx::GeneratorsClient](@ref dialogflow_cx::GeneratorsClient-universe-domain-snippet) +- [\c dialogflow_cx::IntentsClient](@ref dialogflow_cx::IntentsClient-universe-domain-snippet) +- [\c dialogflow_cx::PagesClient](@ref dialogflow_cx::PagesClient-universe-domain-snippet) +- [\c dialogflow_cx::SecuritySettingsServiceClient](@ref dialogflow_cx::SecuritySettingsServiceClient-universe-domain-snippet) +- [\c dialogflow_cx::SessionEntityTypesClient](@ref dialogflow_cx::SessionEntityTypesClient-universe-domain-snippet) +- [\c dialogflow_cx::SessionsClient](@ref dialogflow_cx::SessionsClient-universe-domain-snippet) +- [\c dialogflow_cx::TestCasesClient](@ref dialogflow_cx::TestCasesClient-universe-domain-snippet) +- [\c dialogflow_cx::TransitionRouteGroupsClient](@ref dialogflow_cx::TransitionRouteGroupsClient-universe-domain-snippet) +- [\c dialogflow_cx::VersionsClient](@ref dialogflow_cx::VersionsClient-universe-domain-snippet) +- [\c dialogflow_cx::WebhooksClient](@ref dialogflow_cx::WebhooksClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page dialogflow_cx::AgentsClient-universe-domain-snippet Override dialogflow_cx::AgentsClient Universe Domain + +@snippet google/cloud/dialogflow_cx/samples/agents_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_cx::ChangelogsClient-universe-domain-snippet Override dialogflow_cx::ChangelogsClient Universe Domain + +@snippet google/cloud/dialogflow_cx/samples/changelogs_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_cx::DeploymentsClient-universe-domain-snippet Override dialogflow_cx::DeploymentsClient Universe Domain + +@snippet google/cloud/dialogflow_cx/samples/deployments_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_cx::EntityTypesClient-universe-domain-snippet Override dialogflow_cx::EntityTypesClient Universe Domain + +@snippet google/cloud/dialogflow_cx/samples/entity_types_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_cx::EnvironmentsClient-universe-domain-snippet Override dialogflow_cx::EnvironmentsClient Universe Domain + +@snippet google/cloud/dialogflow_cx/samples/environments_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_cx::ExperimentsClient-universe-domain-snippet Override dialogflow_cx::ExperimentsClient Universe Domain + +@snippet google/cloud/dialogflow_cx/samples/experiments_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_cx::FlowsClient-universe-domain-snippet Override dialogflow_cx::FlowsClient Universe Domain + +@snippet google/cloud/dialogflow_cx/samples/flows_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_cx::GeneratorsClient-universe-domain-snippet Override dialogflow_cx::GeneratorsClient Universe Domain + +@snippet google/cloud/dialogflow_cx/samples/generators_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_cx::IntentsClient-universe-domain-snippet Override dialogflow_cx::IntentsClient Universe Domain + +@snippet google/cloud/dialogflow_cx/samples/intents_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_cx::PagesClient-universe-domain-snippet Override dialogflow_cx::PagesClient Universe Domain + +@snippet google/cloud/dialogflow_cx/samples/pages_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_cx::SecuritySettingsServiceClient-universe-domain-snippet Override dialogflow_cx::SecuritySettingsServiceClient Universe Domain + +@snippet google/cloud/dialogflow_cx/samples/security_settings_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_cx::SessionEntityTypesClient-universe-domain-snippet Override dialogflow_cx::SessionEntityTypesClient Universe Domain + +@snippet google/cloud/dialogflow_cx/samples/session_entity_types_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_cx::SessionsClient-universe-domain-snippet Override dialogflow_cx::SessionsClient Universe Domain + +@snippet google/cloud/dialogflow_cx/samples/sessions_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_cx::TestCasesClient-universe-domain-snippet Override dialogflow_cx::TestCasesClient Universe Domain + +@snippet google/cloud/dialogflow_cx/samples/test_cases_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_cx::TransitionRouteGroupsClient-universe-domain-snippet Override dialogflow_cx::TransitionRouteGroupsClient Universe Domain + +@snippet google/cloud/dialogflow_cx/samples/transition_route_groups_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_cx::VersionsClient-universe-domain-snippet Override dialogflow_cx::VersionsClient Universe Domain + +@snippet google/cloud/dialogflow_cx/samples/versions_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_cx::WebhooksClient-universe-domain-snippet Override dialogflow_cx::WebhooksClient Universe Domain + +@snippet google/cloud/dialogflow_cx/samples/webhooks_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/dialogflow_cx/samples/agents_client_samples.cc b/google/cloud/dialogflow_cx/samples/agents_client_samples.cc index ccd3e3a1ae606..022a2fe6d4e96 100644 --- a/google/cloud/dialogflow_cx/samples/agents_client_samples.cc +++ b/google/cloud/dialogflow_cx/samples/agents_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_cx::AgentsClient( + google::cloud::dialogflow_cx::MakeAgentsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_cx::AgentsConnectionIdempotencyPolicy { @@ -182,6 +202,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -192,6 +215,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_cx/samples/changelogs_client_samples.cc b/google/cloud/dialogflow_cx/samples/changelogs_client_samples.cc index 060946bb63e15..149a6dc70d2da 100644 --- a/google/cloud/dialogflow_cx/samples/changelogs_client_samples.cc +++ b/google/cloud/dialogflow_cx/samples/changelogs_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_cx::ChangelogsClient( + google::cloud::dialogflow_cx::MakeChangelogsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_cx:: ChangelogsConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_cx/samples/deployments_client_samples.cc b/google/cloud/dialogflow_cx/samples/deployments_client_samples.cc index 027b5bbd50c94..3cf474a91b115 100644 --- a/google/cloud/dialogflow_cx/samples/deployments_client_samples.cc +++ b/google/cloud/dialogflow_cx/samples/deployments_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_cx::DeploymentsClient( + google::cloud::dialogflow_cx::MakeDeploymentsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_cx:: DeploymentsConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_cx/samples/entity_types_client_samples.cc b/google/cloud/dialogflow_cx/samples/entity_types_client_samples.cc index 278a8a7e4f617..c2409c02fdd1e 100644 --- a/google/cloud/dialogflow_cx/samples/entity_types_client_samples.cc +++ b/google/cloud/dialogflow_cx/samples/entity_types_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_cx::EntityTypesClient( + google::cloud::dialogflow_cx::MakeEntityTypesConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_cx:: EntityTypesConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_cx/samples/environments_client_samples.cc b/google/cloud/dialogflow_cx/samples/environments_client_samples.cc index 65d19eecc96af..ba63f94d06462 100644 --- a/google/cloud/dialogflow_cx/samples/environments_client_samples.cc +++ b/google/cloud/dialogflow_cx/samples/environments_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_cx::EnvironmentsClient( + google::cloud::dialogflow_cx::MakeEnvironmentsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_cx:: EnvironmentsConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_cx/samples/experiments_client_samples.cc b/google/cloud/dialogflow_cx/samples/experiments_client_samples.cc index 1aa9c10b92d33..6be92db8c59fc 100644 --- a/google/cloud/dialogflow_cx/samples/experiments_client_samples.cc +++ b/google/cloud/dialogflow_cx/samples/experiments_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_cx::ExperimentsClient( + google::cloud::dialogflow_cx::MakeExperimentsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_cx:: ExperimentsConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_cx/samples/flows_client_samples.cc b/google/cloud/dialogflow_cx/samples/flows_client_samples.cc index 57235587ab4da..85ef68b8491b6 100644 --- a/google/cloud/dialogflow_cx/samples/flows_client_samples.cc +++ b/google/cloud/dialogflow_cx/samples/flows_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_cx::FlowsClient( + google::cloud::dialogflow_cx::MakeFlowsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_cx::FlowsConnectionIdempotencyPolicy { @@ -180,6 +200,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -190,6 +213,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_cx/samples/generators_client_samples.cc b/google/cloud/dialogflow_cx/samples/generators_client_samples.cc index ef1233fdef73b..42c1e1f506c11 100644 --- a/google/cloud/dialogflow_cx/samples/generators_client_samples.cc +++ b/google/cloud/dialogflow_cx/samples/generators_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_cx::GeneratorsClient( + google::cloud::dialogflow_cx::MakeGeneratorsConnection("unused", + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_cx:: GeneratorsConnectionIdempotencyPolicy { @@ -143,6 +164,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -152,6 +176,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_cx/samples/intents_client_samples.cc b/google/cloud/dialogflow_cx/samples/intents_client_samples.cc index 329229ccf2aba..9ed928e48b3b1 100644 --- a/google/cloud/dialogflow_cx/samples/intents_client_samples.cc +++ b/google/cloud/dialogflow_cx/samples/intents_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_cx::IntentsClient( + google::cloud::dialogflow_cx::MakeIntentsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_cx::IntentsConnectionIdempotencyPolicy { @@ -184,6 +204,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -194,6 +217,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_cx/samples/pages_client_samples.cc b/google/cloud/dialogflow_cx/samples/pages_client_samples.cc index 2d16e8f544906..71aff41d79860 100644 --- a/google/cloud/dialogflow_cx/samples/pages_client_samples.cc +++ b/google/cloud/dialogflow_cx/samples/pages_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_cx::PagesClient( + google::cloud::dialogflow_cx::MakePagesConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_cx::PagesConnectionIdempotencyPolicy { @@ -139,6 +159,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -148,6 +171,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_cx/samples/security_settings_client_samples.cc b/google/cloud/dialogflow_cx/samples/security_settings_client_samples.cc index 540110c1402ac..7b8d060d279e5 100644 --- a/google/cloud/dialogflow_cx/samples/security_settings_client_samples.cc +++ b/google/cloud/dialogflow_cx/samples/security_settings_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_cx::SecuritySettingsServiceClient( + google::cloud::dialogflow_cx::MakeSecuritySettingsServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_cx:: @@ -150,6 +171,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -159,6 +183,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_cx/samples/session_entity_types_client_samples.cc b/google/cloud/dialogflow_cx/samples/session_entity_types_client_samples.cc index 5de42a9f4e0d6..f7a086d729c22 100644 --- a/google/cloud/dialogflow_cx/samples/session_entity_types_client_samples.cc +++ b/google/cloud/dialogflow_cx/samples/session_entity_types_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_cx::SessionEntityTypesClient( + google::cloud::dialogflow_cx::MakeSessionEntityTypesConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_cx:: @@ -146,6 +167,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -155,6 +179,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_cx/samples/sessions_client_samples.cc b/google/cloud/dialogflow_cx/samples/sessions_client_samples.cc index 98f1e7e6addbb..d412a700be539 100644 --- a/google/cloud/dialogflow_cx/samples/sessions_client_samples.cc +++ b/google/cloud/dialogflow_cx/samples/sessions_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_cx::SessionsClient( + google::cloud::dialogflow_cx::MakeSessionsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_cx::SessionsConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_cx/samples/test_cases_client_samples.cc b/google/cloud/dialogflow_cx/samples/test_cases_client_samples.cc index befbe6061f9f4..8243839ce79bd 100644 --- a/google/cloud/dialogflow_cx/samples/test_cases_client_samples.cc +++ b/google/cloud/dialogflow_cx/samples/test_cases_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_cx::TestCasesClient( + google::cloud::dialogflow_cx::MakeTestCasesConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_cx:: TestCasesConnectionIdempotencyPolicy { @@ -185,6 +205,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -195,6 +218,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_cx/samples/transition_route_groups_client_samples.cc b/google/cloud/dialogflow_cx/samples/transition_route_groups_client_samples.cc index dd6cbf8cc9c5d..e33ee584ab127 100644 --- a/google/cloud/dialogflow_cx/samples/transition_route_groups_client_samples.cc +++ b/google/cloud/dialogflow_cx/samples/transition_route_groups_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_cx::TransitionRouteGroupsClient( + google::cloud::dialogflow_cx::MakeTransitionRouteGroupsConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_cx:: @@ -150,6 +171,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -159,6 +183,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_cx/samples/versions_client_samples.cc b/google/cloud/dialogflow_cx/samples/versions_client_samples.cc index b233d01e837ae..5440b5ffd1c3c 100644 --- a/google/cloud/dialogflow_cx/samples/versions_client_samples.cc +++ b/google/cloud/dialogflow_cx/samples/versions_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_cx::VersionsClient( + google::cloud::dialogflow_cx::MakeVersionsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_cx::VersionsConnectionIdempotencyPolicy { @@ -184,6 +204,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -194,6 +217,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_cx/samples/webhooks_client_samples.cc b/google/cloud/dialogflow_cx/samples/webhooks_client_samples.cc index cf37b4adbc246..f409245bd6fa6 100644 --- a/google/cloud/dialogflow_cx/samples/webhooks_client_samples.cc +++ b/google/cloud/dialogflow_cx/samples/webhooks_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_cx::WebhooksClient( + google::cloud::dialogflow_cx::MakeWebhooksConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_cx::WebhooksConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_es/doc/override-universe-domain.dox b/google/cloud/dialogflow_es/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..8cb9fcc1c7b1d --- /dev/null +++ b/google/cloud/dialogflow_es/doc/override-universe-domain.dox @@ -0,0 +1,155 @@ +/*! +@page dialogflow_es-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `dialogflow_es::AgentsClient`: + +@snippet agents_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c dialogflow_es::AgentsClient](@ref dialogflow_es::AgentsClient-universe-domain-snippet) +- [\c dialogflow_es::AnswerRecordsClient](@ref dialogflow_es::AnswerRecordsClient-universe-domain-snippet) +- [\c dialogflow_es::ContextsClient](@ref dialogflow_es::ContextsClient-universe-domain-snippet) +- [\c dialogflow_es::ConversationDatasetsClient](@ref dialogflow_es::ConversationDatasetsClient-universe-domain-snippet) +- [\c dialogflow_es::ConversationModelsClient](@ref dialogflow_es::ConversationModelsClient-universe-domain-snippet) +- [\c dialogflow_es::ConversationProfilesClient](@ref dialogflow_es::ConversationProfilesClient-universe-domain-snippet) +- [\c dialogflow_es::ConversationsClient](@ref dialogflow_es::ConversationsClient-universe-domain-snippet) +- [\c dialogflow_es::DocumentsClient](@ref dialogflow_es::DocumentsClient-universe-domain-snippet) +- [\c dialogflow_es::EncryptionSpecServiceClient](@ref dialogflow_es::EncryptionSpecServiceClient-universe-domain-snippet) +- [\c dialogflow_es::EntityTypesClient](@ref dialogflow_es::EntityTypesClient-universe-domain-snippet) +- [\c dialogflow_es::EnvironmentsClient](@ref dialogflow_es::EnvironmentsClient-universe-domain-snippet) +- [\c dialogflow_es::FulfillmentsClient](@ref dialogflow_es::FulfillmentsClient-universe-domain-snippet) +- [\c dialogflow_es::GeneratorsClient](@ref dialogflow_es::GeneratorsClient-universe-domain-snippet) +- [\c dialogflow_es::IntentsClient](@ref dialogflow_es::IntentsClient-universe-domain-snippet) +- [\c dialogflow_es::KnowledgeBasesClient](@ref dialogflow_es::KnowledgeBasesClient-universe-domain-snippet) +- [\c dialogflow_es::ParticipantsClient](@ref dialogflow_es::ParticipantsClient-universe-domain-snippet) +- [\c dialogflow_es::SessionEntityTypesClient](@ref dialogflow_es::SessionEntityTypesClient-universe-domain-snippet) +- [\c dialogflow_es::SessionsClient](@ref dialogflow_es::SessionsClient-universe-domain-snippet) +- [\c dialogflow_es::VersionsClient](@ref dialogflow_es::VersionsClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page dialogflow_es::AgentsClient-universe-domain-snippet Override dialogflow_es::AgentsClient Universe Domain + +@snippet google/cloud/dialogflow_es/samples/agents_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_es::AnswerRecordsClient-universe-domain-snippet Override dialogflow_es::AnswerRecordsClient Universe Domain + +@snippet google/cloud/dialogflow_es/samples/answer_records_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_es::ContextsClient-universe-domain-snippet Override dialogflow_es::ContextsClient Universe Domain + +@snippet google/cloud/dialogflow_es/samples/contexts_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_es::ConversationDatasetsClient-universe-domain-snippet Override dialogflow_es::ConversationDatasetsClient Universe Domain + +@snippet google/cloud/dialogflow_es/samples/conversation_datasets_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_es::ConversationModelsClient-universe-domain-snippet Override dialogflow_es::ConversationModelsClient Universe Domain + +@snippet google/cloud/dialogflow_es/samples/conversation_models_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_es::ConversationProfilesClient-universe-domain-snippet Override dialogflow_es::ConversationProfilesClient Universe Domain + +@snippet google/cloud/dialogflow_es/samples/conversation_profiles_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_es::ConversationsClient-universe-domain-snippet Override dialogflow_es::ConversationsClient Universe Domain + +@snippet google/cloud/dialogflow_es/samples/conversations_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_es::DocumentsClient-universe-domain-snippet Override dialogflow_es::DocumentsClient Universe Domain + +@snippet google/cloud/dialogflow_es/samples/documents_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_es::EncryptionSpecServiceClient-universe-domain-snippet Override dialogflow_es::EncryptionSpecServiceClient Universe Domain + +@snippet google/cloud/dialogflow_es/samples/encryption_spec_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_es::EntityTypesClient-universe-domain-snippet Override dialogflow_es::EntityTypesClient Universe Domain + +@snippet google/cloud/dialogflow_es/samples/entity_types_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_es::EnvironmentsClient-universe-domain-snippet Override dialogflow_es::EnvironmentsClient Universe Domain + +@snippet google/cloud/dialogflow_es/samples/environments_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_es::FulfillmentsClient-universe-domain-snippet Override dialogflow_es::FulfillmentsClient Universe Domain + +@snippet google/cloud/dialogflow_es/samples/fulfillments_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_es::GeneratorsClient-universe-domain-snippet Override dialogflow_es::GeneratorsClient Universe Domain + +@snippet google/cloud/dialogflow_es/samples/generators_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_es::IntentsClient-universe-domain-snippet Override dialogflow_es::IntentsClient Universe Domain + +@snippet google/cloud/dialogflow_es/samples/intents_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_es::KnowledgeBasesClient-universe-domain-snippet Override dialogflow_es::KnowledgeBasesClient Universe Domain + +@snippet google/cloud/dialogflow_es/samples/knowledge_bases_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_es::ParticipantsClient-universe-domain-snippet Override dialogflow_es::ParticipantsClient Universe Domain + +@snippet google/cloud/dialogflow_es/samples/participants_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_es::SessionEntityTypesClient-universe-domain-snippet Override dialogflow_es::SessionEntityTypesClient Universe Domain + +@snippet google/cloud/dialogflow_es/samples/session_entity_types_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_es::SessionsClient-universe-domain-snippet Override dialogflow_es::SessionsClient Universe Domain + +@snippet google/cloud/dialogflow_es/samples/sessions_client_samples.cc set-client-universe-domain + +*/ + +/*! @page dialogflow_es::VersionsClient-universe-domain-snippet Override dialogflow_es::VersionsClient Universe Domain + +@snippet google/cloud/dialogflow_es/samples/versions_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/dialogflow_es/samples/agents_client_samples.cc b/google/cloud/dialogflow_es/samples/agents_client_samples.cc index fe88b24b5eb8c..19811d18d89db 100644 --- a/google/cloud/dialogflow_es/samples/agents_client_samples.cc +++ b/google/cloud/dialogflow_es/samples/agents_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_es::AgentsClient( + google::cloud::dialogflow_es::MakeAgentsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_es::AgentsConnectionIdempotencyPolicy { @@ -182,6 +202,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -192,6 +215,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_es/samples/answer_records_client_samples.cc b/google/cloud/dialogflow_es/samples/answer_records_client_samples.cc index abdbc76108201..337101d01cef4 100644 --- a/google/cloud/dialogflow_es/samples/answer_records_client_samples.cc +++ b/google/cloud/dialogflow_es/samples/answer_records_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_es::AnswerRecordsClient( + google::cloud::dialogflow_es::MakeAnswerRecordsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_es:: AnswerRecordsConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_es/samples/contexts_client_samples.cc b/google/cloud/dialogflow_es/samples/contexts_client_samples.cc index 6eb34481d888d..e7fc430bd1acb 100644 --- a/google/cloud/dialogflow_es/samples/contexts_client_samples.cc +++ b/google/cloud/dialogflow_es/samples/contexts_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_es::ContextsClient( + google::cloud::dialogflow_es::MakeContextsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_es::ContextsConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_es/samples/conversation_datasets_client_samples.cc b/google/cloud/dialogflow_es/samples/conversation_datasets_client_samples.cc index 5969735e9ce43..b88537b59dde0 100644 --- a/google/cloud/dialogflow_es/samples/conversation_datasets_client_samples.cc +++ b/google/cloud/dialogflow_es/samples/conversation_datasets_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_es::ConversationDatasetsClient( + google::cloud::dialogflow_es::MakeConversationDatasetsConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_es:: @@ -197,6 +218,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -207,6 +231,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_es/samples/conversation_models_client_samples.cc b/google/cloud/dialogflow_es/samples/conversation_models_client_samples.cc index bf9c4dbf0a14d..7100cad858c54 100644 --- a/google/cloud/dialogflow_es/samples/conversation_models_client_samples.cc +++ b/google/cloud/dialogflow_es/samples/conversation_models_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_es::ConversationModelsClient( + google::cloud::dialogflow_es::MakeConversationModelsConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_es:: @@ -192,6 +213,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -202,6 +226,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_es/samples/conversation_profiles_client_samples.cc b/google/cloud/dialogflow_es/samples/conversation_profiles_client_samples.cc index de780fd13b0ab..8a832e3e0b14f 100644 --- a/google/cloud/dialogflow_es/samples/conversation_profiles_client_samples.cc +++ b/google/cloud/dialogflow_es/samples/conversation_profiles_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_es::ConversationProfilesClient( + google::cloud::dialogflow_es::MakeConversationProfilesConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_es:: @@ -197,6 +218,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -207,6 +231,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_es/samples/conversations_client_samples.cc b/google/cloud/dialogflow_es/samples/conversations_client_samples.cc index e3476b8246b63..7eb1cfe51ee9a 100644 --- a/google/cloud/dialogflow_es/samples/conversations_client_samples.cc +++ b/google/cloud/dialogflow_es/samples/conversations_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_es::ConversationsClient( + google::cloud::dialogflow_es::MakeConversationsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_es:: ConversationsConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_es/samples/documents_client_samples.cc b/google/cloud/dialogflow_es/samples/documents_client_samples.cc index 426c7c2c5cf72..df7e75934adf4 100644 --- a/google/cloud/dialogflow_es/samples/documents_client_samples.cc +++ b/google/cloud/dialogflow_es/samples/documents_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_es::DocumentsClient( + google::cloud::dialogflow_es::MakeDocumentsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_es:: DocumentsConnectionIdempotencyPolicy { @@ -185,6 +205,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -195,6 +218,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_es/samples/encryption_spec_client_samples.cc b/google/cloud/dialogflow_es/samples/encryption_spec_client_samples.cc index 8db70a403b64c..403055128c045 100644 --- a/google/cloud/dialogflow_es/samples/encryption_spec_client_samples.cc +++ b/google/cloud/dialogflow_es/samples/encryption_spec_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_es::EncryptionSpecServiceClient( + google::cloud::dialogflow_es::MakeEncryptionSpecServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_es:: @@ -199,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -209,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_es/samples/entity_types_client_samples.cc b/google/cloud/dialogflow_es/samples/entity_types_client_samples.cc index 0aa15f01df59f..876bfdc58a031 100644 --- a/google/cloud/dialogflow_es/samples/entity_types_client_samples.cc +++ b/google/cloud/dialogflow_es/samples/entity_types_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_es::EntityTypesClient( + google::cloud::dialogflow_es::MakeEntityTypesConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_es:: EntityTypesConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_es/samples/environments_client_samples.cc b/google/cloud/dialogflow_es/samples/environments_client_samples.cc index e393987f1cc8e..7ab821dd63031 100644 --- a/google/cloud/dialogflow_es/samples/environments_client_samples.cc +++ b/google/cloud/dialogflow_es/samples/environments_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_es::EnvironmentsClient( + google::cloud::dialogflow_es::MakeEnvironmentsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_es:: EnvironmentsConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_es/samples/fulfillments_client_samples.cc b/google/cloud/dialogflow_es/samples/fulfillments_client_samples.cc index 33deda794b7b5..cb976e5efc7c0 100644 --- a/google/cloud/dialogflow_es/samples/fulfillments_client_samples.cc +++ b/google/cloud/dialogflow_es/samples/fulfillments_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_es::FulfillmentsClient( + google::cloud::dialogflow_es::MakeFulfillmentsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_es:: FulfillmentsConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_es/samples/generators_client_samples.cc b/google/cloud/dialogflow_es/samples/generators_client_samples.cc index f95571a7aba5b..71715a6d748ec 100644 --- a/google/cloud/dialogflow_es/samples/generators_client_samples.cc +++ b/google/cloud/dialogflow_es/samples/generators_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_es::GeneratorsClient( + google::cloud::dialogflow_es::MakeGeneratorsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_es:: GeneratorsConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_es/samples/intents_client_samples.cc b/google/cloud/dialogflow_es/samples/intents_client_samples.cc index 781be2842cdd4..7d24a9355b935 100644 --- a/google/cloud/dialogflow_es/samples/intents_client_samples.cc +++ b/google/cloud/dialogflow_es/samples/intents_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_es::IntentsClient( + google::cloud::dialogflow_es::MakeIntentsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_es::IntentsConnectionIdempotencyPolicy { @@ -184,6 +204,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -194,6 +217,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_es/samples/knowledge_bases_client_samples.cc b/google/cloud/dialogflow_es/samples/knowledge_bases_client_samples.cc index ce632a695f4ed..b678c35dd8061 100644 --- a/google/cloud/dialogflow_es/samples/knowledge_bases_client_samples.cc +++ b/google/cloud/dialogflow_es/samples/knowledge_bases_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_es::KnowledgeBasesClient( + google::cloud::dialogflow_es::MakeKnowledgeBasesConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_es:: KnowledgeBasesConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_es/samples/participants_client_samples.cc b/google/cloud/dialogflow_es/samples/participants_client_samples.cc index f34d86634472c..1128fba3e4e7c 100644 --- a/google/cloud/dialogflow_es/samples/participants_client_samples.cc +++ b/google/cloud/dialogflow_es/samples/participants_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_es::ParticipantsClient( + google::cloud::dialogflow_es::MakeParticipantsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_es:: ParticipantsConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_es/samples/session_entity_types_client_samples.cc b/google/cloud/dialogflow_es/samples/session_entity_types_client_samples.cc index 02210ff68db77..68b6a1e8f3f51 100644 --- a/google/cloud/dialogflow_es/samples/session_entity_types_client_samples.cc +++ b/google/cloud/dialogflow_es/samples/session_entity_types_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_es::SessionEntityTypesClient( + google::cloud::dialogflow_es::MakeSessionEntityTypesConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_es:: @@ -146,6 +167,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -155,6 +179,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_es/samples/sessions_client_samples.cc b/google/cloud/dialogflow_es/samples/sessions_client_samples.cc index b7afed8c6b8e0..65e7f19532d32 100644 --- a/google/cloud/dialogflow_es/samples/sessions_client_samples.cc +++ b/google/cloud/dialogflow_es/samples/sessions_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_es::SessionsClient( + google::cloud::dialogflow_es::MakeSessionsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_es::SessionsConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dialogflow_es/samples/versions_client_samples.cc b/google/cloud/dialogflow_es/samples/versions_client_samples.cc index 129cf4cdc2ffb..c38ab6913a239 100644 --- a/google/cloud/dialogflow_es/samples/versions_client_samples.cc +++ b/google/cloud/dialogflow_es/samples/versions_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dialogflow_es::VersionsClient( + google::cloud::dialogflow_es::MakeVersionsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dialogflow_es::VersionsConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/discoveryengine/doc/override-universe-domain.dox b/google/cloud/discoveryengine/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..97a0a1e7fc5c6 --- /dev/null +++ b/google/cloud/discoveryengine/doc/override-universe-domain.dox @@ -0,0 +1,120 @@ +/*! +@page discoveryengine-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `discoveryengine_v1::CompletionServiceClient`: + +@snippet completion_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c discoveryengine_v1::CompletionServiceClient](@ref discoveryengine_v1::CompletionServiceClient-universe-domain-snippet) +- [\c discoveryengine_v1::ControlServiceClient](@ref discoveryengine_v1::ControlServiceClient-universe-domain-snippet) +- [\c discoveryengine_v1::ConversationalSearchServiceClient](@ref discoveryengine_v1::ConversationalSearchServiceClient-universe-domain-snippet) +- [\c discoveryengine_v1::DataStoreServiceClient](@ref discoveryengine_v1::DataStoreServiceClient-universe-domain-snippet) +- [\c discoveryengine_v1::DocumentServiceClient](@ref discoveryengine_v1::DocumentServiceClient-universe-domain-snippet) +- [\c discoveryengine_v1::EngineServiceClient](@ref discoveryengine_v1::EngineServiceClient-universe-domain-snippet) +- [\c discoveryengine_v1::GroundedGenerationServiceClient](@ref discoveryengine_v1::GroundedGenerationServiceClient-universe-domain-snippet) +- [\c discoveryengine_v1::ProjectServiceClient](@ref discoveryengine_v1::ProjectServiceClient-universe-domain-snippet) +- [\c discoveryengine_v1::RankServiceClient](@ref discoveryengine_v1::RankServiceClient-universe-domain-snippet) +- [\c discoveryengine_v1::RecommendationServiceClient](@ref discoveryengine_v1::RecommendationServiceClient-universe-domain-snippet) +- [\c discoveryengine_v1::SchemaServiceClient](@ref discoveryengine_v1::SchemaServiceClient-universe-domain-snippet) +- [\c discoveryengine_v1::SearchServiceClient](@ref discoveryengine_v1::SearchServiceClient-universe-domain-snippet) +- [\c discoveryengine_v1::SiteSearchEngineServiceClient](@ref discoveryengine_v1::SiteSearchEngineServiceClient-universe-domain-snippet) +- [\c discoveryengine_v1::UserEventServiceClient](@ref discoveryengine_v1::UserEventServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page discoveryengine_v1::CompletionServiceClient-universe-domain-snippet Override discoveryengine_v1::CompletionServiceClient Universe Domain + +@snippet google/cloud/discoveryengine/v1/samples/completion_client_samples.cc set-client-universe-domain + +*/ + +/*! @page discoveryengine_v1::ControlServiceClient-universe-domain-snippet Override discoveryengine_v1::ControlServiceClient Universe Domain + +@snippet google/cloud/discoveryengine/v1/samples/control_client_samples.cc set-client-universe-domain + +*/ + +/*! @page discoveryengine_v1::ConversationalSearchServiceClient-universe-domain-snippet Override discoveryengine_v1::ConversationalSearchServiceClient Universe Domain + +@snippet google/cloud/discoveryengine/v1/samples/conversational_search_client_samples.cc set-client-universe-domain + +*/ + +/*! @page discoveryengine_v1::DataStoreServiceClient-universe-domain-snippet Override discoveryengine_v1::DataStoreServiceClient Universe Domain + +@snippet google/cloud/discoveryengine/v1/samples/data_store_client_samples.cc set-client-universe-domain + +*/ + +/*! @page discoveryengine_v1::DocumentServiceClient-universe-domain-snippet Override discoveryengine_v1::DocumentServiceClient Universe Domain + +@snippet google/cloud/discoveryengine/v1/samples/document_client_samples.cc set-client-universe-domain + +*/ + +/*! @page discoveryengine_v1::EngineServiceClient-universe-domain-snippet Override discoveryengine_v1::EngineServiceClient Universe Domain + +@snippet google/cloud/discoveryengine/v1/samples/engine_client_samples.cc set-client-universe-domain + +*/ + +/*! @page discoveryengine_v1::GroundedGenerationServiceClient-universe-domain-snippet Override discoveryengine_v1::GroundedGenerationServiceClient Universe Domain + +@snippet google/cloud/discoveryengine/v1/samples/grounded_generation_client_samples.cc set-client-universe-domain + +*/ + +/*! @page discoveryengine_v1::ProjectServiceClient-universe-domain-snippet Override discoveryengine_v1::ProjectServiceClient Universe Domain + +@snippet google/cloud/discoveryengine/v1/samples/project_client_samples.cc set-client-universe-domain + +*/ + +/*! @page discoveryengine_v1::RankServiceClient-universe-domain-snippet Override discoveryengine_v1::RankServiceClient Universe Domain + +@snippet google/cloud/discoveryengine/v1/samples/rank_client_samples.cc set-client-universe-domain + +*/ + +/*! @page discoveryengine_v1::RecommendationServiceClient-universe-domain-snippet Override discoveryengine_v1::RecommendationServiceClient Universe Domain + +@snippet google/cloud/discoveryengine/v1/samples/recommendation_client_samples.cc set-client-universe-domain + +*/ + +/*! @page discoveryengine_v1::SchemaServiceClient-universe-domain-snippet Override discoveryengine_v1::SchemaServiceClient Universe Domain + +@snippet google/cloud/discoveryengine/v1/samples/schema_client_samples.cc set-client-universe-domain + +*/ + +/*! @page discoveryengine_v1::SearchServiceClient-universe-domain-snippet Override discoveryengine_v1::SearchServiceClient Universe Domain + +@snippet google/cloud/discoveryengine/v1/samples/search_client_samples.cc set-client-universe-domain + +*/ + +/*! @page discoveryengine_v1::SiteSearchEngineServiceClient-universe-domain-snippet Override discoveryengine_v1::SiteSearchEngineServiceClient Universe Domain + +@snippet google/cloud/discoveryengine/v1/samples/site_search_engine_client_samples.cc set-client-universe-domain + +*/ + +/*! @page discoveryengine_v1::UserEventServiceClient-universe-domain-snippet Override discoveryengine_v1::UserEventServiceClient Universe Domain + +@snippet google/cloud/discoveryengine/v1/samples/user_event_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/discoveryengine/v1/samples/completion_client_samples.cc b/google/cloud/discoveryengine/v1/samples/completion_client_samples.cc index ad29939eaa1ce..ff94cc273855d 100644 --- a/google/cloud/discoveryengine/v1/samples/completion_client_samples.cc +++ b/google/cloud/discoveryengine/v1/samples/completion_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::discoveryengine_v1::CompletionServiceClient( + google::cloud::discoveryengine_v1::MakeCompletionServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::discoveryengine_v1:: @@ -199,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -209,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/discoveryengine/v1/samples/control_client_samples.cc b/google/cloud/discoveryengine/v1/samples/control_client_samples.cc index aa1a24a592587..a96f10b263cd0 100644 --- a/google/cloud/discoveryengine/v1/samples/control_client_samples.cc +++ b/google/cloud/discoveryengine/v1/samples/control_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::discoveryengine_v1::ControlServiceClient( + google::cloud::discoveryengine_v1::MakeControlServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::discoveryengine_v1:: ControlServiceConnectionIdempotencyPolicy { @@ -144,6 +165,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -153,6 +177,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/discoveryengine/v1/samples/conversational_search_client_samples.cc b/google/cloud/discoveryengine/v1/samples/conversational_search_client_samples.cc index 880ea304ed1f3..4e587af2e0497 100644 --- a/google/cloud/discoveryengine/v1/samples/conversational_search_client_samples.cc +++ b/google/cloud/discoveryengine/v1/samples/conversational_search_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::discoveryengine_v1::ConversationalSearchServiceClient( + google::cloud::discoveryengine_v1:: + MakeConversationalSearchServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::discoveryengine_v1:: @@ -155,6 +177,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -164,6 +189,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/discoveryengine/v1/samples/data_store_client_samples.cc b/google/cloud/discoveryengine/v1/samples/data_store_client_samples.cc index aabfb2d66ae8b..88602a609e18e 100644 --- a/google/cloud/discoveryengine/v1/samples/data_store_client_samples.cc +++ b/google/cloud/discoveryengine/v1/samples/data_store_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::discoveryengine_v1::DataStoreServiceClient( + google::cloud::discoveryengine_v1::MakeDataStoreServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::discoveryengine_v1:: @@ -199,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -209,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/discoveryengine/v1/samples/document_client_samples.cc b/google/cloud/discoveryengine/v1/samples/document_client_samples.cc index d4fe058ad9942..feb676c9efadd 100644 --- a/google/cloud/discoveryengine/v1/samples/document_client_samples.cc +++ b/google/cloud/discoveryengine/v1/samples/document_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::discoveryengine_v1::DocumentServiceClient( + google::cloud::discoveryengine_v1::MakeDocumentServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::discoveryengine_v1:: DocumentServiceConnectionIdempotencyPolicy { @@ -195,6 +216,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -205,6 +229,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/discoveryengine/v1/samples/engine_client_samples.cc b/google/cloud/discoveryengine/v1/samples/engine_client_samples.cc index d1565a1425133..6f0f4a57cc1a2 100644 --- a/google/cloud/discoveryengine/v1/samples/engine_client_samples.cc +++ b/google/cloud/discoveryengine/v1/samples/engine_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::discoveryengine_v1::EngineServiceClient( + google::cloud::discoveryengine_v1::MakeEngineServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::discoveryengine_v1:: EngineServiceConnectionIdempotencyPolicy { @@ -190,6 +211,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -200,6 +224,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/discoveryengine/v1/samples/grounded_generation_client_samples.cc b/google/cloud/discoveryengine/v1/samples/grounded_generation_client_samples.cc index 881cb4bdda65b..faa48b46948a8 100644 --- a/google/cloud/discoveryengine/v1/samples/grounded_generation_client_samples.cc +++ b/google/cloud/discoveryengine/v1/samples/grounded_generation_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::discoveryengine_v1::GroundedGenerationServiceClient( + google::cloud::discoveryengine_v1:: + MakeGroundedGenerationServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::discoveryengine_v1:: @@ -150,6 +172,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -159,6 +184,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/discoveryengine/v1/samples/project_client_samples.cc b/google/cloud/discoveryengine/v1/samples/project_client_samples.cc index ae265dc7441d2..283dcc668eb5b 100644 --- a/google/cloud/discoveryengine/v1/samples/project_client_samples.cc +++ b/google/cloud/discoveryengine/v1/samples/project_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::discoveryengine_v1::ProjectServiceClient( + google::cloud::discoveryengine_v1::MakeProjectServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::discoveryengine_v1:: ProjectServiceConnectionIdempotencyPolicy { @@ -190,6 +211,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -200,6 +224,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/discoveryengine/v1/samples/rank_client_samples.cc b/google/cloud/discoveryengine/v1/samples/rank_client_samples.cc index ad3c884b0189a..c9e167a8810b3 100644 --- a/google/cloud/discoveryengine/v1/samples/rank_client_samples.cc +++ b/google/cloud/discoveryengine/v1/samples/rank_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::discoveryengine_v1::RankServiceClient( + google::cloud::discoveryengine_v1::MakeRankServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::discoveryengine_v1:: RankServiceConnectionIdempotencyPolicy { @@ -142,6 +163,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -151,6 +175,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/discoveryengine/v1/samples/recommendation_client_samples.cc b/google/cloud/discoveryengine/v1/samples/recommendation_client_samples.cc index eadebaaddf289..c7ab131cd0046 100644 --- a/google/cloud/discoveryengine/v1/samples/recommendation_client_samples.cc +++ b/google/cloud/discoveryengine/v1/samples/recommendation_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::discoveryengine_v1::RecommendationServiceClient( + google::cloud::discoveryengine_v1:: + MakeRecommendationServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::discoveryengine_v1:: @@ -151,6 +173,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -160,6 +185,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/discoveryengine/v1/samples/schema_client_samples.cc b/google/cloud/discoveryengine/v1/samples/schema_client_samples.cc index bed1e319d761e..e7fa19ab40c43 100644 --- a/google/cloud/discoveryengine/v1/samples/schema_client_samples.cc +++ b/google/cloud/discoveryengine/v1/samples/schema_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::discoveryengine_v1::SchemaServiceClient( + google::cloud::discoveryengine_v1::MakeSchemaServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::discoveryengine_v1:: SchemaServiceConnectionIdempotencyPolicy { @@ -190,6 +211,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -200,6 +224,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/discoveryengine/v1/samples/search_client_samples.cc b/google/cloud/discoveryengine/v1/samples/search_client_samples.cc index 0219b0f94c042..e30d47970b040 100644 --- a/google/cloud/discoveryengine/v1/samples/search_client_samples.cc +++ b/google/cloud/discoveryengine/v1/samples/search_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::discoveryengine_v1::SearchServiceClient( + google::cloud::discoveryengine_v1::MakeSearchServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::discoveryengine_v1:: SearchServiceConnectionIdempotencyPolicy { @@ -144,6 +165,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -153,6 +177,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/discoveryengine/v1/samples/site_search_engine_client_samples.cc b/google/cloud/discoveryengine/v1/samples/site_search_engine_client_samples.cc index 767dddc889cf3..b603d597aca29 100644 --- a/google/cloud/discoveryengine/v1/samples/site_search_engine_client_samples.cc +++ b/google/cloud/discoveryengine/v1/samples/site_search_engine_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::discoveryengine_v1::SiteSearchEngineServiceClient( + google::cloud::discoveryengine_v1:: + MakeSiteSearchEngineServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::discoveryengine_v1:: @@ -200,6 +222,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -210,6 +235,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/discoveryengine/v1/samples/user_event_client_samples.cc b/google/cloud/discoveryengine/v1/samples/user_event_client_samples.cc index a71f219124f2d..7faebb9b92333 100644 --- a/google/cloud/discoveryengine/v1/samples/user_event_client_samples.cc +++ b/google/cloud/discoveryengine/v1/samples/user_event_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::discoveryengine_v1::UserEventServiceClient( + google::cloud::discoveryengine_v1::MakeUserEventServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::discoveryengine_v1:: @@ -199,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -209,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/dlp/doc/override-universe-domain.dox b/google/cloud/dlp/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..2bc05c50fbec7 --- /dev/null +++ b/google/cloud/dlp/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page dlp-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `dlp_v2::DlpServiceClient`: + +@snippet dlp_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page dlp_v2::DlpServiceClient-universe-domain-snippet Override dlp_v2::DlpServiceClient Universe Domain + +@snippet google/cloud/dlp/v2/samples/dlp_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/dlp/v2/samples/dlp_client_samples.cc b/google/cloud/dlp/v2/samples/dlp_client_samples.cc index b3507ffe19259..5233105bc4f66 100644 --- a/google/cloud/dlp/v2/samples/dlp_client_samples.cc +++ b/google/cloud/dlp/v2/samples/dlp_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::dlp_v2::DlpServiceClient( + google::cloud::dlp_v2::MakeDlpServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::dlp_v2::DlpServiceConnectionIdempotencyPolicy { @@ -138,6 +158,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -147,6 +170,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/documentai/doc/override-universe-domain.dox b/google/cloud/documentai/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..e62b4fd81ef9a --- /dev/null +++ b/google/cloud/documentai/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page documentai-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `documentai_v1::DocumentProcessorServiceClient`: + +@snippet document_processor_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page documentai_v1::DocumentProcessorServiceClient-universe-domain-snippet Override documentai_v1::DocumentProcessorServiceClient Universe Domain + +@snippet google/cloud/documentai/v1/samples/document_processor_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/documentai/v1/samples/document_processor_client_samples.cc b/google/cloud/documentai/v1/samples/document_processor_client_samples.cc index 509c6107c3cc4..691d46e7fc317 100644 --- a/google/cloud/documentai/v1/samples/document_processor_client_samples.cc +++ b/google/cloud/documentai/v1/samples/document_processor_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::documentai_v1::DocumentProcessorServiceClient( + google::cloud::documentai_v1::MakeDocumentProcessorServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::documentai_v1:: @@ -200,6 +221,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -210,6 +234,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/domains/doc/override-universe-domain.dox b/google/cloud/domains/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..83be746935522 --- /dev/null +++ b/google/cloud/domains/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page domains-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `domains_v1::DomainsClient`: + +@snippet domains_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page domains_v1::DomainsClient-universe-domain-snippet Override domains_v1::DomainsClient Universe Domain + +@snippet google/cloud/domains/v1/samples/domains_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/domains/v1/samples/domains_client_samples.cc b/google/cloud/domains/v1/samples/domains_client_samples.cc index d30a4b6d3bf1f..6f3e249e1c906 100644 --- a/google/cloud/domains/v1/samples/domains_client_samples.cc +++ b/google/cloud/domains/v1/samples/domains_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::domains_v1::DomainsClient( + google::cloud::domains_v1::MakeDomainsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::domains_v1::DomainsConnectionIdempotencyPolicy { @@ -179,6 +199,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -189,6 +212,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/edgecontainer/doc/override-universe-domain.dox b/google/cloud/edgecontainer/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..5defae4892839 --- /dev/null +++ b/google/cloud/edgecontainer/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page edgecontainer-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `edgecontainer_v1::EdgeContainerClient`: + +@snippet edge_container_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page edgecontainer_v1::EdgeContainerClient-universe-domain-snippet Override edgecontainer_v1::EdgeContainerClient Universe Domain + +@snippet google/cloud/edgecontainer/v1/samples/edge_container_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/edgecontainer/v1/samples/edge_container_client_samples.cc b/google/cloud/edgecontainer/v1/samples/edge_container_client_samples.cc index f0016ecc1de34..3caa322ef9f14 100644 --- a/google/cloud/edgecontainer/v1/samples/edge_container_client_samples.cc +++ b/google/cloud/edgecontainer/v1/samples/edge_container_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::edgecontainer_v1::EdgeContainerClient( + google::cloud::edgecontainer_v1::MakeEdgeContainerConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::edgecontainer_v1:: EdgeContainerConnectionIdempotencyPolicy { @@ -188,6 +209,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -198,6 +222,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/edgenetwork/doc/override-universe-domain.dox b/google/cloud/edgenetwork/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..ed94aa80314df --- /dev/null +++ b/google/cloud/edgenetwork/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page edgenetwork-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `edgenetwork_v1::EdgeNetworkClient`: + +@snippet edge_network_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page edgenetwork_v1::EdgeNetworkClient-universe-domain-snippet Override edgenetwork_v1::EdgeNetworkClient Universe Domain + +@snippet google/cloud/edgenetwork/v1/samples/edge_network_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/edgenetwork/v1/samples/edge_network_client_samples.cc b/google/cloud/edgenetwork/v1/samples/edge_network_client_samples.cc index deac9b9c36ad7..70574742ef4df 100644 --- a/google/cloud/edgenetwork/v1/samples/edge_network_client_samples.cc +++ b/google/cloud/edgenetwork/v1/samples/edge_network_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::edgenetwork_v1::EdgeNetworkClient( + google::cloud::edgenetwork_v1::MakeEdgeNetworkConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::edgenetwork_v1:: EdgeNetworkConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/essentialcontacts/doc/override-universe-domain.dox b/google/cloud/essentialcontacts/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..b3a9e0f007f4c --- /dev/null +++ b/google/cloud/essentialcontacts/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page essentialcontacts-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `essentialcontacts_v1::EssentialContactsServiceClient`: + +@snippet essential_contacts_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page essentialcontacts_v1::EssentialContactsServiceClient-universe-domain-snippet Override essentialcontacts_v1::EssentialContactsServiceClient Universe Domain + +@snippet google/cloud/essentialcontacts/v1/samples/essential_contacts_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/essentialcontacts/v1/samples/essential_contacts_client_samples.cc b/google/cloud/essentialcontacts/v1/samples/essential_contacts_client_samples.cc index bffc4e8829ee8..f015341aaadf6 100644 --- a/google/cloud/essentialcontacts/v1/samples/essential_contacts_client_samples.cc +++ b/google/cloud/essentialcontacts/v1/samples/essential_contacts_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::essentialcontacts_v1::EssentialContactsServiceClient( + google::cloud::essentialcontacts_v1:: + MakeEssentialContactsServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::essentialcontacts_v1:: @@ -150,6 +172,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -159,6 +184,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/eventarc/doc/override-universe-domain.dox b/google/cloud/eventarc/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..5218a2d78f92a --- /dev/null +++ b/google/cloud/eventarc/doc/override-universe-domain.dox @@ -0,0 +1,36 @@ +/*! +@page eventarc-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `eventarc_publishing_v1::PublisherClient`: + +@snippet publisher_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c eventarc_publishing_v1::PublisherClient](@ref eventarc_publishing_v1::PublisherClient-universe-domain-snippet) +- [\c eventarc_v1::EventarcClient](@ref eventarc_v1::EventarcClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page eventarc_publishing_v1::PublisherClient-universe-domain-snippet Override eventarc_publishing_v1::PublisherClient Universe Domain + +@snippet google/cloud/eventarc/publishing/v1/samples/publisher_client_samples.cc set-client-universe-domain + +*/ + +/*! @page eventarc_v1::EventarcClient-universe-domain-snippet Override eventarc_v1::EventarcClient Universe Domain + +@snippet google/cloud/eventarc/v1/samples/eventarc_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/eventarc/publishing/v1/samples/publisher_client_samples.cc b/google/cloud/eventarc/publishing/v1/samples/publisher_client_samples.cc index 0afb948a04d95..860fae711d384 100644 --- a/google/cloud/eventarc/publishing/v1/samples/publisher_client_samples.cc +++ b/google/cloud/eventarc/publishing/v1/samples/publisher_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::eventarc_publishing_v1::PublisherClient( + google::cloud::eventarc_publishing_v1::MakePublisherConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::eventarc_publishing_v1:: PublisherConnectionIdempotencyPolicy { @@ -144,6 +165,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -153,6 +177,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/eventarc/v1/samples/eventarc_client_samples.cc b/google/cloud/eventarc/v1/samples/eventarc_client_samples.cc index 832bb94d5a0b0..91cb399c71182 100644 --- a/google/cloud/eventarc/v1/samples/eventarc_client_samples.cc +++ b/google/cloud/eventarc/v1/samples/eventarc_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::eventarc_v1::EventarcClient( + google::cloud::eventarc_v1::MakeEventarcConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::eventarc_v1::EventarcConnectionIdempotencyPolicy { @@ -182,6 +202,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -192,6 +215,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/filestore/doc/override-universe-domain.dox b/google/cloud/filestore/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..cf9bc4287e767 --- /dev/null +++ b/google/cloud/filestore/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page filestore-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `filestore_v1::CloudFilestoreManagerClient`: + +@snippet cloud_filestore_manager_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page filestore_v1::CloudFilestoreManagerClient-universe-domain-snippet Override filestore_v1::CloudFilestoreManagerClient Universe Domain + +@snippet google/cloud/filestore/v1/samples/cloud_filestore_manager_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/filestore/v1/samples/cloud_filestore_manager_client_samples.cc b/google/cloud/filestore/v1/samples/cloud_filestore_manager_client_samples.cc index 61e3c8a86d407..9791f8238ba06 100644 --- a/google/cloud/filestore/v1/samples/cloud_filestore_manager_client_samples.cc +++ b/google/cloud/filestore/v1/samples/cloud_filestore_manager_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::filestore_v1::CloudFilestoreManagerClient( + google::cloud::filestore_v1::MakeCloudFilestoreManagerConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::filestore_v1:: @@ -197,6 +218,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -207,6 +231,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/financialservices/doc/override-universe-domain.dox b/google/cloud/financialservices/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..94f8142bca881 --- /dev/null +++ b/google/cloud/financialservices/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page financialservices-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `financialservices_v1::AMLClient`: + +@snippet aml_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page financialservices_v1::AMLClient-universe-domain-snippet Override financialservices_v1::AMLClient Universe Domain + +@snippet google/cloud/financialservices/v1/samples/aml_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/financialservices/v1/samples/aml_client_samples.cc b/google/cloud/financialservices/v1/samples/aml_client_samples.cc index 9d4f88c09579a..ce4bf6f56694d 100644 --- a/google/cloud/financialservices/v1/samples/aml_client_samples.cc +++ b/google/cloud/financialservices/v1/samples/aml_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::financialservices_v1::AMLClient( + google::cloud::financialservices_v1::MakeAMLConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::financialservices_v1:: AMLConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/functions/doc/override-universe-domain.dox b/google/cloud/functions/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..0758c268721e2 --- /dev/null +++ b/google/cloud/functions/doc/override-universe-domain.dox @@ -0,0 +1,36 @@ +/*! +@page functions-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `functions_v1::CloudFunctionsServiceClient`: + +@snippet cloud_functions_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c functions_v1::CloudFunctionsServiceClient](@ref functions_v1::CloudFunctionsServiceClient-universe-domain-snippet) +- [\c functions_v2::FunctionServiceClient](@ref functions_v2::FunctionServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page functions_v1::CloudFunctionsServiceClient-universe-domain-snippet Override functions_v1::CloudFunctionsServiceClient Universe Domain + +@snippet google/cloud/functions/v1/samples/cloud_functions_client_samples.cc set-client-universe-domain + +*/ + +/*! @page functions_v2::FunctionServiceClient-universe-domain-snippet Override functions_v2::FunctionServiceClient Universe Domain + +@snippet google/cloud/functions/v2/samples/function_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/functions/v1/samples/cloud_functions_client_samples.cc b/google/cloud/functions/v1/samples/cloud_functions_client_samples.cc index 45a363f618ac8..92f6b26baf38e 100644 --- a/google/cloud/functions/v1/samples/cloud_functions_client_samples.cc +++ b/google/cloud/functions/v1/samples/cloud_functions_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::functions_v1::CloudFunctionsServiceClient( + google::cloud::functions_v1::MakeCloudFunctionsServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::functions_v1:: @@ -197,6 +218,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -207,6 +231,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/functions/v2/samples/function_client_samples.cc b/google/cloud/functions/v2/samples/function_client_samples.cc index f1e599e846981..ab6f3f2fd3ad3 100644 --- a/google/cloud/functions/v2/samples/function_client_samples.cc +++ b/google/cloud/functions/v2/samples/function_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::functions_v2::FunctionServiceClient( + google::cloud::functions_v2::MakeFunctionServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::functions_v2:: FunctionServiceConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/gkebackup/doc/override-universe-domain.dox b/google/cloud/gkebackup/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..c6fe664f69fef --- /dev/null +++ b/google/cloud/gkebackup/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page gkebackup-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `gkebackup_v1::BackupForGKEClient`: + +@snippet backup_for_gke_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page gkebackup_v1::BackupForGKEClient-universe-domain-snippet Override gkebackup_v1::BackupForGKEClient Universe Domain + +@snippet google/cloud/gkebackup/v1/samples/backup_for_gke_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/gkebackup/v1/samples/backup_for_gke_client_samples.cc b/google/cloud/gkebackup/v1/samples/backup_for_gke_client_samples.cc index ce5ad632bc570..d9cd511df15f9 100644 --- a/google/cloud/gkebackup/v1/samples/backup_for_gke_client_samples.cc +++ b/google/cloud/gkebackup/v1/samples/backup_for_gke_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::gkebackup_v1::BackupForGKEClient( + google::cloud::gkebackup_v1::MakeBackupForGKEConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::gkebackup_v1:: BackupForGKEConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/gkeconnect/doc/override-universe-domain.dox b/google/cloud/gkeconnect/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..714a60ef955f0 --- /dev/null +++ b/google/cloud/gkeconnect/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page gkeconnect-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `gkeconnect_gateway_v1::GatewayControlClient`: + +@snippet gateway_control_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page gkeconnect_gateway_v1::GatewayControlClient-universe-domain-snippet Override gkeconnect_gateway_v1::GatewayControlClient Universe Domain + +@snippet google/cloud/gkeconnect/gateway/v1/samples/gateway_control_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/gkeconnect/gateway/v1/samples/gateway_control_client_samples.cc b/google/cloud/gkeconnect/gateway/v1/samples/gateway_control_client_samples.cc index 7d0ee9fe6f4cb..c5a05f4b7999f 100644 --- a/google/cloud/gkeconnect/gateway/v1/samples/gateway_control_client_samples.cc +++ b/google/cloud/gkeconnect/gateway/v1/samples/gateway_control_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::gkeconnect_gateway_v1::GatewayControlClient( + google::cloud::gkeconnect_gateway_v1::MakeGatewayControlConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::gkeconnect_gateway_v1:: GatewayControlConnectionIdempotencyPolicy { @@ -148,6 +169,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -157,6 +181,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/gkehub/doc/override-universe-domain.dox b/google/cloud/gkehub/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..daca744f16d43 --- /dev/null +++ b/google/cloud/gkehub/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page gkehub-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `gkehub_v1::GkeHubClient`: + +@snippet gke_hub_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page gkehub_v1::GkeHubClient-universe-domain-snippet Override gkehub_v1::GkeHubClient Universe Domain + +@snippet google/cloud/gkehub/v1/samples/gke_hub_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/gkehub/v1/samples/gke_hub_client_samples.cc b/google/cloud/gkehub/v1/samples/gke_hub_client_samples.cc index d4ba02e9aa5ab..dbd8565f251b0 100644 --- a/google/cloud/gkehub/v1/samples/gke_hub_client_samples.cc +++ b/google/cloud/gkehub/v1/samples/gke_hub_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::gkehub_v1::GkeHubClient( + google::cloud::gkehub_v1::MakeGkeHubConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::gkehub_v1::GkeHubConnectionIdempotencyPolicy { @@ -179,6 +199,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -189,6 +212,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/gkemulticloud/doc/override-universe-domain.dox b/google/cloud/gkemulticloud/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..4ad2367f75a7d --- /dev/null +++ b/google/cloud/gkemulticloud/doc/override-universe-domain.dox @@ -0,0 +1,43 @@ +/*! +@page gkemulticloud-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `gkemulticloud_v1::AttachedClustersClient`: + +@snippet attached_clusters_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c gkemulticloud_v1::AttachedClustersClient](@ref gkemulticloud_v1::AttachedClustersClient-universe-domain-snippet) +- [\c gkemulticloud_v1::AwsClustersClient](@ref gkemulticloud_v1::AwsClustersClient-universe-domain-snippet) +- [\c gkemulticloud_v1::AzureClustersClient](@ref gkemulticloud_v1::AzureClustersClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page gkemulticloud_v1::AttachedClustersClient-universe-domain-snippet Override gkemulticloud_v1::AttachedClustersClient Universe Domain + +@snippet google/cloud/gkemulticloud/v1/samples/attached_clusters_client_samples.cc set-client-universe-domain + +*/ + +/*! @page gkemulticloud_v1::AwsClustersClient-universe-domain-snippet Override gkemulticloud_v1::AwsClustersClient Universe Domain + +@snippet google/cloud/gkemulticloud/v1/samples/aws_clusters_client_samples.cc set-client-universe-domain + +*/ + +/*! @page gkemulticloud_v1::AzureClustersClient-universe-domain-snippet Override gkemulticloud_v1::AzureClustersClient Universe Domain + +@snippet google/cloud/gkemulticloud/v1/samples/azure_clusters_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/gkemulticloud/v1/samples/attached_clusters_client_samples.cc b/google/cloud/gkemulticloud/v1/samples/attached_clusters_client_samples.cc index 35e720db58390..fd624a92b8919 100644 --- a/google/cloud/gkemulticloud/v1/samples/attached_clusters_client_samples.cc +++ b/google/cloud/gkemulticloud/v1/samples/attached_clusters_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::gkemulticloud_v1::AttachedClustersClient( + google::cloud::gkemulticloud_v1::MakeAttachedClustersConnection( + "unused", *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::gkemulticloud_v1:: @@ -195,6 +216,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -205,6 +229,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/gkemulticloud/v1/samples/aws_clusters_client_samples.cc b/google/cloud/gkemulticloud/v1/samples/aws_clusters_client_samples.cc index c7239e9c15539..b668a7b12ac3b 100644 --- a/google/cloud/gkemulticloud/v1/samples/aws_clusters_client_samples.cc +++ b/google/cloud/gkemulticloud/v1/samples/aws_clusters_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::gkemulticloud_v1::AwsClustersClient( + google::cloud::gkemulticloud_v1::MakeAwsClustersConnection("unused", + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::gkemulticloud_v1:: AwsClustersConnectionIdempotencyPolicy { @@ -188,6 +209,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -198,6 +222,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/gkemulticloud/v1/samples/azure_clusters_client_samples.cc b/google/cloud/gkemulticloud/v1/samples/azure_clusters_client_samples.cc index f72af381eb4de..f46807b8b2bdc 100644 --- a/google/cloud/gkemulticloud/v1/samples/azure_clusters_client_samples.cc +++ b/google/cloud/gkemulticloud/v1/samples/azure_clusters_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::gkemulticloud_v1::AzureClustersClient( + google::cloud::gkemulticloud_v1::MakeAzureClustersConnection( + "unused", *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::gkemulticloud_v1:: AzureClustersConnectionIdempotencyPolicy { @@ -192,6 +213,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -202,6 +226,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/google_cloud_cpp_universe_domain.cmake b/google/cloud/google_cloud_cpp_universe_domain.cmake index cf16f8ab88870..e5e74b599aa05 100644 --- a/google/cloud/google_cloud_cpp_universe_domain.cmake +++ b/google/cloud/google_cloud_cpp_universe_domain.cmake @@ -63,7 +63,7 @@ google_cloud_cpp_add_pkgconfig( "Universe Domain Utilities for the Google Cloud C++ Client Library" "Provides Universe Domain Utilities for the Google Cloud C++ Client Library." "google_cloud_cpp_common" - "google_cloud_rest_internal") + "google_cloud_cpp_rest_internal") # Create and install the CMake configuration files. configure_file("config-universe-domain.cmake.in" diff --git a/google/cloud/iam/admin/v1/samples/iam_client_samples.cc b/google/cloud/iam/admin/v1/samples/iam_client_samples.cc index 9f5edb2aab832..edfb1fa873439 100644 --- a/google/cloud/iam/admin/v1/samples/iam_client_samples.cc +++ b/google/cloud/iam/admin/v1/samples/iam_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::iam_admin_v1::IAMClient( + google::cloud::iam_admin_v1::MakeIAMConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::iam_admin_v1::IAMConnectionIdempotencyPolicy { @@ -138,6 +158,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -147,6 +170,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/iam/credentials/v1/samples/iam_credentials_client_samples.cc b/google/cloud/iam/credentials/v1/samples/iam_credentials_client_samples.cc index f177eb335d5e8..317d259c84aac 100644 --- a/google/cloud/iam/credentials/v1/samples/iam_credentials_client_samples.cc +++ b/google/cloud/iam/credentials/v1/samples/iam_credentials_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::iam_credentials_v1::IAMCredentialsClient( + google::cloud::iam_credentials_v1::MakeIAMCredentialsConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::iam_credentials_v1:: IAMCredentialsConnectionIdempotencyPolicy { @@ -144,6 +165,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -153,6 +177,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/iam/doc/override-universe-domain.dox b/google/cloud/iam/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..4ee429d8a6932 --- /dev/null +++ b/google/cloud/iam/doc/override-universe-domain.dox @@ -0,0 +1,64 @@ +/*! +@page iam-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `iam_admin_v1::IAMClient`: + +@snippet iam_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c iam_admin_v1::IAMClient](@ref iam_admin_v1::IAMClient-universe-domain-snippet) +- [\c iam_credentials_v1::IAMCredentialsClient](@ref iam_credentials_v1::IAMCredentialsClient-universe-domain-snippet) +- [\c iam_v1::IAMPolicyClient](@ref iam_v1::IAMPolicyClient-universe-domain-snippet) +- [\c iam_v2::PoliciesClient](@ref iam_v2::PoliciesClient-universe-domain-snippet) +- [\c iam_v3::PolicyBindingsClient](@ref iam_v3::PolicyBindingsClient-universe-domain-snippet) +- [\c iam_v3::PrincipalAccessBoundaryPoliciesClient](@ref iam_v3::PrincipalAccessBoundaryPoliciesClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page iam_admin_v1::IAMClient-universe-domain-snippet Override iam_admin_v1::IAMClient Universe Domain + +@snippet google/cloud/iam/admin/v1/samples/iam_client_samples.cc set-client-universe-domain + +*/ + +/*! @page iam_credentials_v1::IAMCredentialsClient-universe-domain-snippet Override iam_credentials_v1::IAMCredentialsClient Universe Domain + +@snippet google/cloud/iam/credentials/v1/samples/iam_credentials_client_samples.cc set-client-universe-domain + +*/ + +/*! @page iam_v1::IAMPolicyClient-universe-domain-snippet Override iam_v1::IAMPolicyClient Universe Domain + +@snippet google/cloud/iam/v1/samples/iam_policy_client_samples.cc set-client-universe-domain + +*/ + +/*! @page iam_v2::PoliciesClient-universe-domain-snippet Override iam_v2::PoliciesClient Universe Domain + +@snippet google/cloud/iam/v2/samples/policies_client_samples.cc set-client-universe-domain + +*/ + +/*! @page iam_v3::PolicyBindingsClient-universe-domain-snippet Override iam_v3::PolicyBindingsClient Universe Domain + +@snippet google/cloud/iam/v3/samples/policy_bindings_client_samples.cc set-client-universe-domain + +*/ + +/*! @page iam_v3::PrincipalAccessBoundaryPoliciesClient-universe-domain-snippet Override iam_v3::PrincipalAccessBoundaryPoliciesClient Universe Domain + +@snippet google/cloud/iam/v3/samples/principal_access_boundary_policies_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/iam/v1/samples/iam_policy_client_samples.cc b/google/cloud/iam/v1/samples/iam_policy_client_samples.cc index f5e764fcb9f60..31db1bbe79ab0 100644 --- a/google/cloud/iam/v1/samples/iam_policy_client_samples.cc +++ b/google/cloud/iam/v1/samples/iam_policy_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::iam_v1::IAMPolicyClient( + google::cloud::iam_v1::MakeIAMPolicyConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::iam_v1::IAMPolicyConnectionIdempotencyPolicy { @@ -138,6 +158,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -147,6 +170,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/iam/v2/samples/policies_client_samples.cc b/google/cloud/iam/v2/samples/policies_client_samples.cc index 6a4c965d83072..65bc5b3e914bf 100644 --- a/google/cloud/iam/v2/samples/policies_client_samples.cc +++ b/google/cloud/iam/v2/samples/policies_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::iam_v2::PoliciesClient( + google::cloud::iam_v2::MakePoliciesConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::iam_v2::PoliciesConnectionIdempotencyPolicy { @@ -178,6 +198,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -188,6 +211,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/iam/v3/samples/policy_bindings_client_samples.cc b/google/cloud/iam/v3/samples/policy_bindings_client_samples.cc index 494a843018c09..1559e2bcaf267 100644 --- a/google/cloud/iam/v3/samples/policy_bindings_client_samples.cc +++ b/google/cloud/iam/v3/samples/policy_bindings_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::iam_v3::PolicyBindingsClient( + google::cloud::iam_v3::MakePolicyBindingsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::iam_v3::PolicyBindingsConnectionIdempotencyPolicy { @@ -184,6 +204,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -194,6 +217,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/iam/v3/samples/principal_access_boundary_policies_client_samples.cc b/google/cloud/iam/v3/samples/principal_access_boundary_policies_client_samples.cc index f2327f0d1949c..78e37657634c7 100644 --- a/google/cloud/iam/v3/samples/principal_access_boundary_policies_client_samples.cc +++ b/google/cloud/iam/v3/samples/principal_access_boundary_policies_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::iam_v3::PrincipalAccessBoundaryPoliciesClient( + google::cloud::iam_v3::MakePrincipalAccessBoundaryPoliciesConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::iam_v3:: @@ -203,6 +224,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -213,6 +237,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/iap/doc/override-universe-domain.dox b/google/cloud/iap/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..691a4fe0ed5ca --- /dev/null +++ b/google/cloud/iap/doc/override-universe-domain.dox @@ -0,0 +1,36 @@ +/*! +@page iap-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `iap_v1::IdentityAwareProxyAdminServiceClient`: + +@snippet identity_aware_proxy_admin_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c iap_v1::IdentityAwareProxyAdminServiceClient](@ref iap_v1::IdentityAwareProxyAdminServiceClient-universe-domain-snippet) +- [\c iap_v1::IdentityAwareProxyOAuthServiceClient](@ref iap_v1::IdentityAwareProxyOAuthServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page iap_v1::IdentityAwareProxyAdminServiceClient-universe-domain-snippet Override iap_v1::IdentityAwareProxyAdminServiceClient Universe Domain + +@snippet google/cloud/iap/v1/samples/identity_aware_proxy_admin_client_samples.cc set-client-universe-domain + +*/ + +/*! @page iap_v1::IdentityAwareProxyOAuthServiceClient-universe-domain-snippet Override iap_v1::IdentityAwareProxyOAuthServiceClient Universe Domain + +@snippet google/cloud/iap/v1/samples/identity_aware_proxy_o_auth_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/iap/v1/samples/identity_aware_proxy_admin_client_samples.cc b/google/cloud/iap/v1/samples/identity_aware_proxy_admin_client_samples.cc index ba54b0926c057..5f4f1ed166b80 100644 --- a/google/cloud/iap/v1/samples/identity_aware_proxy_admin_client_samples.cc +++ b/google/cloud/iap/v1/samples/identity_aware_proxy_admin_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::iap_v1::IdentityAwareProxyAdminServiceClient( + google::cloud::iap_v1::MakeIdentityAwareProxyAdminServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::iap_v1:: @@ -152,6 +173,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -161,6 +185,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/iap/v1/samples/identity_aware_proxy_o_auth_client_samples.cc b/google/cloud/iap/v1/samples/identity_aware_proxy_o_auth_client_samples.cc index 83fdd6fa9aecd..4563927b0ee39 100644 --- a/google/cloud/iap/v1/samples/identity_aware_proxy_o_auth_client_samples.cc +++ b/google/cloud/iap/v1/samples/identity_aware_proxy_o_auth_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::iap_v1::IdentityAwareProxyOAuthServiceClient( + google::cloud::iap_v1::MakeIdentityAwareProxyOAuthServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::iap_v1:: @@ -152,6 +173,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -161,6 +185,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/ids/doc/override-universe-domain.dox b/google/cloud/ids/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..f500cf38fbe29 --- /dev/null +++ b/google/cloud/ids/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page ids-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `ids_v1::IDSClient`: + +@snippet ids_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page ids_v1::IDSClient-universe-domain-snippet Override ids_v1::IDSClient Universe Domain + +@snippet google/cloud/ids/v1/samples/ids_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/ids/v1/samples/ids_client_samples.cc b/google/cloud/ids/v1/samples/ids_client_samples.cc index 4ae1d44e33a1e..9497ad11432c9 100644 --- a/google/cloud/ids/v1/samples/ids_client_samples.cc +++ b/google/cloud/ids/v1/samples/ids_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::ids_v1::IDSClient( + google::cloud::ids_v1::MakeIDSConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::ids_v1::IDSConnectionIdempotencyPolicy { @@ -176,6 +196,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -186,6 +209,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/kms/doc/override-universe-domain.dox b/google/cloud/kms/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..23bd38649a3e7 --- /dev/null +++ b/google/cloud/kms/doc/override-universe-domain.dox @@ -0,0 +1,64 @@ +/*! +@page kms-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `kms_inventory_v1::KeyDashboardServiceClient`: + +@snippet key_dashboard_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c kms_inventory_v1::KeyDashboardServiceClient](@ref kms_inventory_v1::KeyDashboardServiceClient-universe-domain-snippet) +- [\c kms_inventory_v1::KeyTrackingServiceClient](@ref kms_inventory_v1::KeyTrackingServiceClient-universe-domain-snippet) +- [\c kms_v1::AutokeyAdminClient](@ref kms_v1::AutokeyAdminClient-universe-domain-snippet) +- [\c kms_v1::AutokeyClient](@ref kms_v1::AutokeyClient-universe-domain-snippet) +- [\c kms_v1::EkmServiceClient](@ref kms_v1::EkmServiceClient-universe-domain-snippet) +- [\c kms_v1::KeyManagementServiceClient](@ref kms_v1::KeyManagementServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page kms_inventory_v1::KeyDashboardServiceClient-universe-domain-snippet Override kms_inventory_v1::KeyDashboardServiceClient Universe Domain + +@snippet google/cloud/kms/inventory/v1/samples/key_dashboard_client_samples.cc set-client-universe-domain + +*/ + +/*! @page kms_inventory_v1::KeyTrackingServiceClient-universe-domain-snippet Override kms_inventory_v1::KeyTrackingServiceClient Universe Domain + +@snippet google/cloud/kms/inventory/v1/samples/key_tracking_client_samples.cc set-client-universe-domain + +*/ + +/*! @page kms_v1::AutokeyAdminClient-universe-domain-snippet Override kms_v1::AutokeyAdminClient Universe Domain + +@snippet google/cloud/kms/v1/samples/autokey_admin_client_samples.cc set-client-universe-domain + +*/ + +/*! @page kms_v1::AutokeyClient-universe-domain-snippet Override kms_v1::AutokeyClient Universe Domain + +@snippet google/cloud/kms/v1/samples/autokey_client_samples.cc set-client-universe-domain + +*/ + +/*! @page kms_v1::EkmServiceClient-universe-domain-snippet Override kms_v1::EkmServiceClient Universe Domain + +@snippet google/cloud/kms/v1/samples/ekm_client_samples.cc set-client-universe-domain + +*/ + +/*! @page kms_v1::KeyManagementServiceClient-universe-domain-snippet Override kms_v1::KeyManagementServiceClient Universe Domain + +@snippet google/cloud/kms/v1/samples/key_management_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/kms/inventory/v1/samples/key_dashboard_client_samples.cc b/google/cloud/kms/inventory/v1/samples/key_dashboard_client_samples.cc index b53d57ea97979..94141c8381f2f 100644 --- a/google/cloud/kms/inventory/v1/samples/key_dashboard_client_samples.cc +++ b/google/cloud/kms/inventory/v1/samples/key_dashboard_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::kms_inventory_v1::KeyDashboardServiceClient( + google::cloud::kms_inventory_v1::MakeKeyDashboardServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::kms_inventory_v1:: @@ -150,6 +171,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -159,6 +183,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/kms/inventory/v1/samples/key_tracking_client_samples.cc b/google/cloud/kms/inventory/v1/samples/key_tracking_client_samples.cc index b1d5ab8f2c6e5..66f14dcf633d5 100644 --- a/google/cloud/kms/inventory/v1/samples/key_tracking_client_samples.cc +++ b/google/cloud/kms/inventory/v1/samples/key_tracking_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::kms_inventory_v1::KeyTrackingServiceClient( + google::cloud::kms_inventory_v1::MakeKeyTrackingServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::kms_inventory_v1:: @@ -150,6 +171,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -159,6 +183,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/kms/v1/samples/autokey_admin_client_samples.cc b/google/cloud/kms/v1/samples/autokey_admin_client_samples.cc index ffd8397ad477b..76d00a229b3c8 100644 --- a/google/cloud/kms/v1/samples/autokey_admin_client_samples.cc +++ b/google/cloud/kms/v1/samples/autokey_admin_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::kms_v1::AutokeyAdminClient( + google::cloud::kms_v1::MakeAutokeyAdminConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::kms_v1::AutokeyAdminConnectionIdempotencyPolicy { @@ -139,6 +159,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -148,6 +171,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/kms/v1/samples/autokey_client_samples.cc b/google/cloud/kms/v1/samples/autokey_client_samples.cc index 4b24c9b104dea..078a317f9bc3d 100644 --- a/google/cloud/kms/v1/samples/autokey_client_samples.cc +++ b/google/cloud/kms/v1/samples/autokey_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::kms_v1::AutokeyClient( + google::cloud::kms_v1::MakeAutokeyConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::kms_v1::AutokeyConnectionIdempotencyPolicy { @@ -177,6 +197,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -187,6 +210,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/kms/v1/samples/ekm_client_samples.cc b/google/cloud/kms/v1/samples/ekm_client_samples.cc index c2cdd40126fec..8954449c52976 100644 --- a/google/cloud/kms/v1/samples/ekm_client_samples.cc +++ b/google/cloud/kms/v1/samples/ekm_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::kms_v1::EkmServiceClient( + google::cloud::kms_v1::MakeEkmServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::kms_v1::EkmServiceConnectionIdempotencyPolicy { @@ -138,6 +158,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -147,6 +170,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/kms/v1/samples/key_management_client_samples.cc b/google/cloud/kms/v1/samples/key_management_client_samples.cc index 27b7916694f3c..add6739d22b4b 100644 --- a/google/cloud/kms/v1/samples/key_management_client_samples.cc +++ b/google/cloud/kms/v1/samples/key_management_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::kms_v1::KeyManagementServiceClient( + google::cloud::kms_v1::MakeKeyManagementServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::kms_v1:: @@ -142,6 +162,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -151,6 +174,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/language/doc/override-universe-domain.dox b/google/cloud/language/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..a4ba3146a920b --- /dev/null +++ b/google/cloud/language/doc/override-universe-domain.dox @@ -0,0 +1,36 @@ +/*! +@page language-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `language_v1::LanguageServiceClient`: + +@snippet language_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c language_v1::LanguageServiceClient](@ref language_v1::LanguageServiceClient-universe-domain-snippet) +- [\c language_v2::LanguageServiceClient](@ref language_v2::LanguageServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page language_v1::LanguageServiceClient-universe-domain-snippet Override language_v1::LanguageServiceClient Universe Domain + +@snippet google/cloud/language/v1/samples/language_client_samples.cc set-client-universe-domain + +*/ + +/*! @page language_v2::LanguageServiceClient-universe-domain-snippet Override language_v2::LanguageServiceClient Universe Domain + +@snippet google/cloud/language/v2/samples/language_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/language/v1/samples/language_client_samples.cc b/google/cloud/language/v1/samples/language_client_samples.cc index 7d0a48480a8b4..544e957039e56 100644 --- a/google/cloud/language/v1/samples/language_client_samples.cc +++ b/google/cloud/language/v1/samples/language_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::language_v1::LanguageServiceClient( + google::cloud::language_v1::MakeLanguageServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::language_v1:: LanguageServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/language/v2/samples/language_client_samples.cc b/google/cloud/language/v2/samples/language_client_samples.cc index b75b847b3cc5a..0034289cc3a3b 100644 --- a/google/cloud/language/v2/samples/language_client_samples.cc +++ b/google/cloud/language/v2/samples/language_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::language_v2::LanguageServiceClient( + google::cloud::language_v2::MakeLanguageServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::language_v2:: LanguageServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/licensemanager/doc/override-universe-domain.dox b/google/cloud/licensemanager/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..3f0472bcd04e2 --- /dev/null +++ b/google/cloud/licensemanager/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page licensemanager-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `licensemanager_v1::LicenseManagerClient`: + +@snippet license_manager_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page licensemanager_v1::LicenseManagerClient-universe-domain-snippet Override licensemanager_v1::LicenseManagerClient Universe Domain + +@snippet google/cloud/licensemanager/v1/samples/license_manager_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/licensemanager/v1/samples/license_manager_client_samples.cc b/google/cloud/licensemanager/v1/samples/license_manager_client_samples.cc index f05e83a5f6149..a9c8601be0259 100644 --- a/google/cloud/licensemanager/v1/samples/license_manager_client_samples.cc +++ b/google/cloud/licensemanager/v1/samples/license_manager_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::licensemanager_v1::LicenseManagerClient( + google::cloud::licensemanager_v1::MakeLicenseManagerConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::licensemanager_v1:: LicenseManagerConnectionIdempotencyPolicy { @@ -190,6 +211,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -200,6 +224,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/logging/doc/override-universe-domain.dox b/google/cloud/logging/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..4041b2a70d3ac --- /dev/null +++ b/google/cloud/logging/doc/override-universe-domain.dox @@ -0,0 +1,43 @@ +/*! +@page logging-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `logging_v2::ConfigServiceV2Client`: + +@snippet config_service_v2_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c logging_v2::ConfigServiceV2Client](@ref logging_v2::ConfigServiceV2Client-universe-domain-snippet) +- [\c logging_v2::LoggingServiceV2Client](@ref logging_v2::LoggingServiceV2Client-universe-domain-snippet) +- [\c logging_v2::MetricsServiceV2Client](@ref logging_v2::MetricsServiceV2Client-universe-domain-snippet) + + + +*/ + +// + +/*! @page logging_v2::ConfigServiceV2Client-universe-domain-snippet Override logging_v2::ConfigServiceV2Client Universe Domain + +@snippet google/cloud/logging/v2/samples/config_service_v2_client_samples.cc set-client-universe-domain + +*/ + +/*! @page logging_v2::LoggingServiceV2Client-universe-domain-snippet Override logging_v2::LoggingServiceV2Client Universe Domain + +@snippet google/cloud/logging/v2/samples/logging_service_v2_client_samples.cc set-client-universe-domain + +*/ + +/*! @page logging_v2::MetricsServiceV2Client-universe-domain-snippet Override logging_v2::MetricsServiceV2Client Universe Domain + +@snippet google/cloud/logging/v2/samples/metrics_service_v2_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/logging/v2/samples/config_service_v2_client_samples.cc b/google/cloud/logging/v2/samples/config_service_v2_client_samples.cc index 1a29421f87826..a0c4c4ed253bb 100644 --- a/google/cloud/logging/v2/samples/config_service_v2_client_samples.cc +++ b/google/cloud/logging/v2/samples/config_service_v2_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::logging_v2::ConfigServiceV2Client( + google::cloud::logging_v2::MakeConfigServiceV2Connection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::logging_v2:: ConfigServiceV2ConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/logging/v2/samples/logging_service_v2_client_samples.cc b/google/cloud/logging/v2/samples/logging_service_v2_client_samples.cc index 80d138f3b5746..2af36f2f5163f 100644 --- a/google/cloud/logging/v2/samples/logging_service_v2_client_samples.cc +++ b/google/cloud/logging/v2/samples/logging_service_v2_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::logging_v2::LoggingServiceV2Client( + google::cloud::logging_v2::MakeLoggingServiceV2Connection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::logging_v2:: @@ -142,6 +162,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -151,6 +174,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/logging/v2/samples/metrics_service_v2_client_samples.cc b/google/cloud/logging/v2/samples/metrics_service_v2_client_samples.cc index 8a364db40247d..7e1b42db4fd10 100644 --- a/google/cloud/logging/v2/samples/metrics_service_v2_client_samples.cc +++ b/google/cloud/logging/v2/samples/metrics_service_v2_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::logging_v2::MetricsServiceV2Client( + google::cloud::logging_v2::MakeMetricsServiceV2Connection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::logging_v2:: @@ -142,6 +162,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -151,6 +174,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/lustre/doc/override-universe-domain.dox b/google/cloud/lustre/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..d8b3c7d502eb1 --- /dev/null +++ b/google/cloud/lustre/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page lustre-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `lustre_v1::LustreClient`: + +@snippet lustre_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page lustre_v1::LustreClient-universe-domain-snippet Override lustre_v1::LustreClient Universe Domain + +@snippet google/cloud/lustre/v1/samples/lustre_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/lustre/v1/samples/lustre_client_samples.cc b/google/cloud/lustre/v1/samples/lustre_client_samples.cc index 6cc4c32f459f9..e9284c84b5f5e 100644 --- a/google/cloud/lustre/v1/samples/lustre_client_samples.cc +++ b/google/cloud/lustre/v1/samples/lustre_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::lustre_v1::LustreClient( + google::cloud::lustre_v1::MakeLustreConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::lustre_v1::LustreConnectionIdempotencyPolicy { @@ -179,6 +199,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -189,6 +212,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/managedidentities/doc/override-universe-domain.dox b/google/cloud/managedidentities/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..3912d4d848b10 --- /dev/null +++ b/google/cloud/managedidentities/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page managedidentities-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `managedidentities_v1::ManagedIdentitiesServiceClient`: + +@snippet managed_identities_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page managedidentities_v1::ManagedIdentitiesServiceClient-universe-domain-snippet Override managedidentities_v1::ManagedIdentitiesServiceClient Universe Domain + +@snippet google/cloud/managedidentities/v1/samples/managed_identities_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/managedidentities/v1/samples/managed_identities_client_samples.cc b/google/cloud/managedidentities/v1/samples/managed_identities_client_samples.cc index c7f3c62205c43..eed7dd49b3cda 100644 --- a/google/cloud/managedidentities/v1/samples/managed_identities_client_samples.cc +++ b/google/cloud/managedidentities/v1/samples/managed_identities_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::managedidentities_v1::ManagedIdentitiesServiceClient( + google::cloud::managedidentities_v1:: + MakeManagedIdentitiesServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::managedidentities_v1:: @@ -198,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -208,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/managedkafka/doc/override-universe-domain.dox b/google/cloud/managedkafka/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..984a747b829e0 --- /dev/null +++ b/google/cloud/managedkafka/doc/override-universe-domain.dox @@ -0,0 +1,36 @@ +/*! +@page managedkafka-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `managedkafka_schemaregistry_v1::ManagedSchemaRegistryClient`: + +@snippet managed_schema_registry_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c managedkafka_schemaregistry_v1::ManagedSchemaRegistryClient](@ref managedkafka_schemaregistry_v1::ManagedSchemaRegistryClient-universe-domain-snippet) +- [\c managedkafka_v1::ManagedKafkaClient](@ref managedkafka_v1::ManagedKafkaClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page managedkafka_schemaregistry_v1::ManagedSchemaRegistryClient-universe-domain-snippet Override managedkafka_schemaregistry_v1::ManagedSchemaRegistryClient Universe Domain + +@snippet google/cloud/managedkafka/schemaregistry/v1/samples/managed_schema_registry_client_samples.cc set-client-universe-domain + +*/ + +/*! @page managedkafka_v1::ManagedKafkaClient-universe-domain-snippet Override managedkafka_v1::ManagedKafkaClient Universe Domain + +@snippet google/cloud/managedkafka/v1/samples/managed_kafka_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/managedkafka/schemaregistry/v1/samples/managed_schema_registry_client_samples.cc b/google/cloud/managedkafka/schemaregistry/v1/samples/managed_schema_registry_client_samples.cc index c11ed54fa44da..c2cf5d66c0a61 100644 --- a/google/cloud/managedkafka/schemaregistry/v1/samples/managed_schema_registry_client_samples.cc +++ b/google/cloud/managedkafka/schemaregistry/v1/samples/managed_schema_registry_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::managedkafka_schemaregistry_v1:: + ManagedSchemaRegistryClient( + google::cloud::managedkafka_schemaregistry_v1:: + MakeManagedSchemaRegistryConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::managedkafka_schemaregistry_v1:: @@ -152,6 +174,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -161,6 +186,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/managedkafka/v1/samples/managed_kafka_client_samples.cc b/google/cloud/managedkafka/v1/samples/managed_kafka_client_samples.cc index 9925b760906cb..eaaf189de5363 100644 --- a/google/cloud/managedkafka/v1/samples/managed_kafka_client_samples.cc +++ b/google/cloud/managedkafka/v1/samples/managed_kafka_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::managedkafka_v1::ManagedKafkaClient( + google::cloud::managedkafka_v1::MakeManagedKafkaConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::managedkafka_v1:: ManagedKafkaConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/memcache/doc/override-universe-domain.dox b/google/cloud/memcache/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..fec18aa69a282 --- /dev/null +++ b/google/cloud/memcache/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page memcache-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `memcache_v1::CloudMemcacheClient`: + +@snippet cloud_memcache_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page memcache_v1::CloudMemcacheClient-universe-domain-snippet Override memcache_v1::CloudMemcacheClient Universe Domain + +@snippet google/cloud/memcache/v1/samples/cloud_memcache_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/memcache/v1/samples/cloud_memcache_client_samples.cc b/google/cloud/memcache/v1/samples/cloud_memcache_client_samples.cc index 355b837adcfc4..7ba6ee0d969ea 100644 --- a/google/cloud/memcache/v1/samples/cloud_memcache_client_samples.cc +++ b/google/cloud/memcache/v1/samples/cloud_memcache_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::memcache_v1::CloudMemcacheClient( + google::cloud::memcache_v1::MakeCloudMemcacheConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::memcache_v1:: CloudMemcacheConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/memorystore/doc/override-universe-domain.dox b/google/cloud/memorystore/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..cbb9cd2506d28 --- /dev/null +++ b/google/cloud/memorystore/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page memorystore-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `memorystore_v1::MemorystoreClient`: + +@snippet memorystore_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page memorystore_v1::MemorystoreClient-universe-domain-snippet Override memorystore_v1::MemorystoreClient Universe Domain + +@snippet google/cloud/memorystore/v1/samples/memorystore_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/memorystore/v1/samples/memorystore_client_samples.cc b/google/cloud/memorystore/v1/samples/memorystore_client_samples.cc index a841377b0aff7..b8efab792d898 100644 --- a/google/cloud/memorystore/v1/samples/memorystore_client_samples.cc +++ b/google/cloud/memorystore/v1/samples/memorystore_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::memorystore_v1::MemorystoreClient( + google::cloud::memorystore_v1::MakeMemorystoreConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::memorystore_v1:: MemorystoreConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/metastore/doc/override-universe-domain.dox b/google/cloud/metastore/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..da46b911070c4 --- /dev/null +++ b/google/cloud/metastore/doc/override-universe-domain.dox @@ -0,0 +1,36 @@ +/*! +@page metastore-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `metastore_v1::DataprocMetastoreClient`: + +@snippet dataproc_metastore_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c metastore_v1::DataprocMetastoreClient](@ref metastore_v1::DataprocMetastoreClient-universe-domain-snippet) +- [\c metastore_v1::DataprocMetastoreFederationClient](@ref metastore_v1::DataprocMetastoreFederationClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page metastore_v1::DataprocMetastoreClient-universe-domain-snippet Override metastore_v1::DataprocMetastoreClient Universe Domain + +@snippet google/cloud/metastore/v1/samples/dataproc_metastore_client_samples.cc set-client-universe-domain + +*/ + +/*! @page metastore_v1::DataprocMetastoreFederationClient-universe-domain-snippet Override metastore_v1::DataprocMetastoreFederationClient Universe Domain + +@snippet google/cloud/metastore/v1/samples/dataproc_metastore_federation_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/metastore/v1/samples/dataproc_metastore_client_samples.cc b/google/cloud/metastore/v1/samples/dataproc_metastore_client_samples.cc index 09c857a054020..8a0fdd9bb22b9 100644 --- a/google/cloud/metastore/v1/samples/dataproc_metastore_client_samples.cc +++ b/google/cloud/metastore/v1/samples/dataproc_metastore_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::metastore_v1::DataprocMetastoreClient( + google::cloud::metastore_v1::MakeDataprocMetastoreConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::metastore_v1:: @@ -190,6 +211,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -200,6 +224,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/metastore/v1/samples/dataproc_metastore_federation_client_samples.cc b/google/cloud/metastore/v1/samples/dataproc_metastore_federation_client_samples.cc index e1f97fd418825..bdcf32f6cf450 100644 --- a/google/cloud/metastore/v1/samples/dataproc_metastore_federation_client_samples.cc +++ b/google/cloud/metastore/v1/samples/dataproc_metastore_federation_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::metastore_v1::DataprocMetastoreFederationClient( + google::cloud::metastore_v1:: + MakeDataprocMetastoreFederationConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::metastore_v1:: @@ -201,6 +223,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -211,6 +236,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/migrationcenter/doc/override-universe-domain.dox b/google/cloud/migrationcenter/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..123e4ce969708 --- /dev/null +++ b/google/cloud/migrationcenter/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page migrationcenter-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `migrationcenter_v1::MigrationCenterClient`: + +@snippet migration_center_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page migrationcenter_v1::MigrationCenterClient-universe-domain-snippet Override migrationcenter_v1::MigrationCenterClient Universe Domain + +@snippet google/cloud/migrationcenter/v1/samples/migration_center_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/migrationcenter/v1/samples/migration_center_client_samples.cc b/google/cloud/migrationcenter/v1/samples/migration_center_client_samples.cc index 63aba2dbc84f4..8e858fb509394 100644 --- a/google/cloud/migrationcenter/v1/samples/migration_center_client_samples.cc +++ b/google/cloud/migrationcenter/v1/samples/migration_center_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::migrationcenter_v1::MigrationCenterClient( + google::cloud::migrationcenter_v1::MakeMigrationCenterConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::migrationcenter_v1:: MigrationCenterConnectionIdempotencyPolicy { @@ -195,6 +216,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -205,6 +229,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/monitoring/dashboard/v1/samples/dashboards_client_samples.cc b/google/cloud/monitoring/dashboard/v1/samples/dashboards_client_samples.cc index 3cfeee4354bd8..1acd0f477c6a7 100644 --- a/google/cloud/monitoring/dashboard/v1/samples/dashboards_client_samples.cc +++ b/google/cloud/monitoring/dashboard/v1/samples/dashboards_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::monitoring_dashboard_v1::DashboardsServiceClient( + google::cloud::monitoring_dashboard_v1:: + MakeDashboardsServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::monitoring_dashboard_v1:: @@ -151,6 +173,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -160,6 +185,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/monitoring/doc/override-universe-domain.dox b/google/cloud/monitoring/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..4b7a02b1c35bc --- /dev/null +++ b/google/cloud/monitoring/doc/override-universe-domain.dox @@ -0,0 +1,92 @@ +/*! +@page monitoring-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `monitoring_dashboard_v1::DashboardsServiceClient`: + +@snippet dashboards_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c monitoring_dashboard_v1::DashboardsServiceClient](@ref monitoring_dashboard_v1::DashboardsServiceClient-universe-domain-snippet) +- [\c monitoring_metricsscope_v1::MetricsScopesClient](@ref monitoring_metricsscope_v1::MetricsScopesClient-universe-domain-snippet) +- [\c monitoring_v3::AlertPolicyServiceClient](@ref monitoring_v3::AlertPolicyServiceClient-universe-domain-snippet) +- [\c monitoring_v3::GroupServiceClient](@ref monitoring_v3::GroupServiceClient-universe-domain-snippet) +- [\c monitoring_v3::MetricServiceClient](@ref monitoring_v3::MetricServiceClient-universe-domain-snippet) +- [\c monitoring_v3::NotificationChannelServiceClient](@ref monitoring_v3::NotificationChannelServiceClient-universe-domain-snippet) +- [\c monitoring_v3::QueryServiceClient](@ref monitoring_v3::QueryServiceClient-universe-domain-snippet) +- [\c monitoring_v3::ServiceMonitoringServiceClient](@ref monitoring_v3::ServiceMonitoringServiceClient-universe-domain-snippet) +- [\c monitoring_v3::SnoozeServiceClient](@ref monitoring_v3::SnoozeServiceClient-universe-domain-snippet) +- [\c monitoring_v3::UptimeCheckServiceClient](@ref monitoring_v3::UptimeCheckServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page monitoring_dashboard_v1::DashboardsServiceClient-universe-domain-snippet Override monitoring_dashboard_v1::DashboardsServiceClient Universe Domain + +@snippet google/cloud/monitoring/dashboard/v1/samples/dashboards_client_samples.cc set-client-universe-domain + +*/ + +/*! @page monitoring_metricsscope_v1::MetricsScopesClient-universe-domain-snippet Override monitoring_metricsscope_v1::MetricsScopesClient Universe Domain + +@snippet google/cloud/monitoring/metricsscope/v1/samples/metrics_scopes_client_samples.cc set-client-universe-domain + +*/ + +/*! @page monitoring_v3::AlertPolicyServiceClient-universe-domain-snippet Override monitoring_v3::AlertPolicyServiceClient Universe Domain + +@snippet google/cloud/monitoring/v3/samples/alert_policy_client_samples.cc set-client-universe-domain + +*/ + +/*! @page monitoring_v3::GroupServiceClient-universe-domain-snippet Override monitoring_v3::GroupServiceClient Universe Domain + +@snippet google/cloud/monitoring/v3/samples/group_client_samples.cc set-client-universe-domain + +*/ + +/*! @page monitoring_v3::MetricServiceClient-universe-domain-snippet Override monitoring_v3::MetricServiceClient Universe Domain + +@snippet google/cloud/monitoring/v3/samples/metric_client_samples.cc set-client-universe-domain + +*/ + +/*! @page monitoring_v3::NotificationChannelServiceClient-universe-domain-snippet Override monitoring_v3::NotificationChannelServiceClient Universe Domain + +@snippet google/cloud/monitoring/v3/samples/notification_channel_client_samples.cc set-client-universe-domain + +*/ + +/*! @page monitoring_v3::QueryServiceClient-universe-domain-snippet Override monitoring_v3::QueryServiceClient Universe Domain + +@snippet google/cloud/monitoring/v3/samples/query_client_samples.cc set-client-universe-domain + +*/ + +/*! @page monitoring_v3::ServiceMonitoringServiceClient-universe-domain-snippet Override monitoring_v3::ServiceMonitoringServiceClient Universe Domain + +@snippet google/cloud/monitoring/v3/samples/service_monitoring_client_samples.cc set-client-universe-domain + +*/ + +/*! @page monitoring_v3::SnoozeServiceClient-universe-domain-snippet Override monitoring_v3::SnoozeServiceClient Universe Domain + +@snippet google/cloud/monitoring/v3/samples/snooze_client_samples.cc set-client-universe-domain + +*/ + +/*! @page monitoring_v3::UptimeCheckServiceClient-universe-domain-snippet Override monitoring_v3::UptimeCheckServiceClient Universe Domain + +@snippet google/cloud/monitoring/v3/samples/uptime_check_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/monitoring/metricsscope/v1/samples/metrics_scopes_client_samples.cc b/google/cloud/monitoring/metricsscope/v1/samples/metrics_scopes_client_samples.cc index 3b7ada464c9cf..bcfbef8f5e0bf 100644 --- a/google/cloud/monitoring/metricsscope/v1/samples/metrics_scopes_client_samples.cc +++ b/google/cloud/monitoring/metricsscope/v1/samples/metrics_scopes_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::monitoring_metricsscope_v1::MetricsScopesClient( + google::cloud::monitoring_metricsscope_v1:: + MakeMetricsScopesConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::monitoring_metricsscope_v1:: @@ -199,6 +221,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -209,6 +234,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/monitoring/v3/samples/alert_policy_client_samples.cc b/google/cloud/monitoring/v3/samples/alert_policy_client_samples.cc index 3523e4a4fa9c3..6daa3e55baefe 100644 --- a/google/cloud/monitoring/v3/samples/alert_policy_client_samples.cc +++ b/google/cloud/monitoring/v3/samples/alert_policy_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::monitoring_v3::AlertPolicyServiceClient( + google::cloud::monitoring_v3::MakeAlertPolicyServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::monitoring_v3:: @@ -146,6 +167,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -155,6 +179,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/monitoring/v3/samples/group_client_samples.cc b/google/cloud/monitoring/v3/samples/group_client_samples.cc index e6f98544dca8c..e0ac0bdfbb540 100644 --- a/google/cloud/monitoring/v3/samples/group_client_samples.cc +++ b/google/cloud/monitoring/v3/samples/group_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::monitoring_v3::GroupServiceClient( + google::cloud::monitoring_v3::MakeGroupServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::monitoring_v3:: GroupServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/monitoring/v3/samples/metric_client_samples.cc b/google/cloud/monitoring/v3/samples/metric_client_samples.cc index 15b6a26621603..132dc45d499c8 100644 --- a/google/cloud/monitoring/v3/samples/metric_client_samples.cc +++ b/google/cloud/monitoring/v3/samples/metric_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::monitoring_v3::MetricServiceClient( + google::cloud::monitoring_v3::MakeMetricServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::monitoring_v3:: MetricServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/monitoring/v3/samples/notification_channel_client_samples.cc b/google/cloud/monitoring/v3/samples/notification_channel_client_samples.cc index 18f7c66ce8361..c1b51a048ab21 100644 --- a/google/cloud/monitoring/v3/samples/notification_channel_client_samples.cc +++ b/google/cloud/monitoring/v3/samples/notification_channel_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::monitoring_v3::NotificationChannelServiceClient( + google::cloud::monitoring_v3:: + MakeNotificationChannelServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::monitoring_v3:: @@ -151,6 +173,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -160,6 +185,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/monitoring/v3/samples/query_client_samples.cc b/google/cloud/monitoring/v3/samples/query_client_samples.cc index 409ef93921254..40f9988a268b1 100644 --- a/google/cloud/monitoring/v3/samples/query_client_samples.cc +++ b/google/cloud/monitoring/v3/samples/query_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::monitoring_v3::QueryServiceClient( + google::cloud::monitoring_v3::MakeQueryServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::monitoring_v3:: QueryServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/monitoring/v3/samples/service_monitoring_client_samples.cc b/google/cloud/monitoring/v3/samples/service_monitoring_client_samples.cc index 35f480d37068e..8682a850ff2b9 100644 --- a/google/cloud/monitoring/v3/samples/service_monitoring_client_samples.cc +++ b/google/cloud/monitoring/v3/samples/service_monitoring_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::monitoring_v3::ServiceMonitoringServiceClient( + google::cloud::monitoring_v3::MakeServiceMonitoringServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::monitoring_v3:: @@ -151,6 +172,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -160,6 +184,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/monitoring/v3/samples/snooze_client_samples.cc b/google/cloud/monitoring/v3/samples/snooze_client_samples.cc index de06829518e5e..50e9c99e4586d 100644 --- a/google/cloud/monitoring/v3/samples/snooze_client_samples.cc +++ b/google/cloud/monitoring/v3/samples/snooze_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::monitoring_v3::SnoozeServiceClient( + google::cloud::monitoring_v3::MakeSnoozeServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::monitoring_v3:: SnoozeServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/monitoring/v3/samples/uptime_check_client_samples.cc b/google/cloud/monitoring/v3/samples/uptime_check_client_samples.cc index a4a89a0049463..1fc05daa27ed6 100644 --- a/google/cloud/monitoring/v3/samples/uptime_check_client_samples.cc +++ b/google/cloud/monitoring/v3/samples/uptime_check_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::monitoring_v3::UptimeCheckServiceClient( + google::cloud::monitoring_v3::MakeUptimeCheckServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::monitoring_v3:: @@ -146,6 +167,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -155,6 +179,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/netapp/doc/override-universe-domain.dox b/google/cloud/netapp/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..7b7d20a9dd68d --- /dev/null +++ b/google/cloud/netapp/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page netapp-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `netapp_v1::NetAppClient`: + +@snippet net_app_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page netapp_v1::NetAppClient-universe-domain-snippet Override netapp_v1::NetAppClient Universe Domain + +@snippet google/cloud/netapp/v1/samples/net_app_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/netapp/v1/samples/net_app_client_samples.cc b/google/cloud/netapp/v1/samples/net_app_client_samples.cc index 836ee33d8ace2..d1ef2ea4545e3 100644 --- a/google/cloud/netapp/v1/samples/net_app_client_samples.cc +++ b/google/cloud/netapp/v1/samples/net_app_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::netapp_v1::NetAppClient( + google::cloud::netapp_v1::MakeNetAppConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::netapp_v1::NetAppConnectionIdempotencyPolicy { @@ -179,6 +199,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -189,6 +212,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/networkconnectivity/doc/override-universe-domain.dox b/google/cloud/networkconnectivity/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..bdf1a4184d502 --- /dev/null +++ b/google/cloud/networkconnectivity/doc/override-universe-domain.dox @@ -0,0 +1,43 @@ +/*! +@page networkconnectivity-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `networkconnectivity_v1::DataTransferServiceClient`: + +@snippet data_transfer_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c networkconnectivity_v1::DataTransferServiceClient](@ref networkconnectivity_v1::DataTransferServiceClient-universe-domain-snippet) +- [\c networkconnectivity_v1::HubServiceClient](@ref networkconnectivity_v1::HubServiceClient-universe-domain-snippet) +- [\c networkconnectivity_v1::PolicyBasedRoutingServiceClient](@ref networkconnectivity_v1::PolicyBasedRoutingServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page networkconnectivity_v1::DataTransferServiceClient-universe-domain-snippet Override networkconnectivity_v1::DataTransferServiceClient Universe Domain + +@snippet google/cloud/networkconnectivity/v1/samples/data_transfer_client_samples.cc set-client-universe-domain + +*/ + +/*! @page networkconnectivity_v1::HubServiceClient-universe-domain-snippet Override networkconnectivity_v1::HubServiceClient Universe Domain + +@snippet google/cloud/networkconnectivity/v1/samples/hub_client_samples.cc set-client-universe-domain + +*/ + +/*! @page networkconnectivity_v1::PolicyBasedRoutingServiceClient-universe-domain-snippet Override networkconnectivity_v1::PolicyBasedRoutingServiceClient Universe Domain + +@snippet google/cloud/networkconnectivity/v1/samples/policy_based_routing_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/networkconnectivity/v1/samples/data_transfer_client_samples.cc b/google/cloud/networkconnectivity/v1/samples/data_transfer_client_samples.cc index 3290831a9ce5d..9b43f1343d014 100644 --- a/google/cloud/networkconnectivity/v1/samples/data_transfer_client_samples.cc +++ b/google/cloud/networkconnectivity/v1/samples/data_transfer_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::networkconnectivity_v1::DataTransferServiceClient( + google::cloud::networkconnectivity_v1:: + MakeDataTransferServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::networkconnectivity_v1:: @@ -200,6 +222,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -210,6 +235,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/networkconnectivity/v1/samples/hub_client_samples.cc b/google/cloud/networkconnectivity/v1/samples/hub_client_samples.cc index 1f7c1a0914b52..cf05698a17798 100644 --- a/google/cloud/networkconnectivity/v1/samples/hub_client_samples.cc +++ b/google/cloud/networkconnectivity/v1/samples/hub_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::networkconnectivity_v1::HubServiceClient( + google::cloud::networkconnectivity_v1::MakeHubServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::networkconnectivity_v1:: HubServiceConnectionIdempotencyPolicy { @@ -190,6 +211,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -200,6 +224,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/networkconnectivity/v1/samples/policy_based_routing_client_samples.cc b/google/cloud/networkconnectivity/v1/samples/policy_based_routing_client_samples.cc index bef39e280be53..4985f44f0ba40 100644 --- a/google/cloud/networkconnectivity/v1/samples/policy_based_routing_client_samples.cc +++ b/google/cloud/networkconnectivity/v1/samples/policy_based_routing_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::networkconnectivity_v1::PolicyBasedRoutingServiceClient( + google::cloud::networkconnectivity_v1:: + MakePolicyBasedRoutingServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::networkconnectivity_v1:: @@ -205,6 +227,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -215,6 +240,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/networkmanagement/doc/override-universe-domain.dox b/google/cloud/networkmanagement/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..94902dce6533d --- /dev/null +++ b/google/cloud/networkmanagement/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page networkmanagement-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `networkmanagement_v1::ReachabilityServiceClient`: + +@snippet reachability_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page networkmanagement_v1::ReachabilityServiceClient-universe-domain-snippet Override networkmanagement_v1::ReachabilityServiceClient Universe Domain + +@snippet google/cloud/networkmanagement/v1/samples/reachability_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/networkmanagement/v1/samples/reachability_client_samples.cc b/google/cloud/networkmanagement/v1/samples/reachability_client_samples.cc index e060e4d278417..67b45a43f670f 100644 --- a/google/cloud/networkmanagement/v1/samples/reachability_client_samples.cc +++ b/google/cloud/networkmanagement/v1/samples/reachability_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::networkmanagement_v1::ReachabilityServiceClient( + google::cloud::networkmanagement_v1:: + MakeReachabilityServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::networkmanagement_v1:: @@ -200,6 +222,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -210,6 +235,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/networksecurity/doc/override-universe-domain.dox b/google/cloud/networksecurity/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..bb2eed2454293 --- /dev/null +++ b/google/cloud/networksecurity/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page networksecurity-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `networksecurity_v1::NetworkSecurityClient`: + +@snippet network_security_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page networksecurity_v1::NetworkSecurityClient-universe-domain-snippet Override networksecurity_v1::NetworkSecurityClient Universe Domain + +@snippet google/cloud/networksecurity/v1/samples/network_security_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/networksecurity/v1/samples/network_security_client_samples.cc b/google/cloud/networksecurity/v1/samples/network_security_client_samples.cc index 8919236ae09f1..68962f535355b 100644 --- a/google/cloud/networksecurity/v1/samples/network_security_client_samples.cc +++ b/google/cloud/networksecurity/v1/samples/network_security_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::networksecurity_v1::NetworkSecurityClient( + google::cloud::networksecurity_v1::MakeNetworkSecurityConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::networksecurity_v1:: NetworkSecurityConnectionIdempotencyPolicy { @@ -195,6 +216,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -205,6 +229,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/networkservices/doc/override-universe-domain.dox b/google/cloud/networkservices/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..c9c98fb0db6c2 --- /dev/null +++ b/google/cloud/networkservices/doc/override-universe-domain.dox @@ -0,0 +1,36 @@ +/*! +@page networkservices-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `networkservices_v1::DepServiceClient`: + +@snippet dep_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c networkservices_v1::DepServiceClient](@ref networkservices_v1::DepServiceClient-universe-domain-snippet) +- [\c networkservices_v1::NetworkServicesClient](@ref networkservices_v1::NetworkServicesClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page networkservices_v1::DepServiceClient-universe-domain-snippet Override networkservices_v1::DepServiceClient Universe Domain + +@snippet google/cloud/networkservices/v1/samples/dep_client_samples.cc set-client-universe-domain + +*/ + +/*! @page networkservices_v1::NetworkServicesClient-universe-domain-snippet Override networkservices_v1::NetworkServicesClient Universe Domain + +@snippet google/cloud/networkservices/v1/samples/network_services_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/networkservices/v1/samples/dep_client_samples.cc b/google/cloud/networkservices/v1/samples/dep_client_samples.cc index 6db782b3ce6a9..9462b43095325 100644 --- a/google/cloud/networkservices/v1/samples/dep_client_samples.cc +++ b/google/cloud/networkservices/v1/samples/dep_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::networkservices_v1::DepServiceClient( + google::cloud::networkservices_v1::MakeDepServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::networkservices_v1:: DepServiceConnectionIdempotencyPolicy { @@ -188,6 +208,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -198,6 +221,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/networkservices/v1/samples/network_services_client_samples.cc b/google/cloud/networkservices/v1/samples/network_services_client_samples.cc index 695047b8824ad..347623d1361d8 100644 --- a/google/cloud/networkservices/v1/samples/network_services_client_samples.cc +++ b/google/cloud/networkservices/v1/samples/network_services_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::networkservices_v1::NetworkServicesClient( + google::cloud::networkservices_v1::MakeNetworkServicesConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::networkservices_v1:: NetworkServicesConnectionIdempotencyPolicy { @@ -195,6 +216,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -205,6 +229,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/notebooks/doc/override-universe-domain.dox b/google/cloud/notebooks/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..a940cea48bbd2 --- /dev/null +++ b/google/cloud/notebooks/doc/override-universe-domain.dox @@ -0,0 +1,43 @@ +/*! +@page notebooks-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `notebooks_v1::ManagedNotebookServiceClient`: + +@snippet managed_notebook_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c notebooks_v1::ManagedNotebookServiceClient](@ref notebooks_v1::ManagedNotebookServiceClient-universe-domain-snippet) +- [\c notebooks_v1::NotebookServiceClient](@ref notebooks_v1::NotebookServiceClient-universe-domain-snippet) +- [\c notebooks_v2::NotebookServiceClient](@ref notebooks_v2::NotebookServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page notebooks_v1::ManagedNotebookServiceClient-universe-domain-snippet Override notebooks_v1::ManagedNotebookServiceClient Universe Domain + +@snippet google/cloud/notebooks/v1/samples/managed_notebook_client_samples.cc set-client-universe-domain + +*/ + +/*! @page notebooks_v1::NotebookServiceClient-universe-domain-snippet Override notebooks_v1::NotebookServiceClient Universe Domain + +@snippet google/cloud/notebooks/v1/samples/notebook_client_samples.cc set-client-universe-domain + +*/ + +/*! @page notebooks_v2::NotebookServiceClient-universe-domain-snippet Override notebooks_v2::NotebookServiceClient Universe Domain + +@snippet google/cloud/notebooks/v2/samples/notebook_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/notebooks/v1/samples/managed_notebook_client_samples.cc b/google/cloud/notebooks/v1/samples/managed_notebook_client_samples.cc index a7219d4ac20ed..ee2bc68bbc59a 100644 --- a/google/cloud/notebooks/v1/samples/managed_notebook_client_samples.cc +++ b/google/cloud/notebooks/v1/samples/managed_notebook_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::notebooks_v1::ManagedNotebookServiceClient( + google::cloud::notebooks_v1::MakeManagedNotebookServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::notebooks_v1:: @@ -199,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -209,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/notebooks/v1/samples/notebook_client_samples.cc b/google/cloud/notebooks/v1/samples/notebook_client_samples.cc index fb5f5639ae459..dc90bf366022d 100644 --- a/google/cloud/notebooks/v1/samples/notebook_client_samples.cc +++ b/google/cloud/notebooks/v1/samples/notebook_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::notebooks_v1::NotebookServiceClient( + google::cloud::notebooks_v1::MakeNotebookServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::notebooks_v1:: NotebookServiceConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/notebooks/v2/samples/notebook_client_samples.cc b/google/cloud/notebooks/v2/samples/notebook_client_samples.cc index e9aa43a10d821..e7a7e64787f17 100644 --- a/google/cloud/notebooks/v2/samples/notebook_client_samples.cc +++ b/google/cloud/notebooks/v2/samples/notebook_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::notebooks_v2::NotebookServiceClient( + google::cloud::notebooks_v2::MakeNotebookServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::notebooks_v2:: NotebookServiceConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/optimization/doc/override-universe-domain.dox b/google/cloud/optimization/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..591ed4a231036 --- /dev/null +++ b/google/cloud/optimization/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page optimization-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `optimization_v1::FleetRoutingClient`: + +@snippet fleet_routing_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page optimization_v1::FleetRoutingClient-universe-domain-snippet Override optimization_v1::FleetRoutingClient Universe Domain + +@snippet google/cloud/optimization/v1/samples/fleet_routing_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/optimization/v1/samples/fleet_routing_client_samples.cc b/google/cloud/optimization/v1/samples/fleet_routing_client_samples.cc index 4e485d3748c2d..402cbf16ca623 100644 --- a/google/cloud/optimization/v1/samples/fleet_routing_client_samples.cc +++ b/google/cloud/optimization/v1/samples/fleet_routing_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::optimization_v1::FleetRoutingClient( + google::cloud::optimization_v1::MakeFleetRoutingConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::optimization_v1:: FleetRoutingConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/oracledatabase/doc/override-universe-domain.dox b/google/cloud/oracledatabase/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..7d75f772da3c9 --- /dev/null +++ b/google/cloud/oracledatabase/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page oracledatabase-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `oracledatabase_v1::OracleDatabaseClient`: + +@snippet oracle_database_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page oracledatabase_v1::OracleDatabaseClient-universe-domain-snippet Override oracledatabase_v1::OracleDatabaseClient Universe Domain + +@snippet google/cloud/oracledatabase/v1/samples/oracle_database_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/oracledatabase/v1/samples/oracle_database_client_samples.cc b/google/cloud/oracledatabase/v1/samples/oracle_database_client_samples.cc index 0996b94a6094b..26969e55d2fbc 100644 --- a/google/cloud/oracledatabase/v1/samples/oracle_database_client_samples.cc +++ b/google/cloud/oracledatabase/v1/samples/oracle_database_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::oracledatabase_v1::OracleDatabaseClient( + google::cloud::oracledatabase_v1::MakeOracleDatabaseConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::oracledatabase_v1:: OracleDatabaseConnectionIdempotencyPolicy { @@ -190,6 +211,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -200,6 +224,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/orgpolicy/doc/override-universe-domain.dox b/google/cloud/orgpolicy/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..00cf1a05a8398 --- /dev/null +++ b/google/cloud/orgpolicy/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page orgpolicy-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `orgpolicy_v2::OrgPolicyClient`: + +@snippet org_policy_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page orgpolicy_v2::OrgPolicyClient-universe-domain-snippet Override orgpolicy_v2::OrgPolicyClient Universe Domain + +@snippet google/cloud/orgpolicy/v2/samples/org_policy_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/orgpolicy/v2/samples/org_policy_client_samples.cc b/google/cloud/orgpolicy/v2/samples/org_policy_client_samples.cc index b658f9a67794b..918682f976edf 100644 --- a/google/cloud/orgpolicy/v2/samples/org_policy_client_samples.cc +++ b/google/cloud/orgpolicy/v2/samples/org_policy_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::orgpolicy_v2::OrgPolicyClient( + google::cloud::orgpolicy_v2::MakeOrgPolicyConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::orgpolicy_v2::OrgPolicyConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/osconfig/agentendpoint/v1/samples/agent_endpoint_client_samples.cc b/google/cloud/osconfig/agentendpoint/v1/samples/agent_endpoint_client_samples.cc index 9ce6c1d26e32c..bafac2e2e7ed5 100644 --- a/google/cloud/osconfig/agentendpoint/v1/samples/agent_endpoint_client_samples.cc +++ b/google/cloud/osconfig/agentendpoint/v1/samples/agent_endpoint_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::osconfig_agentendpoint_v1::AgentEndpointServiceClient( + google::cloud::osconfig_agentendpoint_v1:: + MakeAgentEndpointServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::osconfig_agentendpoint_v1:: @@ -153,6 +175,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -162,6 +187,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/osconfig/doc/override-universe-domain.dox b/google/cloud/osconfig/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..5b3774414ab0b --- /dev/null +++ b/google/cloud/osconfig/doc/override-universe-domain.dox @@ -0,0 +1,43 @@ +/*! +@page osconfig-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `osconfig_agentendpoint_v1::AgentEndpointServiceClient`: + +@snippet agent_endpoint_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c osconfig_agentendpoint_v1::AgentEndpointServiceClient](@ref osconfig_agentendpoint_v1::AgentEndpointServiceClient-universe-domain-snippet) +- [\c osconfig_v1::OsConfigServiceClient](@ref osconfig_v1::OsConfigServiceClient-universe-domain-snippet) +- [\c osconfig_v1::OsConfigZonalServiceClient](@ref osconfig_v1::OsConfigZonalServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page osconfig_agentendpoint_v1::AgentEndpointServiceClient-universe-domain-snippet Override osconfig_agentendpoint_v1::AgentEndpointServiceClient Universe Domain + +@snippet google/cloud/osconfig/agentendpoint/v1/samples/agent_endpoint_client_samples.cc set-client-universe-domain + +*/ + +/*! @page osconfig_v1::OsConfigServiceClient-universe-domain-snippet Override osconfig_v1::OsConfigServiceClient Universe Domain + +@snippet google/cloud/osconfig/v1/samples/os_config_client_samples.cc set-client-universe-domain + +*/ + +/*! @page osconfig_v1::OsConfigZonalServiceClient-universe-domain-snippet Override osconfig_v1::OsConfigZonalServiceClient Universe Domain + +@snippet google/cloud/osconfig/v1/samples/os_config_zonal_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/osconfig/v1/samples/os_config_client_samples.cc b/google/cloud/osconfig/v1/samples/os_config_client_samples.cc index 5d0c68afa02cf..ff5c8612d3788 100644 --- a/google/cloud/osconfig/v1/samples/os_config_client_samples.cc +++ b/google/cloud/osconfig/v1/samples/os_config_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::osconfig_v1::OsConfigServiceClient( + google::cloud::osconfig_v1::MakeOsConfigServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::osconfig_v1:: OsConfigServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/osconfig/v1/samples/os_config_zonal_client_samples.cc b/google/cloud/osconfig/v1/samples/os_config_zonal_client_samples.cc index 6bcdbfea459ab..bc43fe402b33c 100644 --- a/google/cloud/osconfig/v1/samples/os_config_zonal_client_samples.cc +++ b/google/cloud/osconfig/v1/samples/os_config_zonal_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::osconfig_v1::OsConfigZonalServiceClient( + google::cloud::osconfig_v1::MakeOsConfigZonalServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::osconfig_v1:: @@ -192,6 +213,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -202,6 +226,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/oslogin/doc/override-universe-domain.dox b/google/cloud/oslogin/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..5e7c6df504595 --- /dev/null +++ b/google/cloud/oslogin/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page oslogin-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `oslogin_v1::OsLoginServiceClient`: + +@snippet os_login_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page oslogin_v1::OsLoginServiceClient-universe-domain-snippet Override oslogin_v1::OsLoginServiceClient Universe Domain + +@snippet google/cloud/oslogin/v1/samples/os_login_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/oslogin/v1/samples/os_login_client_samples.cc b/google/cloud/oslogin/v1/samples/os_login_client_samples.cc index 86cf0cc048f3b..811dfc885da1e 100644 --- a/google/cloud/oslogin/v1/samples/os_login_client_samples.cc +++ b/google/cloud/oslogin/v1/samples/os_login_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::oslogin_v1::OsLoginServiceClient( + google::cloud::oslogin_v1::MakeOsLoginServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::oslogin_v1:: OsLoginServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/parallelstore/doc/override-universe-domain.dox b/google/cloud/parallelstore/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..1889489717adb --- /dev/null +++ b/google/cloud/parallelstore/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page parallelstore-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `parallelstore_v1::ParallelstoreClient`: + +@snippet parallelstore_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page parallelstore_v1::ParallelstoreClient-universe-domain-snippet Override parallelstore_v1::ParallelstoreClient Universe Domain + +@snippet google/cloud/parallelstore/v1/samples/parallelstore_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/parallelstore/v1/samples/parallelstore_client_samples.cc b/google/cloud/parallelstore/v1/samples/parallelstore_client_samples.cc index 25b3d0f67f6da..22eae8113190f 100644 --- a/google/cloud/parallelstore/v1/samples/parallelstore_client_samples.cc +++ b/google/cloud/parallelstore/v1/samples/parallelstore_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::parallelstore_v1::ParallelstoreClient( + google::cloud::parallelstore_v1::MakeParallelstoreConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::parallelstore_v1:: ParallelstoreConnectionIdempotencyPolicy { @@ -188,6 +209,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -198,6 +222,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/parametermanager/doc/override-universe-domain.dox b/google/cloud/parametermanager/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..16979eea22b65 --- /dev/null +++ b/google/cloud/parametermanager/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page parametermanager-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `parametermanager_v1::ParameterManagerClient`: + +@snippet parameter_manager_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page parametermanager_v1::ParameterManagerClient-universe-domain-snippet Override parametermanager_v1::ParameterManagerClient Universe Domain + +@snippet google/cloud/parametermanager/v1/samples/parameter_manager_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/parametermanager/v1/samples/parameter_manager_client_samples.cc b/google/cloud/parametermanager/v1/samples/parameter_manager_client_samples.cc index 553138407be23..982492649fae2 100644 --- a/google/cloud/parametermanager/v1/samples/parameter_manager_client_samples.cc +++ b/google/cloud/parametermanager/v1/samples/parameter_manager_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::parametermanager_v1::ParameterManagerClient( + google::cloud::parametermanager_v1::MakeParameterManagerConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::parametermanager_v1:: @@ -150,6 +171,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -159,6 +183,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/policysimulator/doc/override-universe-domain.dox b/google/cloud/policysimulator/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..4bb1537c240c2 --- /dev/null +++ b/google/cloud/policysimulator/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page policysimulator-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `policysimulator_v1::SimulatorClient`: + +@snippet simulator_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page policysimulator_v1::SimulatorClient-universe-domain-snippet Override policysimulator_v1::SimulatorClient Universe Domain + +@snippet google/cloud/policysimulator/v1/samples/simulator_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/policysimulator/v1/samples/simulator_client_samples.cc b/google/cloud/policysimulator/v1/samples/simulator_client_samples.cc index b7d8bd94995d2..c2baaf9c05fc9 100644 --- a/google/cloud/policysimulator/v1/samples/simulator_client_samples.cc +++ b/google/cloud/policysimulator/v1/samples/simulator_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::policysimulator_v1::SimulatorClient( + google::cloud::policysimulator_v1::MakeSimulatorConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::policysimulator_v1:: SimulatorConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/policytroubleshooter/doc/override-universe-domain.dox b/google/cloud/policytroubleshooter/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..1f69d283589ea --- /dev/null +++ b/google/cloud/policytroubleshooter/doc/override-universe-domain.dox @@ -0,0 +1,36 @@ +/*! +@page policytroubleshooter-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `policytroubleshooter_iam_v3::PolicyTroubleshooterClient`: + +@snippet policy_troubleshooter_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c policytroubleshooter_iam_v3::PolicyTroubleshooterClient](@ref policytroubleshooter_iam_v3::PolicyTroubleshooterClient-universe-domain-snippet) +- [\c policytroubleshooter_v1::IamCheckerClient](@ref policytroubleshooter_v1::IamCheckerClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page policytroubleshooter_iam_v3::PolicyTroubleshooterClient-universe-domain-snippet Override policytroubleshooter_iam_v3::PolicyTroubleshooterClient Universe Domain + +@snippet google/cloud/policytroubleshooter/iam/v3/samples/policy_troubleshooter_client_samples.cc set-client-universe-domain + +*/ + +/*! @page policytroubleshooter_v1::IamCheckerClient-universe-domain-snippet Override policytroubleshooter_v1::IamCheckerClient Universe Domain + +@snippet google/cloud/policytroubleshooter/v1/samples/iam_checker_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/policytroubleshooter/iam/v3/samples/policy_troubleshooter_client_samples.cc b/google/cloud/policytroubleshooter/iam/v3/samples/policy_troubleshooter_client_samples.cc index 81a3ddb5350d4..f46d1e7b89a2e 100644 --- a/google/cloud/policytroubleshooter/iam/v3/samples/policy_troubleshooter_client_samples.cc +++ b/google/cloud/policytroubleshooter/iam/v3/samples/policy_troubleshooter_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::policytroubleshooter_iam_v3::PolicyTroubleshooterClient( + google::cloud::policytroubleshooter_iam_v3:: + MakePolicyTroubleshooterConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::policytroubleshooter_iam_v3:: @@ -154,6 +176,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -163,6 +188,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/policytroubleshooter/v1/samples/iam_checker_client_samples.cc b/google/cloud/policytroubleshooter/v1/samples/iam_checker_client_samples.cc index 220b4cffeaadb..09a3dd119406f 100644 --- a/google/cloud/policytroubleshooter/v1/samples/iam_checker_client_samples.cc +++ b/google/cloud/policytroubleshooter/v1/samples/iam_checker_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::policytroubleshooter_v1::IamCheckerClient( + google::cloud::policytroubleshooter_v1::MakeIamCheckerConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::policytroubleshooter_v1:: IamCheckerConnectionIdempotencyPolicy { @@ -147,6 +168,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -156,6 +180,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/privateca/doc/override-universe-domain.dox b/google/cloud/privateca/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..41ece86099b8d --- /dev/null +++ b/google/cloud/privateca/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page privateca-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `privateca_v1::CertificateAuthorityServiceClient`: + +@snippet certificate_authority_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page privateca_v1::CertificateAuthorityServiceClient-universe-domain-snippet Override privateca_v1::CertificateAuthorityServiceClient Universe Domain + +@snippet google/cloud/privateca/v1/samples/certificate_authority_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/privateca/v1/samples/certificate_authority_client_samples.cc b/google/cloud/privateca/v1/samples/certificate_authority_client_samples.cc index 53bb2f9c2df47..6aab3e2c4d315 100644 --- a/google/cloud/privateca/v1/samples/certificate_authority_client_samples.cc +++ b/google/cloud/privateca/v1/samples/certificate_authority_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::privateca_v1::CertificateAuthorityServiceClient( + google::cloud::privateca_v1:: + MakeCertificateAuthorityServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::privateca_v1:: @@ -201,6 +223,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -211,6 +236,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/privilegedaccessmanager/doc/override-universe-domain.dox b/google/cloud/privilegedaccessmanager/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..34ec4a0a47a91 --- /dev/null +++ b/google/cloud/privilegedaccessmanager/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page privilegedaccessmanager-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `privilegedaccessmanager_v1::PrivilegedAccessManagerClient`: + +@snippet privileged_access_manager_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page privilegedaccessmanager_v1::PrivilegedAccessManagerClient-universe-domain-snippet Override privilegedaccessmanager_v1::PrivilegedAccessManagerClient Universe Domain + +@snippet google/cloud/privilegedaccessmanager/v1/samples/privileged_access_manager_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/privilegedaccessmanager/v1/samples/privileged_access_manager_client_samples.cc b/google/cloud/privilegedaccessmanager/v1/samples/privileged_access_manager_client_samples.cc index 111f8b22a2071..9d83eb2e9310c 100644 --- a/google/cloud/privilegedaccessmanager/v1/samples/privileged_access_manager_client_samples.cc +++ b/google/cloud/privilegedaccessmanager/v1/samples/privileged_access_manager_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::privilegedaccessmanager_v1::PrivilegedAccessManagerClient( + google::cloud::privilegedaccessmanager_v1:: + MakePrivilegedAccessManagerConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::privilegedaccessmanager_v1:: @@ -204,6 +226,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -214,6 +239,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/profiler/doc/override-universe-domain.dox b/google/cloud/profiler/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..3cfd056839432 --- /dev/null +++ b/google/cloud/profiler/doc/override-universe-domain.dox @@ -0,0 +1,36 @@ +/*! +@page profiler-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `profiler_v2::ExportServiceClient`: + +@snippet export_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c profiler_v2::ExportServiceClient](@ref profiler_v2::ExportServiceClient-universe-domain-snippet) +- [\c profiler_v2::ProfilerServiceClient](@ref profiler_v2::ProfilerServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page profiler_v2::ExportServiceClient-universe-domain-snippet Override profiler_v2::ExportServiceClient Universe Domain + +@snippet google/cloud/profiler/v2/samples/export_client_samples.cc set-client-universe-domain + +*/ + +/*! @page profiler_v2::ProfilerServiceClient-universe-domain-snippet Override profiler_v2::ProfilerServiceClient Universe Domain + +@snippet google/cloud/profiler/v2/samples/profiler_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/profiler/v2/samples/export_client_samples.cc b/google/cloud/profiler/v2/samples/export_client_samples.cc index 914e602ce8771..d55486d483a8b 100644 --- a/google/cloud/profiler/v2/samples/export_client_samples.cc +++ b/google/cloud/profiler/v2/samples/export_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::profiler_v2::ExportServiceClient( + google::cloud::profiler_v2::MakeExportServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::profiler_v2:: ExportServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/profiler/v2/samples/profiler_client_samples.cc b/google/cloud/profiler/v2/samples/profiler_client_samples.cc index 5bed12e676bce..140f5e2c04326 100644 --- a/google/cloud/profiler/v2/samples/profiler_client_samples.cc +++ b/google/cloud/profiler/v2/samples/profiler_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::profiler_v2::ProfilerServiceClient( + google::cloud::profiler_v2::MakeProfilerServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::profiler_v2:: ProfilerServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/publicca/doc/override-universe-domain.dox b/google/cloud/publicca/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..f9a50676677a3 --- /dev/null +++ b/google/cloud/publicca/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page publicca-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `publicca_v1::PublicCertificateAuthorityServiceClient`: + +@snippet public_certificate_authority_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page publicca_v1::PublicCertificateAuthorityServiceClient-universe-domain-snippet Override publicca_v1::PublicCertificateAuthorityServiceClient Universe Domain + +@snippet google/cloud/publicca/v1/samples/public_certificate_authority_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/publicca/v1/samples/public_certificate_authority_client_samples.cc b/google/cloud/publicca/v1/samples/public_certificate_authority_client_samples.cc index 9582f42a4713d..9a5c10386b122 100644 --- a/google/cloud/publicca/v1/samples/public_certificate_authority_client_samples.cc +++ b/google/cloud/publicca/v1/samples/public_certificate_authority_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::publicca_v1::PublicCertificateAuthorityServiceClient( + google::cloud::publicca_v1:: + MakePublicCertificateAuthorityServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::publicca_v1:: @@ -154,6 +176,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -163,6 +188,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/pubsub/admin/samples/BUILD.bazel b/google/cloud/pubsub/admin/samples/BUILD.bazel index e888138ebc4f9..5dab2cc187c39 100644 --- a/google/cloud/pubsub/admin/samples/BUILD.bazel +++ b/google/cloud/pubsub/admin/samples/BUILD.bazel @@ -22,6 +22,7 @@ licenses(["notice"]) # Apache 2.0 tags = ["integration-test"], deps = [ "//:pubsub", + "//:universe_domain", "//google/cloud/testing_util:google_cloud_cpp_testing_private", ], ) for sample in glob(["*.cc"])] diff --git a/google/cloud/pubsub/admin/samples/subscription_admin_client_samples.cc b/google/cloud/pubsub/admin/samples/subscription_admin_client_samples.cc index 77bd4ac1d9011..401061555b9d6 100644 --- a/google/cloud/pubsub/admin/samples/subscription_admin_client_samples.cc +++ b/google/cloud/pubsub/admin/samples/subscription_admin_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -54,6 +55,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::pubsub_admin::SubscriptionAdminClient( + google::cloud::pubsub_admin::MakeSubscriptionAdminConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::pubsub_admin:: @@ -151,6 +172,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -160,6 +184,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/pubsub/admin/samples/topic_admin_client_samples.cc b/google/cloud/pubsub/admin/samples/topic_admin_client_samples.cc index e453f9f03113c..ba660e181931c 100644 --- a/google/cloud/pubsub/admin/samples/topic_admin_client_samples.cc +++ b/google/cloud/pubsub/admin/samples/topic_admin_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -53,6 +54,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::pubsub_admin::TopicAdminClient( + google::cloud::pubsub_admin::MakeTopicAdminConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::pubsub_admin:: TopicAdminConnectionIdempotencyPolicy { @@ -147,6 +167,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -156,6 +179,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/pubsub/samples/BUILD.bazel b/google/cloud/pubsub/samples/BUILD.bazel index e7fa34774d4f4..7586994429215 100644 --- a/google/cloud/pubsub/samples/BUILD.bazel +++ b/google/cloud/pubsub/samples/BUILD.bazel @@ -76,6 +76,7 @@ cc_proto_library( ":samples_cc_proto", "//:common", "//:pubsub", + "//:universe_domain", ] + (["//:iam"] if test == "iam_samples.cc" else []), ) for test in pubsub_client_integration_samples] diff --git a/google/cloud/pubsub/samples/schema_client_samples.cc b/google/cloud/pubsub/samples/schema_client_samples.cc index 989849b1b3328..374e26ab42d18 100644 --- a/google/cloud/pubsub/samples/schema_client_samples.cc +++ b/google/cloud/pubsub/samples/schema_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -53,6 +54,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::pubsub::SchemaServiceClient( + google::cloud::pubsub::MakeSchemaServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::pubsub::SchemaServiceConnectionIdempotencyPolicy { @@ -146,6 +166,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -155,6 +178,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/pubsublite/doc/override-universe-domain.dox b/google/cloud/pubsublite/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..17f6f7f549eea --- /dev/null +++ b/google/cloud/pubsublite/doc/override-universe-domain.dox @@ -0,0 +1,36 @@ +/*! +@page pubsublite-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `pubsublite::AdminServiceClient`: + +@snippet admin_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c pubsublite::AdminServiceClient](@ref pubsublite::AdminServiceClient-universe-domain-snippet) +- [\c pubsublite::TopicStatsServiceClient](@ref pubsublite::TopicStatsServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page pubsublite::AdminServiceClient-universe-domain-snippet Override pubsublite::AdminServiceClient Universe Domain + +@snippet google/cloud/pubsublite/samples/admin_client_samples.cc set-client-universe-domain + +*/ + +/*! @page pubsublite::TopicStatsServiceClient-universe-domain-snippet Override pubsublite::TopicStatsServiceClient Universe Domain + +@snippet google/cloud/pubsublite/samples/topic_stats_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/pubsublite/samples/BUILD.bazel b/google/cloud/pubsublite/samples/BUILD.bazel index 03571cac67e84..c4d317124c933 100644 --- a/google/cloud/pubsublite/samples/BUILD.bazel +++ b/google/cloud/pubsublite/samples/BUILD.bazel @@ -22,6 +22,7 @@ licenses(["notice"]) # Apache 2.0 tags = ["integration-test"], deps = [ "//:experimental-pubsublite", + "//:universe_domain", "//google/cloud/testing_util:google_cloud_cpp_testing_private", ], ) for sample in glob(["*.cc"])] diff --git a/google/cloud/pubsublite/samples/admin_client_samples.cc b/google/cloud/pubsublite/samples/admin_client_samples.cc index 500a554fee4c3..780bbd8b7b74d 100644 --- a/google/cloud/pubsublite/samples/admin_client_samples.cc +++ b/google/cloud/pubsublite/samples/admin_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::pubsublite::AdminServiceClient( + google::cloud::pubsublite::MakeAdminServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::pubsublite:: AdminServiceConnectionIdempotencyPolicy { @@ -185,6 +205,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -195,6 +218,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/pubsublite/samples/topic_stats_client_samples.cc b/google/cloud/pubsublite/samples/topic_stats_client_samples.cc index 7a3d4861f7d21..4fc0bc66ad46e 100644 --- a/google/cloud/pubsublite/samples/topic_stats_client_samples.cc +++ b/google/cloud/pubsublite/samples/topic_stats_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::pubsublite::TopicStatsServiceClient( + google::cloud::pubsublite::MakeTopicStatsServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::pubsublite:: @@ -143,6 +163,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -152,6 +175,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/rapidmigrationassessment/doc/override-universe-domain.dox b/google/cloud/rapidmigrationassessment/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..82da266ad9c5c --- /dev/null +++ b/google/cloud/rapidmigrationassessment/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page rapidmigrationassessment-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `rapidmigrationassessment_v1::RapidMigrationAssessmentClient`: + +@snippet rapid_migration_assessment_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page rapidmigrationassessment_v1::RapidMigrationAssessmentClient-universe-domain-snippet Override rapidmigrationassessment_v1::RapidMigrationAssessmentClient Universe Domain + +@snippet google/cloud/rapidmigrationassessment/v1/samples/rapid_migration_assessment_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/rapidmigrationassessment/v1/samples/rapid_migration_assessment_client_samples.cc b/google/cloud/rapidmigrationassessment/v1/samples/rapid_migration_assessment_client_samples.cc index 168103e7de117..c9860e4bb7ec3 100644 --- a/google/cloud/rapidmigrationassessment/v1/samples/rapid_migration_assessment_client_samples.cc +++ b/google/cloud/rapidmigrationassessment/v1/samples/rapid_migration_assessment_client_samples.cc @@ -25,6 +25,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -52,6 +53,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::rapidmigrationassessment_v1:: + RapidMigrationAssessmentClient( + google::cloud::rapidmigrationassessment_v1:: + MakeRapidMigrationAssessmentConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::rapidmigrationassessment_v1:: @@ -202,6 +224,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -212,6 +237,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/recaptchaenterprise/doc/override-universe-domain.dox b/google/cloud/recaptchaenterprise/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..3e4f5d536e3ee --- /dev/null +++ b/google/cloud/recaptchaenterprise/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page recaptchaenterprise-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `recaptchaenterprise_v1::RecaptchaEnterpriseServiceClient`: + +@snippet recaptcha_enterprise_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page recaptchaenterprise_v1::RecaptchaEnterpriseServiceClient-universe-domain-snippet Override recaptchaenterprise_v1::RecaptchaEnterpriseServiceClient Universe Domain + +@snippet google/cloud/recaptchaenterprise/v1/samples/recaptcha_enterprise_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/recaptchaenterprise/v1/samples/recaptcha_enterprise_client_samples.cc b/google/cloud/recaptchaenterprise/v1/samples/recaptcha_enterprise_client_samples.cc index 9ff8b681e8caa..f783c024377d2 100644 --- a/google/cloud/recaptchaenterprise/v1/samples/recaptcha_enterprise_client_samples.cc +++ b/google/cloud/recaptchaenterprise/v1/samples/recaptcha_enterprise_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::recaptchaenterprise_v1::RecaptchaEnterpriseServiceClient( + google::cloud::recaptchaenterprise_v1:: + MakeRecaptchaEnterpriseServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::recaptchaenterprise_v1:: @@ -155,6 +177,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -164,6 +189,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/recommender/doc/override-universe-domain.dox b/google/cloud/recommender/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..83684cb679d8d --- /dev/null +++ b/google/cloud/recommender/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page recommender-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `recommender_v1::RecommenderClient`: + +@snippet recommender_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page recommender_v1::RecommenderClient-universe-domain-snippet Override recommender_v1::RecommenderClient Universe Domain + +@snippet google/cloud/recommender/v1/samples/recommender_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/recommender/v1/samples/recommender_client_samples.cc b/google/cloud/recommender/v1/samples/recommender_client_samples.cc index fba958419fbe6..941b5d42e922c 100644 --- a/google/cloud/recommender/v1/samples/recommender_client_samples.cc +++ b/google/cloud/recommender/v1/samples/recommender_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::recommender_v1::RecommenderClient( + google::cloud::recommender_v1::MakeRecommenderConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::recommender_v1:: RecommenderConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/redis/cluster/v1/samples/cloud_redis_cluster_client_samples.cc b/google/cloud/redis/cluster/v1/samples/cloud_redis_cluster_client_samples.cc index 21962b061a466..100b412dd5317 100644 --- a/google/cloud/redis/cluster/v1/samples/cloud_redis_cluster_client_samples.cc +++ b/google/cloud/redis/cluster/v1/samples/cloud_redis_cluster_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::redis_cluster_v1::CloudRedisClusterClient( + google::cloud::redis_cluster_v1::MakeCloudRedisClusterConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::redis_cluster_v1:: @@ -197,6 +218,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -207,6 +231,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/redis/doc/override-universe-domain.dox b/google/cloud/redis/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..8de522233c345 --- /dev/null +++ b/google/cloud/redis/doc/override-universe-domain.dox @@ -0,0 +1,36 @@ +/*! +@page redis-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `redis_cluster_v1::CloudRedisClusterClient`: + +@snippet cloud_redis_cluster_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c redis_cluster_v1::CloudRedisClusterClient](@ref redis_cluster_v1::CloudRedisClusterClient-universe-domain-snippet) +- [\c redis_v1::CloudRedisClient](@ref redis_v1::CloudRedisClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page redis_cluster_v1::CloudRedisClusterClient-universe-domain-snippet Override redis_cluster_v1::CloudRedisClusterClient Universe Domain + +@snippet google/cloud/redis/cluster/v1/samples/cloud_redis_cluster_client_samples.cc set-client-universe-domain + +*/ + +/*! @page redis_v1::CloudRedisClient-universe-domain-snippet Override redis_v1::CloudRedisClient Universe Domain + +@snippet google/cloud/redis/v1/samples/cloud_redis_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/redis/v1/samples/cloud_redis_client_samples.cc b/google/cloud/redis/v1/samples/cloud_redis_client_samples.cc index 74e1dd77ceb35..90015dc518ea9 100644 --- a/google/cloud/redis/v1/samples/cloud_redis_client_samples.cc +++ b/google/cloud/redis/v1/samples/cloud_redis_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::redis_v1::CloudRedisClient( + google::cloud::redis_v1::MakeCloudRedisConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::redis_v1::CloudRedisConnectionIdempotencyPolicy { @@ -180,6 +200,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -190,6 +213,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/resourcemanager/doc/override-universe-domain.dox b/google/cloud/resourcemanager/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..ff236054757a7 --- /dev/null +++ b/google/cloud/resourcemanager/doc/override-universe-domain.dox @@ -0,0 +1,71 @@ +/*! +@page resourcemanager-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `resourcemanager_v3::FoldersClient`: + +@snippet folders_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c resourcemanager_v3::FoldersClient](@ref resourcemanager_v3::FoldersClient-universe-domain-snippet) +- [\c resourcemanager_v3::OrganizationsClient](@ref resourcemanager_v3::OrganizationsClient-universe-domain-snippet) +- [\c resourcemanager_v3::ProjectsClient](@ref resourcemanager_v3::ProjectsClient-universe-domain-snippet) +- [\c resourcemanager_v3::TagBindingsClient](@ref resourcemanager_v3::TagBindingsClient-universe-domain-snippet) +- [\c resourcemanager_v3::TagHoldsClient](@ref resourcemanager_v3::TagHoldsClient-universe-domain-snippet) +- [\c resourcemanager_v3::TagKeysClient](@ref resourcemanager_v3::TagKeysClient-universe-domain-snippet) +- [\c resourcemanager_v3::TagValuesClient](@ref resourcemanager_v3::TagValuesClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page resourcemanager_v3::FoldersClient-universe-domain-snippet Override resourcemanager_v3::FoldersClient Universe Domain + +@snippet google/cloud/resourcemanager/v3/samples/folders_client_samples.cc set-client-universe-domain + +*/ + +/*! @page resourcemanager_v3::OrganizationsClient-universe-domain-snippet Override resourcemanager_v3::OrganizationsClient Universe Domain + +@snippet google/cloud/resourcemanager/v3/samples/organizations_client_samples.cc set-client-universe-domain + +*/ + +/*! @page resourcemanager_v3::ProjectsClient-universe-domain-snippet Override resourcemanager_v3::ProjectsClient Universe Domain + +@snippet google/cloud/resourcemanager/v3/samples/projects_client_samples.cc set-client-universe-domain + +*/ + +/*! @page resourcemanager_v3::TagBindingsClient-universe-domain-snippet Override resourcemanager_v3::TagBindingsClient Universe Domain + +@snippet google/cloud/resourcemanager/v3/samples/tag_bindings_client_samples.cc set-client-universe-domain + +*/ + +/*! @page resourcemanager_v3::TagHoldsClient-universe-domain-snippet Override resourcemanager_v3::TagHoldsClient Universe Domain + +@snippet google/cloud/resourcemanager/v3/samples/tag_holds_client_samples.cc set-client-universe-domain + +*/ + +/*! @page resourcemanager_v3::TagKeysClient-universe-domain-snippet Override resourcemanager_v3::TagKeysClient Universe Domain + +@snippet google/cloud/resourcemanager/v3/samples/tag_keys_client_samples.cc set-client-universe-domain + +*/ + +/*! @page resourcemanager_v3::TagValuesClient-universe-domain-snippet Override resourcemanager_v3::TagValuesClient Universe Domain + +@snippet google/cloud/resourcemanager/v3/samples/tag_values_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/resourcemanager/v3/samples/folders_client_samples.cc b/google/cloud/resourcemanager/v3/samples/folders_client_samples.cc index dc7a7d7676b6f..b6ca5e3ae1b08 100644 --- a/google/cloud/resourcemanager/v3/samples/folders_client_samples.cc +++ b/google/cloud/resourcemanager/v3/samples/folders_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -57,6 +58,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::resourcemanager_v3::FoldersClient( + google::cloud::resourcemanager_v3::MakeFoldersConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::resourcemanager_v3:: FoldersConnectionIdempotencyPolicy { @@ -194,6 +214,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -204,6 +227,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/resourcemanager/v3/samples/organizations_client_samples.cc b/google/cloud/resourcemanager/v3/samples/organizations_client_samples.cc index 6cc06e0f1d4dd..8fdc8f5150bfe 100644 --- a/google/cloud/resourcemanager/v3/samples/organizations_client_samples.cc +++ b/google/cloud/resourcemanager/v3/samples/organizations_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -55,6 +56,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::resourcemanager_v3::OrganizationsClient( + google::cloud::resourcemanager_v3::MakeOrganizationsConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::resourcemanager_v3:: OrganizationsConnectionIdempotencyPolicy { @@ -152,6 +173,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -161,6 +185,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/resourcemanager/v3/samples/projects_client_samples.cc b/google/cloud/resourcemanager/v3/samples/projects_client_samples.cc index 6aecc8fd28f24..e8220d1aae1f0 100644 --- a/google/cloud/resourcemanager/v3/samples/projects_client_samples.cc +++ b/google/cloud/resourcemanager/v3/samples/projects_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -57,6 +58,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::resourcemanager_v3::ProjectsClient( + google::cloud::resourcemanager_v3::MakeProjectsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::resourcemanager_v3:: ProjectsConnectionIdempotencyPolicy { @@ -194,6 +214,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -204,6 +227,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/resourcemanager/v3/samples/tag_bindings_client_samples.cc b/google/cloud/resourcemanager/v3/samples/tag_bindings_client_samples.cc index b82d200025686..aff6e0c8363e2 100644 --- a/google/cloud/resourcemanager/v3/samples/tag_bindings_client_samples.cc +++ b/google/cloud/resourcemanager/v3/samples/tag_bindings_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -57,6 +58,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::resourcemanager_v3::TagBindingsClient( + google::cloud::resourcemanager_v3::MakeTagBindingsConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::resourcemanager_v3:: TagBindingsConnectionIdempotencyPolicy { @@ -196,6 +217,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -206,6 +230,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/resourcemanager/v3/samples/tag_holds_client_samples.cc b/google/cloud/resourcemanager/v3/samples/tag_holds_client_samples.cc index 41f9a6bee0944..3d7702bbb4042 100644 --- a/google/cloud/resourcemanager/v3/samples/tag_holds_client_samples.cc +++ b/google/cloud/resourcemanager/v3/samples/tag_holds_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -57,6 +58,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::resourcemanager_v3::TagHoldsClient( + google::cloud::resourcemanager_v3::MakeTagHoldsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::resourcemanager_v3:: TagHoldsConnectionIdempotencyPolicy { @@ -194,6 +214,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -204,6 +227,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/resourcemanager/v3/samples/tag_keys_client_samples.cc b/google/cloud/resourcemanager/v3/samples/tag_keys_client_samples.cc index c13dc943d5d0e..ef5ef66d4612b 100644 --- a/google/cloud/resourcemanager/v3/samples/tag_keys_client_samples.cc +++ b/google/cloud/resourcemanager/v3/samples/tag_keys_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -57,6 +58,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::resourcemanager_v3::TagKeysClient( + google::cloud::resourcemanager_v3::MakeTagKeysConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::resourcemanager_v3:: TagKeysConnectionIdempotencyPolicy { @@ -194,6 +214,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -204,6 +227,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/resourcemanager/v3/samples/tag_values_client_samples.cc b/google/cloud/resourcemanager/v3/samples/tag_values_client_samples.cc index 395c902619b75..9cc817ca8aff5 100644 --- a/google/cloud/resourcemanager/v3/samples/tag_values_client_samples.cc +++ b/google/cloud/resourcemanager/v3/samples/tag_values_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -57,6 +58,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::resourcemanager_v3::TagValuesClient( + google::cloud::resourcemanager_v3::MakeTagValuesConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::resourcemanager_v3:: TagValuesConnectionIdempotencyPolicy { @@ -194,6 +214,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -204,6 +227,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/retail/doc/override-universe-domain.dox b/google/cloud/retail/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..5104c298f2c9d --- /dev/null +++ b/google/cloud/retail/doc/override-universe-domain.dox @@ -0,0 +1,92 @@ +/*! +@page retail-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `retail_v2::AnalyticsServiceClient`: + +@snippet analytics_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c retail_v2::AnalyticsServiceClient](@ref retail_v2::AnalyticsServiceClient-universe-domain-snippet) +- [\c retail_v2::CatalogServiceClient](@ref retail_v2::CatalogServiceClient-universe-domain-snippet) +- [\c retail_v2::CompletionServiceClient](@ref retail_v2::CompletionServiceClient-universe-domain-snippet) +- [\c retail_v2::ControlServiceClient](@ref retail_v2::ControlServiceClient-universe-domain-snippet) +- [\c retail_v2::ModelServiceClient](@ref retail_v2::ModelServiceClient-universe-domain-snippet) +- [\c retail_v2::PredictionServiceClient](@ref retail_v2::PredictionServiceClient-universe-domain-snippet) +- [\c retail_v2::ProductServiceClient](@ref retail_v2::ProductServiceClient-universe-domain-snippet) +- [\c retail_v2::SearchServiceClient](@ref retail_v2::SearchServiceClient-universe-domain-snippet) +- [\c retail_v2::ServingConfigServiceClient](@ref retail_v2::ServingConfigServiceClient-universe-domain-snippet) +- [\c retail_v2::UserEventServiceClient](@ref retail_v2::UserEventServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page retail_v2::AnalyticsServiceClient-universe-domain-snippet Override retail_v2::AnalyticsServiceClient Universe Domain + +@snippet google/cloud/retail/v2/samples/analytics_client_samples.cc set-client-universe-domain + +*/ + +/*! @page retail_v2::CatalogServiceClient-universe-domain-snippet Override retail_v2::CatalogServiceClient Universe Domain + +@snippet google/cloud/retail/v2/samples/catalog_client_samples.cc set-client-universe-domain + +*/ + +/*! @page retail_v2::CompletionServiceClient-universe-domain-snippet Override retail_v2::CompletionServiceClient Universe Domain + +@snippet google/cloud/retail/v2/samples/completion_client_samples.cc set-client-universe-domain + +*/ + +/*! @page retail_v2::ControlServiceClient-universe-domain-snippet Override retail_v2::ControlServiceClient Universe Domain + +@snippet google/cloud/retail/v2/samples/control_client_samples.cc set-client-universe-domain + +*/ + +/*! @page retail_v2::ModelServiceClient-universe-domain-snippet Override retail_v2::ModelServiceClient Universe Domain + +@snippet google/cloud/retail/v2/samples/model_client_samples.cc set-client-universe-domain + +*/ + +/*! @page retail_v2::PredictionServiceClient-universe-domain-snippet Override retail_v2::PredictionServiceClient Universe Domain + +@snippet google/cloud/retail/v2/samples/prediction_client_samples.cc set-client-universe-domain + +*/ + +/*! @page retail_v2::ProductServiceClient-universe-domain-snippet Override retail_v2::ProductServiceClient Universe Domain + +@snippet google/cloud/retail/v2/samples/product_client_samples.cc set-client-universe-domain + +*/ + +/*! @page retail_v2::SearchServiceClient-universe-domain-snippet Override retail_v2::SearchServiceClient Universe Domain + +@snippet google/cloud/retail/v2/samples/search_client_samples.cc set-client-universe-domain + +*/ + +/*! @page retail_v2::ServingConfigServiceClient-universe-domain-snippet Override retail_v2::ServingConfigServiceClient Universe Domain + +@snippet google/cloud/retail/v2/samples/serving_config_client_samples.cc set-client-universe-domain + +*/ + +/*! @page retail_v2::UserEventServiceClient-universe-domain-snippet Override retail_v2::UserEventServiceClient Universe Domain + +@snippet google/cloud/retail/v2/samples/user_event_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/retail/v2/samples/analytics_client_samples.cc b/google/cloud/retail/v2/samples/analytics_client_samples.cc index 67ef551b9a701..6569e854f64bc 100644 --- a/google/cloud/retail/v2/samples/analytics_client_samples.cc +++ b/google/cloud/retail/v2/samples/analytics_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::retail_v2::AnalyticsServiceClient( + google::cloud::retail_v2::MakeAnalyticsServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::retail_v2:: @@ -187,6 +207,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -197,6 +220,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/retail/v2/samples/catalog_client_samples.cc b/google/cloud/retail/v2/samples/catalog_client_samples.cc index d0302a6c4aa0e..bcdcada0b3ae8 100644 --- a/google/cloud/retail/v2/samples/catalog_client_samples.cc +++ b/google/cloud/retail/v2/samples/catalog_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::retail_v2::CatalogServiceClient( + google::cloud::retail_v2::MakeCatalogServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::retail_v2:: CatalogServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/retail/v2/samples/completion_client_samples.cc b/google/cloud/retail/v2/samples/completion_client_samples.cc index 0aca162f16f5d..96fca1a7c7dcf 100644 --- a/google/cloud/retail/v2/samples/completion_client_samples.cc +++ b/google/cloud/retail/v2/samples/completion_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::retail_v2::CompletionServiceClient( + google::cloud::retail_v2::MakeCompletionServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::retail_v2:: @@ -187,6 +207,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -197,6 +220,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/retail/v2/samples/control_client_samples.cc b/google/cloud/retail/v2/samples/control_client_samples.cc index 668cf4a496ba8..2fbfbc7a6535f 100644 --- a/google/cloud/retail/v2/samples/control_client_samples.cc +++ b/google/cloud/retail/v2/samples/control_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::retail_v2::ControlServiceClient( + google::cloud::retail_v2::MakeControlServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::retail_v2:: ControlServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/retail/v2/samples/model_client_samples.cc b/google/cloud/retail/v2/samples/model_client_samples.cc index cd2f59bc7d3b3..86222d4df124c 100644 --- a/google/cloud/retail/v2/samples/model_client_samples.cc +++ b/google/cloud/retail/v2/samples/model_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::retail_v2::ModelServiceClient( + google::cloud::retail_v2::MakeModelServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::retail_v2::ModelServiceConnectionIdempotencyPolicy { @@ -184,6 +204,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -194,6 +217,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/retail/v2/samples/prediction_client_samples.cc b/google/cloud/retail/v2/samples/prediction_client_samples.cc index d467183ffe597..9920190620c98 100644 --- a/google/cloud/retail/v2/samples/prediction_client_samples.cc +++ b/google/cloud/retail/v2/samples/prediction_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::retail_v2::PredictionServiceClient( + google::cloud::retail_v2::MakePredictionServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::retail_v2:: @@ -142,6 +162,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -151,6 +174,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/retail/v2/samples/product_client_samples.cc b/google/cloud/retail/v2/samples/product_client_samples.cc index 094dc659eec64..b717322187aa2 100644 --- a/google/cloud/retail/v2/samples/product_client_samples.cc +++ b/google/cloud/retail/v2/samples/product_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::retail_v2::ProductServiceClient( + google::cloud::retail_v2::MakeProductServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::retail_v2:: ProductServiceConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/retail/v2/samples/search_client_samples.cc b/google/cloud/retail/v2/samples/search_client_samples.cc index 23b6a64297b8f..df48b18a40201 100644 --- a/google/cloud/retail/v2/samples/search_client_samples.cc +++ b/google/cloud/retail/v2/samples/search_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::retail_v2::SearchServiceClient( + google::cloud::retail_v2::MakeSearchServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::retail_v2:: SearchServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/retail/v2/samples/serving_config_client_samples.cc b/google/cloud/retail/v2/samples/serving_config_client_samples.cc index b3579eb25d9d4..f26da7b73cf46 100644 --- a/google/cloud/retail/v2/samples/serving_config_client_samples.cc +++ b/google/cloud/retail/v2/samples/serving_config_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::retail_v2::ServingConfigServiceClient( + google::cloud::retail_v2::MakeServingConfigServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::retail_v2:: @@ -144,6 +165,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -153,6 +177,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/retail/v2/samples/user_event_client_samples.cc b/google/cloud/retail/v2/samples/user_event_client_samples.cc index ad928b317ce5d..37b00325cb0cb 100644 --- a/google/cloud/retail/v2/samples/user_event_client_samples.cc +++ b/google/cloud/retail/v2/samples/user_event_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::retail_v2::UserEventServiceClient( + google::cloud::retail_v2::MakeUserEventServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::retail_v2:: @@ -187,6 +207,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -197,6 +220,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/run/doc/override-universe-domain.dox b/google/cloud/run/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..8283d6934f292 --- /dev/null +++ b/google/cloud/run/doc/override-universe-domain.dox @@ -0,0 +1,57 @@ +/*! +@page run-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `run_v2::ExecutionsClient`: + +@snippet executions_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c run_v2::ExecutionsClient](@ref run_v2::ExecutionsClient-universe-domain-snippet) +- [\c run_v2::JobsClient](@ref run_v2::JobsClient-universe-domain-snippet) +- [\c run_v2::RevisionsClient](@ref run_v2::RevisionsClient-universe-domain-snippet) +- [\c run_v2::ServicesClient](@ref run_v2::ServicesClient-universe-domain-snippet) +- [\c run_v2::TasksClient](@ref run_v2::TasksClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page run_v2::ExecutionsClient-universe-domain-snippet Override run_v2::ExecutionsClient Universe Domain + +@snippet google/cloud/run/v2/samples/executions_client_samples.cc set-client-universe-domain + +*/ + +/*! @page run_v2::JobsClient-universe-domain-snippet Override run_v2::JobsClient Universe Domain + +@snippet google/cloud/run/v2/samples/jobs_client_samples.cc set-client-universe-domain + +*/ + +/*! @page run_v2::RevisionsClient-universe-domain-snippet Override run_v2::RevisionsClient Universe Domain + +@snippet google/cloud/run/v2/samples/revisions_client_samples.cc set-client-universe-domain + +*/ + +/*! @page run_v2::ServicesClient-universe-domain-snippet Override run_v2::ServicesClient Universe Domain + +@snippet google/cloud/run/v2/samples/services_client_samples.cc set-client-universe-domain + +*/ + +/*! @page run_v2::TasksClient-universe-domain-snippet Override run_v2::TasksClient Universe Domain + +@snippet google/cloud/run/v2/samples/tasks_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/run/v2/samples/executions_client_samples.cc b/google/cloud/run/v2/samples/executions_client_samples.cc index 22a52321fa230..8a314fee844e3 100644 --- a/google/cloud/run/v2/samples/executions_client_samples.cc +++ b/google/cloud/run/v2/samples/executions_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::run_v2::ExecutionsClient( + google::cloud::run_v2::MakeExecutionsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::run_v2::ExecutionsConnectionIdempotencyPolicy { @@ -179,6 +199,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -189,6 +212,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/run/v2/samples/jobs_client_samples.cc b/google/cloud/run/v2/samples/jobs_client_samples.cc index 775fec20d47a7..668eeb67a2d52 100644 --- a/google/cloud/run/v2/samples/jobs_client_samples.cc +++ b/google/cloud/run/v2/samples/jobs_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::run_v2::JobsClient( + google::cloud::run_v2::MakeJobsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::run_v2::JobsConnectionIdempotencyPolicy { @@ -177,6 +197,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -187,6 +210,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/run/v2/samples/revisions_client_samples.cc b/google/cloud/run/v2/samples/revisions_client_samples.cc index f9350944e89cb..8af27435fd125 100644 --- a/google/cloud/run/v2/samples/revisions_client_samples.cc +++ b/google/cloud/run/v2/samples/revisions_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::run_v2::RevisionsClient( + google::cloud::run_v2::MakeRevisionsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::run_v2::RevisionsConnectionIdempotencyPolicy { @@ -179,6 +199,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -189,6 +212,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/run/v2/samples/services_client_samples.cc b/google/cloud/run/v2/samples/services_client_samples.cc index 6549b6d7b735d..fac7fd2060b20 100644 --- a/google/cloud/run/v2/samples/services_client_samples.cc +++ b/google/cloud/run/v2/samples/services_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::run_v2::ServicesClient( + google::cloud::run_v2::MakeServicesConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::run_v2::ServicesConnectionIdempotencyPolicy { @@ -178,6 +198,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -188,6 +211,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/run/v2/samples/tasks_client_samples.cc b/google/cloud/run/v2/samples/tasks_client_samples.cc index b088a1e0e8431..2eded4e602667 100644 --- a/google/cloud/run/v2/samples/tasks_client_samples.cc +++ b/google/cloud/run/v2/samples/tasks_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::run_v2::TasksClient( + google::cloud::run_v2::MakeTasksConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::run_v2::TasksConnectionIdempotencyPolicy { @@ -136,6 +156,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -145,6 +168,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/scheduler/doc/override-universe-domain.dox b/google/cloud/scheduler/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..a7be37345d841 --- /dev/null +++ b/google/cloud/scheduler/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page scheduler-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `scheduler_v1::CloudSchedulerClient`: + +@snippet cloud_scheduler_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page scheduler_v1::CloudSchedulerClient-universe-domain-snippet Override scheduler_v1::CloudSchedulerClient Universe Domain + +@snippet google/cloud/scheduler/v1/samples/cloud_scheduler_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/scheduler/v1/samples/cloud_scheduler_client_samples.cc b/google/cloud/scheduler/v1/samples/cloud_scheduler_client_samples.cc index 40091c5f87892..2c9e812df62b6 100644 --- a/google/cloud/scheduler/v1/samples/cloud_scheduler_client_samples.cc +++ b/google/cloud/scheduler/v1/samples/cloud_scheduler_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::scheduler_v1::CloudSchedulerClient( + google::cloud::scheduler_v1::MakeCloudSchedulerConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::scheduler_v1:: CloudSchedulerConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/secretmanager/doc/override-universe-domain.dox b/google/cloud/secretmanager/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..716c5434f2d50 --- /dev/null +++ b/google/cloud/secretmanager/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page secretmanager-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `secretmanager_v1::SecretManagerServiceClient`: + +@snippet secret_manager_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page secretmanager_v1::SecretManagerServiceClient-universe-domain-snippet Override secretmanager_v1::SecretManagerServiceClient Universe Domain + +@snippet google/cloud/secretmanager/v1/samples/secret_manager_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/secretmanager/v1/samples/secret_manager_client_samples.cc b/google/cloud/secretmanager/v1/samples/secret_manager_client_samples.cc index 75a8dd2b4c99e..7019b80391c6b 100644 --- a/google/cloud/secretmanager/v1/samples/secret_manager_client_samples.cc +++ b/google/cloud/secretmanager/v1/samples/secret_manager_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::secretmanager_v1::SecretManagerServiceClient( + google::cloud::secretmanager_v1::MakeSecretManagerServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::secretmanager_v1:: @@ -150,6 +171,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -159,6 +183,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/securesourcemanager/doc/override-universe-domain.dox b/google/cloud/securesourcemanager/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..54f63c0a62ab6 --- /dev/null +++ b/google/cloud/securesourcemanager/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page securesourcemanager-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `securesourcemanager_v1::SecureSourceManagerClient`: + +@snippet secure_source_manager_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page securesourcemanager_v1::SecureSourceManagerClient-universe-domain-snippet Override securesourcemanager_v1::SecureSourceManagerClient Universe Domain + +@snippet google/cloud/securesourcemanager/v1/samples/secure_source_manager_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/securesourcemanager/v1/samples/secure_source_manager_client_samples.cc b/google/cloud/securesourcemanager/v1/samples/secure_source_manager_client_samples.cc index 34ad3bea58722..98bd5164eed9e 100644 --- a/google/cloud/securesourcemanager/v1/samples/secure_source_manager_client_samples.cc +++ b/google/cloud/securesourcemanager/v1/samples/secure_source_manager_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::securesourcemanager_v1::SecureSourceManagerClient( + google::cloud::securesourcemanager_v1:: + MakeSecureSourceManagerConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::securesourcemanager_v1:: @@ -200,6 +222,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -210,6 +235,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/securitycenter/doc/override-universe-domain.dox b/google/cloud/securitycenter/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..f30156318a317 --- /dev/null +++ b/google/cloud/securitycenter/doc/override-universe-domain.dox @@ -0,0 +1,36 @@ +/*! +@page securitycenter-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `securitycenter_v1::SecurityCenterClient`: + +@snippet security_center_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c securitycenter_v1::SecurityCenterClient](@ref securitycenter_v1::SecurityCenterClient-universe-domain-snippet) +- [\c securitycenter_v2::SecurityCenterClient](@ref securitycenter_v2::SecurityCenterClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page securitycenter_v1::SecurityCenterClient-universe-domain-snippet Override securitycenter_v1::SecurityCenterClient Universe Domain + +@snippet google/cloud/securitycenter/v1/samples/security_center_client_samples.cc set-client-universe-domain + +*/ + +/*! @page securitycenter_v2::SecurityCenterClient-universe-domain-snippet Override securitycenter_v2::SecurityCenterClient Universe Domain + +@snippet google/cloud/securitycenter/v2/samples/security_center_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/securitycenter/v1/samples/security_center_client_samples.cc b/google/cloud/securitycenter/v1/samples/security_center_client_samples.cc index 2ba185e54acc0..e158371bbf668 100644 --- a/google/cloud/securitycenter/v1/samples/security_center_client_samples.cc +++ b/google/cloud/securitycenter/v1/samples/security_center_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::securitycenter_v1::SecurityCenterClient( + google::cloud::securitycenter_v1::MakeSecurityCenterConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::securitycenter_v1:: SecurityCenterConnectionIdempotencyPolicy { @@ -190,6 +211,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -200,6 +224,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/securitycenter/v2/samples/security_center_client_samples.cc b/google/cloud/securitycenter/v2/samples/security_center_client_samples.cc index 25c36afb2f8a3..9895e1449ac50 100644 --- a/google/cloud/securitycenter/v2/samples/security_center_client_samples.cc +++ b/google/cloud/securitycenter/v2/samples/security_center_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::securitycenter_v2::SecurityCenterClient( + google::cloud::securitycenter_v2::MakeSecurityCenterConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::securitycenter_v2:: SecurityCenterConnectionIdempotencyPolicy { @@ -190,6 +211,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -200,6 +224,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/securitycentermanagement/doc/override-universe-domain.dox b/google/cloud/securitycentermanagement/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..bd603e88614a1 --- /dev/null +++ b/google/cloud/securitycentermanagement/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page securitycentermanagement-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `securitycentermanagement_v1::SecurityCenterManagementClient`: + +@snippet security_center_management_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page securitycentermanagement_v1::SecurityCenterManagementClient-universe-domain-snippet Override securitycentermanagement_v1::SecurityCenterManagementClient Universe Domain + +@snippet google/cloud/securitycentermanagement/v1/samples/security_center_management_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/securitycentermanagement/v1/samples/security_center_management_client_samples.cc b/google/cloud/securitycentermanagement/v1/samples/security_center_management_client_samples.cc index c9a89796531d4..273428bf13497 100644 --- a/google/cloud/securitycentermanagement/v1/samples/security_center_management_client_samples.cc +++ b/google/cloud/securitycentermanagement/v1/samples/security_center_management_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::securitycentermanagement_v1:: + SecurityCenterManagementClient( + google::cloud::securitycentermanagement_v1:: + MakeSecurityCenterManagementConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::securitycentermanagement_v1:: @@ -154,6 +176,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -163,6 +188,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/servicecontrol/doc/override-universe-domain.dox b/google/cloud/servicecontrol/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..f6d93ac6dd4be --- /dev/null +++ b/google/cloud/servicecontrol/doc/override-universe-domain.dox @@ -0,0 +1,43 @@ +/*! +@page servicecontrol-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `servicecontrol_v1::QuotaControllerClient`: + +@snippet quota_controller_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c servicecontrol_v1::QuotaControllerClient](@ref servicecontrol_v1::QuotaControllerClient-universe-domain-snippet) +- [\c servicecontrol_v1::ServiceControllerClient](@ref servicecontrol_v1::ServiceControllerClient-universe-domain-snippet) +- [\c servicecontrol_v2::ServiceControllerClient](@ref servicecontrol_v2::ServiceControllerClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page servicecontrol_v1::QuotaControllerClient-universe-domain-snippet Override servicecontrol_v1::QuotaControllerClient Universe Domain + +@snippet google/cloud/servicecontrol/v1/samples/quota_controller_client_samples.cc set-client-universe-domain + +*/ + +/*! @page servicecontrol_v1::ServiceControllerClient-universe-domain-snippet Override servicecontrol_v1::ServiceControllerClient Universe Domain + +@snippet google/cloud/servicecontrol/v1/samples/service_controller_client_samples.cc set-client-universe-domain + +*/ + +/*! @page servicecontrol_v2::ServiceControllerClient-universe-domain-snippet Override servicecontrol_v2::ServiceControllerClient Universe Domain + +@snippet google/cloud/servicecontrol/v2/samples/service_controller_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/servicecontrol/v1/samples/quota_controller_client_samples.cc b/google/cloud/servicecontrol/v1/samples/quota_controller_client_samples.cc index 09c688f13785d..7097c59a29a12 100644 --- a/google/cloud/servicecontrol/v1/samples/quota_controller_client_samples.cc +++ b/google/cloud/servicecontrol/v1/samples/quota_controller_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::servicecontrol_v1::QuotaControllerClient( + google::cloud::servicecontrol_v1::MakeQuotaControllerConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::servicecontrol_v1:: QuotaControllerConnectionIdempotencyPolicy { @@ -144,6 +165,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -153,6 +177,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/servicecontrol/v1/samples/service_controller_client_samples.cc b/google/cloud/servicecontrol/v1/samples/service_controller_client_samples.cc index b1b2afddcc08c..a5fe55c6ae5bc 100644 --- a/google/cloud/servicecontrol/v1/samples/service_controller_client_samples.cc +++ b/google/cloud/servicecontrol/v1/samples/service_controller_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::servicecontrol_v1::ServiceControllerClient( + google::cloud::servicecontrol_v1::MakeServiceControllerConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::servicecontrol_v1:: @@ -150,6 +171,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -159,6 +183,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/servicecontrol/v2/samples/service_controller_client_samples.cc b/google/cloud/servicecontrol/v2/samples/service_controller_client_samples.cc index 21a9505d3c573..80864acb93e24 100644 --- a/google/cloud/servicecontrol/v2/samples/service_controller_client_samples.cc +++ b/google/cloud/servicecontrol/v2/samples/service_controller_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::servicecontrol_v2::ServiceControllerClient( + google::cloud::servicecontrol_v2::MakeServiceControllerConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::servicecontrol_v2:: @@ -150,6 +171,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -159,6 +183,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/servicedirectory/doc/override-universe-domain.dox b/google/cloud/servicedirectory/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..9c15b7da8beec --- /dev/null +++ b/google/cloud/servicedirectory/doc/override-universe-domain.dox @@ -0,0 +1,36 @@ +/*! +@page servicedirectory-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `servicedirectory_v1::LookupServiceClient`: + +@snippet lookup_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c servicedirectory_v1::LookupServiceClient](@ref servicedirectory_v1::LookupServiceClient-universe-domain-snippet) +- [\c servicedirectory_v1::RegistrationServiceClient](@ref servicedirectory_v1::RegistrationServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page servicedirectory_v1::LookupServiceClient-universe-domain-snippet Override servicedirectory_v1::LookupServiceClient Universe Domain + +@snippet google/cloud/servicedirectory/v1/samples/lookup_client_samples.cc set-client-universe-domain + +*/ + +/*! @page servicedirectory_v1::RegistrationServiceClient-universe-domain-snippet Override servicedirectory_v1::RegistrationServiceClient Universe Domain + +@snippet google/cloud/servicedirectory/v1/samples/registration_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/servicedirectory/v1/samples/lookup_client_samples.cc b/google/cloud/servicedirectory/v1/samples/lookup_client_samples.cc index b5efbaebdf85f..7f672a6dcd4a4 100644 --- a/google/cloud/servicedirectory/v1/samples/lookup_client_samples.cc +++ b/google/cloud/servicedirectory/v1/samples/lookup_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::servicedirectory_v1::LookupServiceClient( + google::cloud::servicedirectory_v1::MakeLookupServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::servicedirectory_v1:: LookupServiceConnectionIdempotencyPolicy { @@ -144,6 +165,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -153,6 +177,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/servicedirectory/v1/samples/registration_client_samples.cc b/google/cloud/servicedirectory/v1/samples/registration_client_samples.cc index d163317b44f64..dd457877a5edd 100644 --- a/google/cloud/servicedirectory/v1/samples/registration_client_samples.cc +++ b/google/cloud/servicedirectory/v1/samples/registration_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::servicedirectory_v1::RegistrationServiceClient( + google::cloud::servicedirectory_v1::MakeRegistrationServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::servicedirectory_v1:: @@ -151,6 +173,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -160,6 +185,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/servicehealth/doc/override-universe-domain.dox b/google/cloud/servicehealth/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..f820ce4fd9c83 --- /dev/null +++ b/google/cloud/servicehealth/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page servicehealth-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `servicehealth_v1::ServiceHealthClient`: + +@snippet service_health_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page servicehealth_v1::ServiceHealthClient-universe-domain-snippet Override servicehealth_v1::ServiceHealthClient Universe Domain + +@snippet google/cloud/servicehealth/v1/samples/service_health_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/servicehealth/v1/samples/service_health_client_samples.cc b/google/cloud/servicehealth/v1/samples/service_health_client_samples.cc index a52feb87615a8..ac3d5bd3481ae 100644 --- a/google/cloud/servicehealth/v1/samples/service_health_client_samples.cc +++ b/google/cloud/servicehealth/v1/samples/service_health_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::servicehealth_v1::ServiceHealthClient( + google::cloud::servicehealth_v1::MakeServiceHealthConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::servicehealth_v1:: ServiceHealthConnectionIdempotencyPolicy { @@ -142,6 +163,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -151,6 +175,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/servicemanagement/doc/override-universe-domain.dox b/google/cloud/servicemanagement/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..9aae1f9e8ea93 --- /dev/null +++ b/google/cloud/servicemanagement/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page servicemanagement-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `servicemanagement_v1::ServiceManagerClient`: + +@snippet service_manager_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page servicemanagement_v1::ServiceManagerClient-universe-domain-snippet Override servicemanagement_v1::ServiceManagerClient Universe Domain + +@snippet google/cloud/servicemanagement/v1/samples/service_manager_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/servicemanagement/v1/samples/service_manager_client_samples.cc b/google/cloud/servicemanagement/v1/samples/service_manager_client_samples.cc index 431e2826a6cf0..faa40ada4bee3 100644 --- a/google/cloud/servicemanagement/v1/samples/service_manager_client_samples.cc +++ b/google/cloud/servicemanagement/v1/samples/service_manager_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::servicemanagement_v1::ServiceManagerClient( + google::cloud::servicemanagement_v1::MakeServiceManagerConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::servicemanagement_v1:: ServiceManagerConnectionIdempotencyPolicy { @@ -197,6 +218,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -207,6 +231,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/serviceusage/doc/override-universe-domain.dox b/google/cloud/serviceusage/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..daa266d02eed3 --- /dev/null +++ b/google/cloud/serviceusage/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page serviceusage-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `serviceusage_v1::ServiceUsageClient`: + +@snippet service_usage_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page serviceusage_v1::ServiceUsageClient-universe-domain-snippet Override serviceusage_v1::ServiceUsageClient Universe Domain + +@snippet google/cloud/serviceusage/v1/samples/service_usage_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/serviceusage/v1/samples/service_usage_client_samples.cc b/google/cloud/serviceusage/v1/samples/service_usage_client_samples.cc index 7ae7ef7c61fca..23b1851065ffd 100644 --- a/google/cloud/serviceusage/v1/samples/service_usage_client_samples.cc +++ b/google/cloud/serviceusage/v1/samples/service_usage_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::serviceusage_v1::ServiceUsageClient( + google::cloud::serviceusage_v1::MakeServiceUsageConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::serviceusage_v1:: ServiceUsageConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/shell/doc/override-universe-domain.dox b/google/cloud/shell/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..27a52e4fb1acc --- /dev/null +++ b/google/cloud/shell/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page shell-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `shell_v1::CloudShellServiceClient`: + +@snippet cloud_shell_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page shell_v1::CloudShellServiceClient-universe-domain-snippet Override shell_v1::CloudShellServiceClient Universe Domain + +@snippet google/cloud/shell/v1/samples/cloud_shell_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/shell/v1/samples/cloud_shell_client_samples.cc b/google/cloud/shell/v1/samples/cloud_shell_client_samples.cc index ae84d91eb4c32..76b4300613165 100644 --- a/google/cloud/shell/v1/samples/cloud_shell_client_samples.cc +++ b/google/cloud/shell/v1/samples/cloud_shell_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::shell_v1::CloudShellServiceClient( + google::cloud::shell_v1::MakeCloudShellServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::shell_v1:: @@ -187,6 +207,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -197,6 +220,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/spanner/admin/samples/BUILD.bazel b/google/cloud/spanner/admin/samples/BUILD.bazel index 8b2492c8ff9cd..40f9e6ba97585 100644 --- a/google/cloud/spanner/admin/samples/BUILD.bazel +++ b/google/cloud/spanner/admin/samples/BUILD.bazel @@ -22,6 +22,7 @@ licenses(["notice"]) # Apache 2.0 tags = ["integration-test"], deps = [ "//:spanner", + "//:universe_domain", "//google/cloud/testing_util:google_cloud_cpp_testing_private", ], ) for sample in glob(["*.cc"])] diff --git a/google/cloud/spanner/admin/samples/database_admin_client_samples.cc b/google/cloud/spanner/admin/samples/database_admin_client_samples.cc index 8bc49a737f649..0062a107bedb8 100644 --- a/google/cloud/spanner/admin/samples/database_admin_client_samples.cc +++ b/google/cloud/spanner/admin/samples/database_admin_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::spanner_admin::DatabaseAdminClient( + google::cloud::spanner_admin::MakeDatabaseAdminConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::spanner_admin:: DatabaseAdminConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/spanner/admin/samples/instance_admin_client_samples.cc b/google/cloud/spanner/admin/samples/instance_admin_client_samples.cc index 6c1d63ed8fb97..938074a9b7c03 100644 --- a/google/cloud/spanner/admin/samples/instance_admin_client_samples.cc +++ b/google/cloud/spanner/admin/samples/instance_admin_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::spanner_admin::InstanceAdminClient( + google::cloud::spanner_admin::MakeInstanceAdminConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::spanner_admin:: InstanceAdminConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/speech/doc/override-universe-domain.dox b/google/cloud/speech/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..5123c3d8553ca --- /dev/null +++ b/google/cloud/speech/doc/override-universe-domain.dox @@ -0,0 +1,43 @@ +/*! +@page speech-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `speech_v1::AdaptationClient`: + +@snippet adaptation_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c speech_v1::AdaptationClient](@ref speech_v1::AdaptationClient-universe-domain-snippet) +- [\c speech_v1::SpeechClient](@ref speech_v1::SpeechClient-universe-domain-snippet) +- [\c speech_v2::SpeechClient](@ref speech_v2::SpeechClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page speech_v1::AdaptationClient-universe-domain-snippet Override speech_v1::AdaptationClient Universe Domain + +@snippet google/cloud/speech/v1/samples/adaptation_client_samples.cc set-client-universe-domain + +*/ + +/*! @page speech_v1::SpeechClient-universe-domain-snippet Override speech_v1::SpeechClient Universe Domain + +@snippet google/cloud/speech/v1/samples/speech_client_samples.cc set-client-universe-domain + +*/ + +/*! @page speech_v2::SpeechClient-universe-domain-snippet Override speech_v2::SpeechClient Universe Domain + +@snippet google/cloud/speech/v2/samples/speech_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/speech/v1/samples/adaptation_client_samples.cc b/google/cloud/speech/v1/samples/adaptation_client_samples.cc index e99566164512e..a48ae14969e3d 100644 --- a/google/cloud/speech/v1/samples/adaptation_client_samples.cc +++ b/google/cloud/speech/v1/samples/adaptation_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::speech_v1::AdaptationClient( + google::cloud::speech_v1::MakeAdaptationConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::speech_v1::AdaptationConnectionIdempotencyPolicy { @@ -140,6 +160,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -149,6 +172,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/speech/v1/samples/speech_client_samples.cc b/google/cloud/speech/v1/samples/speech_client_samples.cc index b55d95ce178ce..3940e3d49e775 100644 --- a/google/cloud/speech/v1/samples/speech_client_samples.cc +++ b/google/cloud/speech/v1/samples/speech_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::speech_v1::SpeechClient( + google::cloud::speech_v1::MakeSpeechConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::speech_v1::SpeechConnectionIdempotencyPolicy { @@ -179,6 +199,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -189,6 +212,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/speech/v2/samples/speech_client_samples.cc b/google/cloud/speech/v2/samples/speech_client_samples.cc index 708ff08cc0850..968a1bfb5a6cb 100644 --- a/google/cloud/speech/v2/samples/speech_client_samples.cc +++ b/google/cloud/speech/v2/samples/speech_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::speech_v2::SpeechClient( + google::cloud::speech_v2::MakeSpeechConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::speech_v2::SpeechConnectionIdempotencyPolicy { @@ -179,6 +199,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -189,6 +212,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/sql/doc/override-universe-domain.dox b/google/cloud/sql/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..33b4653bd4287 --- /dev/null +++ b/google/cloud/sql/doc/override-universe-domain.dox @@ -0,0 +1,120 @@ +/*! +@page sql-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `sql_v1::SqlAvailableDatabaseVersionsServiceClient`: + +@snippet sql_available_database_versions_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c sql_v1::SqlAvailableDatabaseVersionsServiceClient](@ref sql_v1::SqlAvailableDatabaseVersionsServiceClient-universe-domain-snippet) +- [\c sql_v1::SqlBackupRunsServiceClient](@ref sql_v1::SqlBackupRunsServiceClient-universe-domain-snippet) +- [\c sql_v1::SqlConnectServiceClient](@ref sql_v1::SqlConnectServiceClient-universe-domain-snippet) +- [\c sql_v1::SqlDatabasesServiceClient](@ref sql_v1::SqlDatabasesServiceClient-universe-domain-snippet) +- [\c sql_v1::SqlEventsServiceClient](@ref sql_v1::SqlEventsServiceClient-universe-domain-snippet) +- [\c sql_v1::SqlFlagsServiceClient](@ref sql_v1::SqlFlagsServiceClient-universe-domain-snippet) +- [\c sql_v1::SqlIamPoliciesServiceClient](@ref sql_v1::SqlIamPoliciesServiceClient-universe-domain-snippet) +- [\c sql_v1::SqlInstanceNamesServiceClient](@ref sql_v1::SqlInstanceNamesServiceClient-universe-domain-snippet) +- [\c sql_v1::SqlInstancesServiceClient](@ref sql_v1::SqlInstancesServiceClient-universe-domain-snippet) +- [\c sql_v1::SqlOperationsServiceClient](@ref sql_v1::SqlOperationsServiceClient-universe-domain-snippet) +- [\c sql_v1::SqlRegionsServiceClient](@ref sql_v1::SqlRegionsServiceClient-universe-domain-snippet) +- [\c sql_v1::SqlSslCertsServiceClient](@ref sql_v1::SqlSslCertsServiceClient-universe-domain-snippet) +- [\c sql_v1::SqlTiersServiceClient](@ref sql_v1::SqlTiersServiceClient-universe-domain-snippet) +- [\c sql_v1::SqlUsersServiceClient](@ref sql_v1::SqlUsersServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page sql_v1::SqlAvailableDatabaseVersionsServiceClient-universe-domain-snippet Override sql_v1::SqlAvailableDatabaseVersionsServiceClient Universe Domain + +@snippet google/cloud/sql/v1/samples/sql_available_database_versions_client_samples.cc set-client-universe-domain + +*/ + +/*! @page sql_v1::SqlBackupRunsServiceClient-universe-domain-snippet Override sql_v1::SqlBackupRunsServiceClient Universe Domain + +@snippet google/cloud/sql/v1/samples/sql_backup_runs_client_samples.cc set-client-universe-domain + +*/ + +/*! @page sql_v1::SqlConnectServiceClient-universe-domain-snippet Override sql_v1::SqlConnectServiceClient Universe Domain + +@snippet google/cloud/sql/v1/samples/sql_connect_client_samples.cc set-client-universe-domain + +*/ + +/*! @page sql_v1::SqlDatabasesServiceClient-universe-domain-snippet Override sql_v1::SqlDatabasesServiceClient Universe Domain + +@snippet google/cloud/sql/v1/samples/sql_databases_client_samples.cc set-client-universe-domain + +*/ + +/*! @page sql_v1::SqlEventsServiceClient-universe-domain-snippet Override sql_v1::SqlEventsServiceClient Universe Domain + +@snippet google/cloud/sql/v1/samples/sql_events_client_samples.cc set-client-universe-domain + +*/ + +/*! @page sql_v1::SqlFlagsServiceClient-universe-domain-snippet Override sql_v1::SqlFlagsServiceClient Universe Domain + +@snippet google/cloud/sql/v1/samples/sql_flags_client_samples.cc set-client-universe-domain + +*/ + +/*! @page sql_v1::SqlIamPoliciesServiceClient-universe-domain-snippet Override sql_v1::SqlIamPoliciesServiceClient Universe Domain + +@snippet google/cloud/sql/v1/samples/sql_iam_policies_client_samples.cc set-client-universe-domain + +*/ + +/*! @page sql_v1::SqlInstanceNamesServiceClient-universe-domain-snippet Override sql_v1::SqlInstanceNamesServiceClient Universe Domain + +@snippet google/cloud/sql/v1/samples/sql_instance_names_client_samples.cc set-client-universe-domain + +*/ + +/*! @page sql_v1::SqlInstancesServiceClient-universe-domain-snippet Override sql_v1::SqlInstancesServiceClient Universe Domain + +@snippet google/cloud/sql/v1/samples/sql_instances_client_samples.cc set-client-universe-domain + +*/ + +/*! @page sql_v1::SqlOperationsServiceClient-universe-domain-snippet Override sql_v1::SqlOperationsServiceClient Universe Domain + +@snippet google/cloud/sql/v1/samples/sql_operations_client_samples.cc set-client-universe-domain + +*/ + +/*! @page sql_v1::SqlRegionsServiceClient-universe-domain-snippet Override sql_v1::SqlRegionsServiceClient Universe Domain + +@snippet google/cloud/sql/v1/samples/sql_regions_client_samples.cc set-client-universe-domain + +*/ + +/*! @page sql_v1::SqlSslCertsServiceClient-universe-domain-snippet Override sql_v1::SqlSslCertsServiceClient Universe Domain + +@snippet google/cloud/sql/v1/samples/sql_ssl_certs_client_samples.cc set-client-universe-domain + +*/ + +/*! @page sql_v1::SqlTiersServiceClient-universe-domain-snippet Override sql_v1::SqlTiersServiceClient Universe Domain + +@snippet google/cloud/sql/v1/samples/sql_tiers_client_samples.cc set-client-universe-domain + +*/ + +/*! @page sql_v1::SqlUsersServiceClient-universe-domain-snippet Override sql_v1::SqlUsersServiceClient Universe Domain + +@snippet google/cloud/sql/v1/samples/sql_users_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/sql/v1/samples/sql_available_database_versions_client_samples.cc b/google/cloud/sql/v1/samples/sql_available_database_versions_client_samples.cc index 6298905d03753..480a6be9c4aa6 100644 --- a/google/cloud/sql/v1/samples/sql_available_database_versions_client_samples.cc +++ b/google/cloud/sql/v1/samples/sql_available_database_versions_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,28 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::sql_v1::SqlAvailableDatabaseVersionsServiceClient( + google::cloud::sql_v1:: + MakeSqlAvailableDatabaseVersionsServiceConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::sql_v1:: @@ -154,6 +177,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -163,6 +189,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/sql/v1/samples/sql_backup_runs_client_samples.cc b/google/cloud/sql/v1/samples/sql_backup_runs_client_samples.cc index 11946dad3a12a..e0a27be6a577d 100644 --- a/google/cloud/sql/v1/samples/sql_backup_runs_client_samples.cc +++ b/google/cloud/sql/v1/samples/sql_backup_runs_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::sql_v1::SqlBackupRunsServiceClient( + google::cloud::sql_v1::MakeSqlBackupRunsServiceConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::sql_v1:: @@ -142,6 +163,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -151,6 +175,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/sql/v1/samples/sql_connect_client_samples.cc b/google/cloud/sql/v1/samples/sql_connect_client_samples.cc index d7bcde02f8747..8e54d3cd24b12 100644 --- a/google/cloud/sql/v1/samples/sql_connect_client_samples.cc +++ b/google/cloud/sql/v1/samples/sql_connect_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::sql_v1::SqlConnectServiceClient( + google::cloud::sql_v1::MakeSqlConnectServiceConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::sql_v1:: @@ -142,6 +162,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -151,6 +174,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/sql/v1/samples/sql_databases_client_samples.cc b/google/cloud/sql/v1/samples/sql_databases_client_samples.cc index 8549891f5c4e8..e005506de9d26 100644 --- a/google/cloud/sql/v1/samples/sql_databases_client_samples.cc +++ b/google/cloud/sql/v1/samples/sql_databases_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::sql_v1::SqlDatabasesServiceClient( + google::cloud::sql_v1::MakeSqlDatabasesServiceConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::sql_v1:: @@ -142,6 +163,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -151,6 +175,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/sql/v1/samples/sql_events_client_samples.cc b/google/cloud/sql/v1/samples/sql_events_client_samples.cc index 459dc9b55b548..ae1e228c446a7 100644 --- a/google/cloud/sql/v1/samples/sql_events_client_samples.cc +++ b/google/cloud/sql/v1/samples/sql_events_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::sql_v1::SqlEventsServiceClient( + google::cloud::sql_v1::MakeSqlEventsServiceConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::sql_v1:: @@ -142,6 +162,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -151,6 +174,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/sql/v1/samples/sql_flags_client_samples.cc b/google/cloud/sql/v1/samples/sql_flags_client_samples.cc index 2a635353571d5..6365b713c8fd7 100644 --- a/google/cloud/sql/v1/samples/sql_flags_client_samples.cc +++ b/google/cloud/sql/v1/samples/sql_flags_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::sql_v1::SqlFlagsServiceClient( + google::cloud::sql_v1::MakeSqlFlagsServiceConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::sql_v1::SqlFlagsServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/sql/v1/samples/sql_iam_policies_client_samples.cc b/google/cloud/sql/v1/samples/sql_iam_policies_client_samples.cc index cf1da9d60d3f5..a5cd86ea1f980 100644 --- a/google/cloud/sql/v1/samples/sql_iam_policies_client_samples.cc +++ b/google/cloud/sql/v1/samples/sql_iam_policies_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::sql_v1::SqlIamPoliciesServiceClient( + google::cloud::sql_v1::MakeSqlIamPoliciesServiceConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::sql_v1:: @@ -144,6 +165,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -153,6 +177,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/sql/v1/samples/sql_instance_names_client_samples.cc b/google/cloud/sql/v1/samples/sql_instance_names_client_samples.cc index 6462c5d191cfc..5a2421697965f 100644 --- a/google/cloud/sql/v1/samples/sql_instance_names_client_samples.cc +++ b/google/cloud/sql/v1/samples/sql_instance_names_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::sql_v1::SqlInstanceNamesServiceClient( + google::cloud::sql_v1::MakeSqlInstanceNamesServiceConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::sql_v1:: @@ -146,6 +167,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -155,6 +179,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/sql/v1/samples/sql_instances_client_samples.cc b/google/cloud/sql/v1/samples/sql_instances_client_samples.cc index 281eb7651ec97..9fd5f93fc5727 100644 --- a/google/cloud/sql/v1/samples/sql_instances_client_samples.cc +++ b/google/cloud/sql/v1/samples/sql_instances_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::sql_v1::SqlInstancesServiceClient( + google::cloud::sql_v1::MakeSqlInstancesServiceConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::sql_v1:: @@ -142,6 +163,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -151,6 +175,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/sql/v1/samples/sql_operations_client_samples.cc b/google/cloud/sql/v1/samples/sql_operations_client_samples.cc index 5518b44c16057..97cf6321174a1 100644 --- a/google/cloud/sql/v1/samples/sql_operations_client_samples.cc +++ b/google/cloud/sql/v1/samples/sql_operations_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::sql_v1::SqlOperationsServiceClient( + google::cloud::sql_v1::MakeSqlOperationsServiceConnectionRest( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::sql_v1:: @@ -142,6 +163,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -151,6 +175,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/sql/v1/samples/sql_regions_client_samples.cc b/google/cloud/sql/v1/samples/sql_regions_client_samples.cc index e2c84273f2ae5..dbdbd2b3d64eb 100644 --- a/google/cloud/sql/v1/samples/sql_regions_client_samples.cc +++ b/google/cloud/sql/v1/samples/sql_regions_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::sql_v1::SqlRegionsServiceClient( + google::cloud::sql_v1::MakeSqlRegionsServiceConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::sql_v1:: @@ -142,6 +162,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -151,6 +174,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/sql/v1/samples/sql_ssl_certs_client_samples.cc b/google/cloud/sql/v1/samples/sql_ssl_certs_client_samples.cc index 8da5f041d07ab..bc8a60f9a1517 100644 --- a/google/cloud/sql/v1/samples/sql_ssl_certs_client_samples.cc +++ b/google/cloud/sql/v1/samples/sql_ssl_certs_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::sql_v1::SqlSslCertsServiceClient( + google::cloud::sql_v1::MakeSqlSslCertsServiceConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::sql_v1:: @@ -142,6 +162,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -151,6 +174,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/sql/v1/samples/sql_tiers_client_samples.cc b/google/cloud/sql/v1/samples/sql_tiers_client_samples.cc index 1980d8fdf773c..fd2b486599403 100644 --- a/google/cloud/sql/v1/samples/sql_tiers_client_samples.cc +++ b/google/cloud/sql/v1/samples/sql_tiers_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::sql_v1::SqlTiersServiceClient( + google::cloud::sql_v1::MakeSqlTiersServiceConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::sql_v1::SqlTiersServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/sql/v1/samples/sql_users_client_samples.cc b/google/cloud/sql/v1/samples/sql_users_client_samples.cc index af96bf1cb84e5..7b3857182b4bc 100644 --- a/google/cloud/sql/v1/samples/sql_users_client_samples.cc +++ b/google/cloud/sql/v1/samples/sql_users_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::sql_v1::SqlUsersServiceClient( + google::cloud::sql_v1::MakeSqlUsersServiceConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::sql_v1::SqlUsersServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/storage/tests/BUILD.bazel b/google/cloud/storage/tests/BUILD.bazel index 3286de29469f9..177246db5be7a 100644 --- a/google/cloud/storage/tests/BUILD.bazel +++ b/google/cloud/storage/tests/BUILD.bazel @@ -71,8 +71,8 @@ VARIATIONS = { ], deps = [ "//:common", - "//:experimental-universe_domain", "//:storage", + "//:universe_domain", "//google/cloud/storage:storage_client_testing", "//google/cloud/testing_util:google_cloud_cpp_testing_grpc_private", "//google/cloud/testing_util:google_cloud_cpp_testing_private", diff --git a/google/cloud/storagebatchoperations/doc/override-universe-domain.dox b/google/cloud/storagebatchoperations/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..d04d0fa738f13 --- /dev/null +++ b/google/cloud/storagebatchoperations/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page storagebatchoperations-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `storagebatchoperations_v1::StorageBatchOperationsClient`: + +@snippet storage_batch_operations_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page storagebatchoperations_v1::StorageBatchOperationsClient-universe-domain-snippet Override storagebatchoperations_v1::StorageBatchOperationsClient Universe Domain + +@snippet google/cloud/storagebatchoperations/v1/samples/storage_batch_operations_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/storagebatchoperations/v1/samples/storage_batch_operations_client_samples.cc b/google/cloud/storagebatchoperations/v1/samples/storage_batch_operations_client_samples.cc index c1faf81a93995..bbda8c9ae103b 100644 --- a/google/cloud/storagebatchoperations/v1/samples/storage_batch_operations_client_samples.cc +++ b/google/cloud/storagebatchoperations/v1/samples/storage_batch_operations_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::storagebatchoperations_v1::StorageBatchOperationsClient( + google::cloud::storagebatchoperations_v1:: + MakeStorageBatchOperationsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::storagebatchoperations_v1:: @@ -204,6 +226,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -214,6 +239,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/storagecontrol/doc/override-universe-domain.dox b/google/cloud/storagecontrol/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..e40a4ccb3e1ec --- /dev/null +++ b/google/cloud/storagecontrol/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page storagecontrol-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `storagecontrol_v2::StorageControlClient`: + +@snippet storage_control_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page storagecontrol_v2::StorageControlClient-universe-domain-snippet Override storagecontrol_v2::StorageControlClient Universe Domain + +@snippet google/cloud/storagecontrol/v2/samples/storage_control_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/storagecontrol/v2/samples/storage_control_client_samples.cc b/google/cloud/storagecontrol/v2/samples/storage_control_client_samples.cc index 00d3ea74b8a1b..da2e6fc9f558d 100644 --- a/google/cloud/storagecontrol/v2/samples/storage_control_client_samples.cc +++ b/google/cloud/storagecontrol/v2/samples/storage_control_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::storagecontrol_v2::StorageControlClient( + google::cloud::storagecontrol_v2::MakeStorageControlConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::storagecontrol_v2:: StorageControlConnectionIdempotencyPolicy { @@ -190,6 +211,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -200,6 +224,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/storageinsights/doc/override-universe-domain.dox b/google/cloud/storageinsights/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..2644a2c926c25 --- /dev/null +++ b/google/cloud/storageinsights/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page storageinsights-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `storageinsights_v1::StorageInsightsClient`: + +@snippet storage_insights_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page storageinsights_v1::StorageInsightsClient-universe-domain-snippet Override storageinsights_v1::StorageInsightsClient Universe Domain + +@snippet google/cloud/storageinsights/v1/samples/storage_insights_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/storageinsights/v1/samples/storage_insights_client_samples.cc b/google/cloud/storageinsights/v1/samples/storage_insights_client_samples.cc index 40cd3d3a59546..7017701b02d84 100644 --- a/google/cloud/storageinsights/v1/samples/storage_insights_client_samples.cc +++ b/google/cloud/storageinsights/v1/samples/storage_insights_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::storageinsights_v1::StorageInsightsClient( + google::cloud::storageinsights_v1::MakeStorageInsightsConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::storageinsights_v1:: StorageInsightsConnectionIdempotencyPolicy { @@ -195,6 +216,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -205,6 +229,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/storagetransfer/doc/override-universe-domain.dox b/google/cloud/storagetransfer/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..1c60992b5a187 --- /dev/null +++ b/google/cloud/storagetransfer/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page storagetransfer-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `storagetransfer_v1::StorageTransferServiceClient`: + +@snippet storage_transfer_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page storagetransfer_v1::StorageTransferServiceClient-universe-domain-snippet Override storagetransfer_v1::StorageTransferServiceClient Universe Domain + +@snippet google/cloud/storagetransfer/v1/samples/storage_transfer_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/storagetransfer/v1/samples/storage_transfer_client_samples.cc b/google/cloud/storagetransfer/v1/samples/storage_transfer_client_samples.cc index a7da03bc02b87..3698334712ed4 100644 --- a/google/cloud/storagetransfer/v1/samples/storage_transfer_client_samples.cc +++ b/google/cloud/storagetransfer/v1/samples/storage_transfer_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::storagetransfer_v1::StorageTransferServiceClient( + google::cloud::storagetransfer_v1:: + MakeStorageTransferServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::storagetransfer_v1:: @@ -200,6 +222,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -210,6 +235,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/support/doc/override-universe-domain.dox b/google/cloud/support/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..43af8d72b4150 --- /dev/null +++ b/google/cloud/support/doc/override-universe-domain.dox @@ -0,0 +1,43 @@ +/*! +@page support-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `support_v2::CaseAttachmentServiceClient`: + +@snippet case_attachment_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c support_v2::CaseAttachmentServiceClient](@ref support_v2::CaseAttachmentServiceClient-universe-domain-snippet) +- [\c support_v2::CaseServiceClient](@ref support_v2::CaseServiceClient-universe-domain-snippet) +- [\c support_v2::CommentServiceClient](@ref support_v2::CommentServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page support_v2::CaseAttachmentServiceClient-universe-domain-snippet Override support_v2::CaseAttachmentServiceClient Universe Domain + +@snippet google/cloud/support/v2/samples/case_attachment_client_samples.cc set-client-universe-domain + +*/ + +/*! @page support_v2::CaseServiceClient-universe-domain-snippet Override support_v2::CaseServiceClient Universe Domain + +@snippet google/cloud/support/v2/samples/case_client_samples.cc set-client-universe-domain + +*/ + +/*! @page support_v2::CommentServiceClient-universe-domain-snippet Override support_v2::CommentServiceClient Universe Domain + +@snippet google/cloud/support/v2/samples/comment_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/support/v2/samples/case_attachment_client_samples.cc b/google/cloud/support/v2/samples/case_attachment_client_samples.cc index 24f9e0f7a2176..204fe30cd9ef9 100644 --- a/google/cloud/support/v2/samples/case_attachment_client_samples.cc +++ b/google/cloud/support/v2/samples/case_attachment_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::support_v2::CaseAttachmentServiceClient( + google::cloud::support_v2::MakeCaseAttachmentServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::support_v2:: @@ -146,6 +167,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -155,6 +179,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/support/v2/samples/case_client_samples.cc b/google/cloud/support/v2/samples/case_client_samples.cc index 4e5aeba6561d6..e5001c4204271 100644 --- a/google/cloud/support/v2/samples/case_client_samples.cc +++ b/google/cloud/support/v2/samples/case_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::support_v2::CaseServiceClient( + google::cloud::support_v2::MakeCaseServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::support_v2::CaseServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/support/v2/samples/comment_client_samples.cc b/google/cloud/support/v2/samples/comment_client_samples.cc index 30560dbe70599..149a076bbc986 100644 --- a/google/cloud/support/v2/samples/comment_client_samples.cc +++ b/google/cloud/support/v2/samples/comment_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::support_v2::CommentServiceClient( + google::cloud::support_v2::MakeCommentServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::support_v2:: CommentServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/talent/doc/override-universe-domain.dox b/google/cloud/talent/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..10726780fd1d7 --- /dev/null +++ b/google/cloud/talent/doc/override-universe-domain.dox @@ -0,0 +1,57 @@ +/*! +@page talent-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `talent_v4::CompanyServiceClient`: + +@snippet company_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c talent_v4::CompanyServiceClient](@ref talent_v4::CompanyServiceClient-universe-domain-snippet) +- [\c talent_v4::CompletionClient](@ref talent_v4::CompletionClient-universe-domain-snippet) +- [\c talent_v4::EventServiceClient](@ref talent_v4::EventServiceClient-universe-domain-snippet) +- [\c talent_v4::JobServiceClient](@ref talent_v4::JobServiceClient-universe-domain-snippet) +- [\c talent_v4::TenantServiceClient](@ref talent_v4::TenantServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page talent_v4::CompanyServiceClient-universe-domain-snippet Override talent_v4::CompanyServiceClient Universe Domain + +@snippet google/cloud/talent/v4/samples/company_client_samples.cc set-client-universe-domain + +*/ + +/*! @page talent_v4::CompletionClient-universe-domain-snippet Override talent_v4::CompletionClient Universe Domain + +@snippet google/cloud/talent/v4/samples/completion_client_samples.cc set-client-universe-domain + +*/ + +/*! @page talent_v4::EventServiceClient-universe-domain-snippet Override talent_v4::EventServiceClient Universe Domain + +@snippet google/cloud/talent/v4/samples/event_client_samples.cc set-client-universe-domain + +*/ + +/*! @page talent_v4::JobServiceClient-universe-domain-snippet Override talent_v4::JobServiceClient Universe Domain + +@snippet google/cloud/talent/v4/samples/job_client_samples.cc set-client-universe-domain + +*/ + +/*! @page talent_v4::TenantServiceClient-universe-domain-snippet Override talent_v4::TenantServiceClient Universe Domain + +@snippet google/cloud/talent/v4/samples/tenant_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/talent/v4/samples/company_client_samples.cc b/google/cloud/talent/v4/samples/company_client_samples.cc index e4ff430a9023a..d00969365ff48 100644 --- a/google/cloud/talent/v4/samples/company_client_samples.cc +++ b/google/cloud/talent/v4/samples/company_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::talent_v4::CompanyServiceClient( + google::cloud::talent_v4::MakeCompanyServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::talent_v4:: CompanyServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/talent/v4/samples/completion_client_samples.cc b/google/cloud/talent/v4/samples/completion_client_samples.cc index 4d1d16e0e9e46..083f13986b7cd 100644 --- a/google/cloud/talent/v4/samples/completion_client_samples.cc +++ b/google/cloud/talent/v4/samples/completion_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::talent_v4::CompletionClient( + google::cloud::talent_v4::MakeCompletionConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::talent_v4::CompletionConnectionIdempotencyPolicy { @@ -140,6 +160,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -149,6 +172,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/talent/v4/samples/event_client_samples.cc b/google/cloud/talent/v4/samples/event_client_samples.cc index 695e1e03f2ce0..dcdfe0e697bf6 100644 --- a/google/cloud/talent/v4/samples/event_client_samples.cc +++ b/google/cloud/talent/v4/samples/event_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::talent_v4::EventServiceClient( + google::cloud::talent_v4::MakeEventServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::talent_v4::EventServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/talent/v4/samples/job_client_samples.cc b/google/cloud/talent/v4/samples/job_client_samples.cc index ab3683d1f4cce..a54d4728ee891 100644 --- a/google/cloud/talent/v4/samples/job_client_samples.cc +++ b/google/cloud/talent/v4/samples/job_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::talent_v4::JobServiceClient( + google::cloud::talent_v4::MakeJobServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::talent_v4::JobServiceConnectionIdempotencyPolicy { @@ -182,6 +202,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -192,6 +215,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/talent/v4/samples/tenant_client_samples.cc b/google/cloud/talent/v4/samples/tenant_client_samples.cc index 599131cf37ada..8802b228a33f4 100644 --- a/google/cloud/talent/v4/samples/tenant_client_samples.cc +++ b/google/cloud/talent/v4/samples/tenant_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::talent_v4::TenantServiceClient( + google::cloud::talent_v4::MakeTenantServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::talent_v4:: TenantServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/tasks/doc/override-universe-domain.dox b/google/cloud/tasks/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..5a7029ade35d4 --- /dev/null +++ b/google/cloud/tasks/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page tasks-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `tasks_v2::CloudTasksClient`: + +@snippet cloud_tasks_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page tasks_v2::CloudTasksClient-universe-domain-snippet Override tasks_v2::CloudTasksClient Universe Domain + +@snippet google/cloud/tasks/v2/samples/cloud_tasks_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/tasks/v2/samples/cloud_tasks_client_samples.cc b/google/cloud/tasks/v2/samples/cloud_tasks_client_samples.cc index af9fb997fb1b5..dd85e9e88cf78 100644 --- a/google/cloud/tasks/v2/samples/cloud_tasks_client_samples.cc +++ b/google/cloud/tasks/v2/samples/cloud_tasks_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::tasks_v2::CloudTasksClient( + google::cloud::tasks_v2::MakeCloudTasksConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::tasks_v2::CloudTasksConnectionIdempotencyPolicy { @@ -139,6 +159,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -148,6 +171,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/telcoautomation/doc/override-universe-domain.dox b/google/cloud/telcoautomation/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..62e13e3e46606 --- /dev/null +++ b/google/cloud/telcoautomation/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page telcoautomation-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `telcoautomation_v1::TelcoAutomationClient`: + +@snippet telco_automation_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page telcoautomation_v1::TelcoAutomationClient-universe-domain-snippet Override telcoautomation_v1::TelcoAutomationClient Universe Domain + +@snippet google/cloud/telcoautomation/v1/samples/telco_automation_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/telcoautomation/v1/samples/telco_automation_client_samples.cc b/google/cloud/telcoautomation/v1/samples/telco_automation_client_samples.cc index 08f1129c54d8b..efe457396a8e5 100644 --- a/google/cloud/telcoautomation/v1/samples/telco_automation_client_samples.cc +++ b/google/cloud/telcoautomation/v1/samples/telco_automation_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::telcoautomation_v1::TelcoAutomationClient( + google::cloud::telcoautomation_v1::MakeTelcoAutomationConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::telcoautomation_v1:: TelcoAutomationConnectionIdempotencyPolicy { @@ -195,6 +216,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -205,6 +229,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/texttospeech/doc/override-universe-domain.dox b/google/cloud/texttospeech/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..3b3ec9dd83da4 --- /dev/null +++ b/google/cloud/texttospeech/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page texttospeech-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `texttospeech_v1::TextToSpeechClient`: + +@snippet text_to_speech_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page texttospeech_v1::TextToSpeechClient-universe-domain-snippet Override texttospeech_v1::TextToSpeechClient Universe Domain + +@snippet google/cloud/texttospeech/v1/samples/text_to_speech_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/texttospeech/v1/samples/text_to_speech_client_samples.cc b/google/cloud/texttospeech/v1/samples/text_to_speech_client_samples.cc index 4f22374bff6b5..0481e7f2a90f7 100644 --- a/google/cloud/texttospeech/v1/samples/text_to_speech_client_samples.cc +++ b/google/cloud/texttospeech/v1/samples/text_to_speech_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::texttospeech_v1::TextToSpeechClient( + google::cloud::texttospeech_v1::MakeTextToSpeechConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::texttospeech_v1:: TextToSpeechConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/timeseriesinsights/doc/override-universe-domain.dox b/google/cloud/timeseriesinsights/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..83409f10b7c6c --- /dev/null +++ b/google/cloud/timeseriesinsights/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page timeseriesinsights-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `timeseriesinsights_v1::TimeseriesInsightsControllerClient`: + +@snippet timeseries_insights_controller_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page timeseriesinsights_v1::TimeseriesInsightsControllerClient-universe-domain-snippet Override timeseriesinsights_v1::TimeseriesInsightsControllerClient Universe Domain + +@snippet google/cloud/timeseriesinsights/v1/samples/timeseries_insights_controller_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/timeseriesinsights/v1/samples/timeseries_insights_controller_client_samples.cc b/google/cloud/timeseriesinsights/v1/samples/timeseries_insights_controller_client_samples.cc index 9cd2c16490906..8ac5aef053fe2 100644 --- a/google/cloud/timeseriesinsights/v1/samples/timeseries_insights_controller_client_samples.cc +++ b/google/cloud/timeseriesinsights/v1/samples/timeseries_insights_controller_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::timeseriesinsights_v1::TimeseriesInsightsControllerClient( + google::cloud::timeseriesinsights_v1:: + MakeTimeseriesInsightsControllerConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::timeseriesinsights_v1:: @@ -156,6 +178,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -165,6 +190,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/tpu/doc/override-universe-domain.dox b/google/cloud/tpu/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..cc692acab1f5f --- /dev/null +++ b/google/cloud/tpu/doc/override-universe-domain.dox @@ -0,0 +1,36 @@ +/*! +@page tpu-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `tpu_v1::TpuClient`: + +@snippet tpu_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c tpu_v1::TpuClient](@ref tpu_v1::TpuClient-universe-domain-snippet) +- [\c tpu_v2::TpuClient](@ref tpu_v2::TpuClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page tpu_v1::TpuClient-universe-domain-snippet Override tpu_v1::TpuClient Universe Domain + +@snippet google/cloud/tpu/v1/samples/tpu_client_samples.cc set-client-universe-domain + +*/ + +/*! @page tpu_v2::TpuClient-universe-domain-snippet Override tpu_v2::TpuClient Universe Domain + +@snippet google/cloud/tpu/v2/samples/tpu_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/tpu/v1/samples/tpu_client_samples.cc b/google/cloud/tpu/v1/samples/tpu_client_samples.cc index 2d956026d42a9..ebf06e91358b0 100644 --- a/google/cloud/tpu/v1/samples/tpu_client_samples.cc +++ b/google/cloud/tpu/v1/samples/tpu_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::tpu_v1::TpuClient( + google::cloud::tpu_v1::MakeTpuConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::tpu_v1::TpuConnectionIdempotencyPolicy { @@ -176,6 +196,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -186,6 +209,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/tpu/v2/samples/tpu_client_samples.cc b/google/cloud/tpu/v2/samples/tpu_client_samples.cc index 889cd39a565e5..3a91edb635129 100644 --- a/google/cloud/tpu/v2/samples/tpu_client_samples.cc +++ b/google/cloud/tpu/v2/samples/tpu_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::tpu_v2::TpuClient( + google::cloud::tpu_v2::MakeTpuConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::tpu_v2::TpuConnectionIdempotencyPolicy { @@ -176,6 +196,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -186,6 +209,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/trace/doc/override-universe-domain.dox b/google/cloud/trace/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..a37db18a7c42b --- /dev/null +++ b/google/cloud/trace/doc/override-universe-domain.dox @@ -0,0 +1,36 @@ +/*! +@page trace-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `trace_v1::TraceServiceClient`: + +@snippet trace_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c trace_v1::TraceServiceClient](@ref trace_v1::TraceServiceClient-universe-domain-snippet) +- [\c trace_v2::TraceServiceClient](@ref trace_v2::TraceServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page trace_v1::TraceServiceClient-universe-domain-snippet Override trace_v1::TraceServiceClient Universe Domain + +@snippet google/cloud/trace/v1/samples/trace_client_samples.cc set-client-universe-domain + +*/ + +/*! @page trace_v2::TraceServiceClient-universe-domain-snippet Override trace_v2::TraceServiceClient Universe Domain + +@snippet google/cloud/trace/v2/samples/trace_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/trace/v1/samples/trace_client_samples.cc b/google/cloud/trace/v1/samples/trace_client_samples.cc index 44cab64ab4782..a157da0de1241 100644 --- a/google/cloud/trace/v1/samples/trace_client_samples.cc +++ b/google/cloud/trace/v1/samples/trace_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::trace_v1::TraceServiceClient( + google::cloud::trace_v1::MakeTraceServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::trace_v1::TraceServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/trace/v2/samples/trace_client_samples.cc b/google/cloud/trace/v2/samples/trace_client_samples.cc index 4b00f8e1f701b..2c54a307bccd1 100644 --- a/google/cloud/trace/v2/samples/trace_client_samples.cc +++ b/google/cloud/trace/v2/samples/trace_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -47,6 +48,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::trace_v2::TraceServiceClient( + google::cloud::trace_v2::MakeTraceServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::trace_v2::TraceServiceConnectionIdempotencyPolicy { @@ -141,6 +161,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -150,6 +173,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/translate/doc/override-universe-domain.dox b/google/cloud/translate/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..ae912756fcefc --- /dev/null +++ b/google/cloud/translate/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page translate-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `translate_v3::TranslationServiceClient`: + +@snippet translation_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page translate_v3::TranslationServiceClient-universe-domain-snippet Override translate_v3::TranslationServiceClient Universe Domain + +@snippet google/cloud/translate/v3/samples/translation_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/translate/v3/samples/translation_client_samples.cc b/google/cloud/translate/v3/samples/translation_client_samples.cc index a1e2371010964..44a173057e3e8 100644 --- a/google/cloud/translate/v3/samples/translation_client_samples.cc +++ b/google/cloud/translate/v3/samples/translation_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::translate_v3::TranslationServiceClient( + google::cloud::translate_v3::MakeTranslationServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::translate_v3:: @@ -192,6 +213,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -202,6 +226,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/universe_domain/demo/BUILD.bazel b/google/cloud/universe_domain/demo/BUILD.bazel index 4fd4d4f516a4f..ce4f35e99f313 100644 --- a/google/cloud/universe_domain/demo/BUILD.bazel +++ b/google/cloud/universe_domain/demo/BUILD.bazel @@ -31,6 +31,6 @@ service_demos = [ ], deps = [ "@google_cloud_cpp//:" + demo, - "@google_cloud_cpp//:experimental-universe_domain", + "@google_cloud_cpp//:universe_domain", ], ) for demo in service_demos] diff --git a/google/cloud/universe_domain/integration_tests/BUILD.bazel b/google/cloud/universe_domain/integration_tests/BUILD.bazel index a446a536b38d2..d566417998d08 100644 --- a/google/cloud/universe_domain/integration_tests/BUILD.bazel +++ b/google/cloud/universe_domain/integration_tests/BUILD.bazel @@ -28,7 +28,7 @@ cc_test( ], deps = [ "//:common", - "//:experimental-universe_domain", + "//:universe_domain", "//google/cloud/testing_util:google_cloud_cpp_testing_private", "@com_google_googletest//:gtest_main", "@google_cloud_cpp//:compute", diff --git a/google/cloud/video/doc/override-universe-domain.dox b/google/cloud/video/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..ca691f59075d2 --- /dev/null +++ b/google/cloud/video/doc/override-universe-domain.dox @@ -0,0 +1,43 @@ +/*! +@page video-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `video_livestream_v1::LivestreamServiceClient`: + +@snippet livestream_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c video_livestream_v1::LivestreamServiceClient](@ref video_livestream_v1::LivestreamServiceClient-universe-domain-snippet) +- [\c video_stitcher_v1::VideoStitcherServiceClient](@ref video_stitcher_v1::VideoStitcherServiceClient-universe-domain-snippet) +- [\c video_transcoder_v1::TranscoderServiceClient](@ref video_transcoder_v1::TranscoderServiceClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page video_livestream_v1::LivestreamServiceClient-universe-domain-snippet Override video_livestream_v1::LivestreamServiceClient Universe Domain + +@snippet google/cloud/video/livestream/v1/samples/livestream_client_samples.cc set-client-universe-domain + +*/ + +/*! @page video_stitcher_v1::VideoStitcherServiceClient-universe-domain-snippet Override video_stitcher_v1::VideoStitcherServiceClient Universe Domain + +@snippet google/cloud/video/stitcher/v1/samples/video_stitcher_client_samples.cc set-client-universe-domain + +*/ + +/*! @page video_transcoder_v1::TranscoderServiceClient-universe-domain-snippet Override video_transcoder_v1::TranscoderServiceClient Universe Domain + +@snippet google/cloud/video/transcoder/v1/samples/transcoder_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/video/livestream/v1/samples/livestream_client_samples.cc b/google/cloud/video/livestream/v1/samples/livestream_client_samples.cc index 86fc50a323a0a..324a059441b05 100644 --- a/google/cloud/video/livestream/v1/samples/livestream_client_samples.cc +++ b/google/cloud/video/livestream/v1/samples/livestream_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -50,6 +51,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::video_livestream_v1::LivestreamServiceClient( + google::cloud::video_livestream_v1::MakeLivestreamServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::video_livestream_v1:: @@ -199,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -209,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/video/stitcher/v1/samples/video_stitcher_client_samples.cc b/google/cloud/video/stitcher/v1/samples/video_stitcher_client_samples.cc index dd4fd4ef89cb6..ec3a76cc77204 100644 --- a/google/cloud/video/stitcher/v1/samples/video_stitcher_client_samples.cc +++ b/google/cloud/video/stitcher/v1/samples/video_stitcher_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::video_stitcher_v1::VideoStitcherServiceClient( + google::cloud::video_stitcher_v1::MakeVideoStitcherServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::video_stitcher_v1:: @@ -200,6 +221,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -210,6 +234,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/video/transcoder/v1/samples/transcoder_client_samples.cc b/google/cloud/video/transcoder/v1/samples/transcoder_client_samples.cc index 59e76dfcdaffe..62e76e6f85349 100644 --- a/google/cloud/video/transcoder/v1/samples/transcoder_client_samples.cc +++ b/google/cloud/video/transcoder/v1/samples/transcoder_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::video_transcoder_v1::TranscoderServiceClient( + google::cloud::video_transcoder_v1::MakeTranscoderServiceConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::video_transcoder_v1:: @@ -150,6 +171,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -159,6 +183,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/videointelligence/doc/override-universe-domain.dox b/google/cloud/videointelligence/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..8ae6ce3984bdb --- /dev/null +++ b/google/cloud/videointelligence/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page videointelligence-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `videointelligence_v1::VideoIntelligenceServiceClient`: + +@snippet video_intelligence_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page videointelligence_v1::VideoIntelligenceServiceClient-universe-domain-snippet Override videointelligence_v1::VideoIntelligenceServiceClient Universe Domain + +@snippet google/cloud/videointelligence/v1/samples/video_intelligence_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/videointelligence/v1/samples/video_intelligence_client_samples.cc b/google/cloud/videointelligence/v1/samples/video_intelligence_client_samples.cc index 9d56aa2e0852e..35a9a71328298 100644 --- a/google/cloud/videointelligence/v1/samples/video_intelligence_client_samples.cc +++ b/google/cloud/videointelligence/v1/samples/video_intelligence_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -51,6 +52,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::videointelligence_v1::VideoIntelligenceServiceClient( + google::cloud::videointelligence_v1:: + MakeVideoIntelligenceServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::videointelligence_v1:: @@ -198,6 +220,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -208,6 +233,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/vision/doc/override-universe-domain.dox b/google/cloud/vision/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..8e017804fb885 --- /dev/null +++ b/google/cloud/vision/doc/override-universe-domain.dox @@ -0,0 +1,36 @@ +/*! +@page vision-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `vision_v1::ImageAnnotatorClient`: + +@snippet image_annotator_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c vision_v1::ImageAnnotatorClient](@ref vision_v1::ImageAnnotatorClient-universe-domain-snippet) +- [\c vision_v1::ProductSearchClient](@ref vision_v1::ProductSearchClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page vision_v1::ImageAnnotatorClient-universe-domain-snippet Override vision_v1::ImageAnnotatorClient Universe Domain + +@snippet google/cloud/vision/v1/samples/image_annotator_client_samples.cc set-client-universe-domain + +*/ + +/*! @page vision_v1::ProductSearchClient-universe-domain-snippet Override vision_v1::ProductSearchClient Universe Domain + +@snippet google/cloud/vision/v1/samples/product_search_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/vision/v1/samples/image_annotator_client_samples.cc b/google/cloud/vision/v1/samples/image_annotator_client_samples.cc index 9d380f5090cc7..95a166cb4ae50 100644 --- a/google/cloud/vision/v1/samples/image_annotator_client_samples.cc +++ b/google/cloud/vision/v1/samples/image_annotator_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::vision_v1::ImageAnnotatorClient( + google::cloud::vision_v1::MakeImageAnnotatorConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::vision_v1:: ImageAnnotatorConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/vision/v1/samples/product_search_client_samples.cc b/google/cloud/vision/v1/samples/product_search_client_samples.cc index 745825553e294..33c1745bfdfc2 100644 --- a/google/cloud/vision/v1/samples/product_search_client_samples.cc +++ b/google/cloud/vision/v1/samples/product_search_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::vision_v1::ProductSearchClient( + google::cloud::vision_v1::MakeProductSearchConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::vision_v1:: ProductSearchConnectionIdempotencyPolicy { @@ -185,6 +205,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -195,6 +218,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/vmmigration/doc/override-universe-domain.dox b/google/cloud/vmmigration/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..5b27f79f4840b --- /dev/null +++ b/google/cloud/vmmigration/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page vmmigration-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `vmmigration_v1::VmMigrationClient`: + +@snippet vm_migration_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page vmmigration_v1::VmMigrationClient-universe-domain-snippet Override vmmigration_v1::VmMigrationClient Universe Domain + +@snippet google/cloud/vmmigration/v1/samples/vm_migration_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/vmmigration/v1/samples/vm_migration_client_samples.cc b/google/cloud/vmmigration/v1/samples/vm_migration_client_samples.cc index 6f38564412f1e..572e6ce548890 100644 --- a/google/cloud/vmmigration/v1/samples/vm_migration_client_samples.cc +++ b/google/cloud/vmmigration/v1/samples/vm_migration_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::vmmigration_v1::VmMigrationClient( + google::cloud::vmmigration_v1::MakeVmMigrationConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::vmmigration_v1:: VmMigrationConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/vmwareengine/doc/override-universe-domain.dox b/google/cloud/vmwareengine/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..8c8481cba8bc6 --- /dev/null +++ b/google/cloud/vmwareengine/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page vmwareengine-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `vmwareengine_v1::VmwareEngineClient`: + +@snippet vmware_engine_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page vmwareengine_v1::VmwareEngineClient-universe-domain-snippet Override vmwareengine_v1::VmwareEngineClient Universe Domain + +@snippet google/cloud/vmwareengine/v1/samples/vmware_engine_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/vmwareengine/v1/samples/vmware_engine_client_samples.cc b/google/cloud/vmwareengine/v1/samples/vmware_engine_client_samples.cc index 72f3d671ee251..33c0e8fc0eb39 100644 --- a/google/cloud/vmwareengine/v1/samples/vmware_engine_client_samples.cc +++ b/google/cloud/vmwareengine/v1/samples/vmware_engine_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::vmwareengine_v1::VmwareEngineClient( + google::cloud::vmwareengine_v1::MakeVmwareEngineConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::vmwareengine_v1:: VmwareEngineConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/vpcaccess/doc/override-universe-domain.dox b/google/cloud/vpcaccess/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..54552312880d9 --- /dev/null +++ b/google/cloud/vpcaccess/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page vpcaccess-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `vpcaccess_v1::VpcAccessServiceClient`: + +@snippet vpc_access_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page vpcaccess_v1::VpcAccessServiceClient-universe-domain-snippet Override vpcaccess_v1::VpcAccessServiceClient Universe Domain + +@snippet google/cloud/vpcaccess/v1/samples/vpc_access_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/vpcaccess/v1/samples/vpc_access_client_samples.cc b/google/cloud/vpcaccess/v1/samples/vpc_access_client_samples.cc index 2bbfc1220df6a..3ca4c8c62fb7e 100644 --- a/google/cloud/vpcaccess/v1/samples/vpc_access_client_samples.cc +++ b/google/cloud/vpcaccess/v1/samples/vpc_access_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::vpcaccess_v1::VpcAccessServiceClient( + google::cloud::vpcaccess_v1::MakeVpcAccessServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::vpcaccess_v1:: @@ -190,6 +210,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -200,6 +223,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/webrisk/doc/override-universe-domain.dox b/google/cloud/webrisk/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..f6934fe3507b2 --- /dev/null +++ b/google/cloud/webrisk/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page webrisk-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `webrisk_v1::WebRiskServiceClient`: + +@snippet web_risk_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page webrisk_v1::WebRiskServiceClient-universe-domain-snippet Override webrisk_v1::WebRiskServiceClient Universe Domain + +@snippet google/cloud/webrisk/v1/samples/web_risk_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/webrisk/v1/samples/web_risk_client_samples.cc b/google/cloud/webrisk/v1/samples/web_risk_client_samples.cc index cb37745b98204..1fe10b0b551d7 100644 --- a/google/cloud/webrisk/v1/samples/web_risk_client_samples.cc +++ b/google/cloud/webrisk/v1/samples/web_risk_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::webrisk_v1::WebRiskServiceClient( + google::cloud::webrisk_v1::MakeWebRiskServiceConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::webrisk_v1:: WebRiskServiceConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/websecurityscanner/doc/override-universe-domain.dox b/google/cloud/websecurityscanner/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..4f8c7de4335ba --- /dev/null +++ b/google/cloud/websecurityscanner/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page websecurityscanner-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `websecurityscanner_v1::WebSecurityScannerClient`: + +@snippet web_security_scanner_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page websecurityscanner_v1::WebSecurityScannerClient-universe-domain-snippet Override websecurityscanner_v1::WebSecurityScannerClient Universe Domain + +@snippet google/cloud/websecurityscanner/v1/samples/web_security_scanner_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/websecurityscanner/v1/samples/web_security_scanner_client_samples.cc b/google/cloud/websecurityscanner/v1/samples/web_security_scanner_client_samples.cc index 2215f579d12fd..e61613d7e82d4 100644 --- a/google/cloud/websecurityscanner/v1/samples/web_security_scanner_client_samples.cc +++ b/google/cloud/websecurityscanner/v1/samples/web_security_scanner_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,27 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = + google::cloud::websecurityscanner_v1::WebSecurityScannerClient( + google::cloud::websecurityscanner_v1:: + MakeWebSecurityScannerConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::websecurityscanner_v1:: @@ -151,6 +173,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -160,6 +185,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/workflows/doc/override-universe-domain.dox b/google/cloud/workflows/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..2112b0b70b9bd --- /dev/null +++ b/google/cloud/workflows/doc/override-universe-domain.dox @@ -0,0 +1,36 @@ +/*! +@page workflows-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `workflows_executions_v1::ExecutionsClient`: + +@snippet executions_client_samples.cc set-client-universe-domain + +Follow these links to find examples for other \c *Client classes: + +- [\c workflows_executions_v1::ExecutionsClient](@ref workflows_executions_v1::ExecutionsClient-universe-domain-snippet) +- [\c workflows_v1::WorkflowsClient](@ref workflows_v1::WorkflowsClient-universe-domain-snippet) + + + +*/ + +// + +/*! @page workflows_executions_v1::ExecutionsClient-universe-domain-snippet Override workflows_executions_v1::ExecutionsClient Universe Domain + +@snippet google/cloud/workflows/executions/v1/samples/executions_client_samples.cc set-client-universe-domain + +*/ + +/*! @page workflows_v1::WorkflowsClient-universe-domain-snippet Override workflows_v1::WorkflowsClient Universe Domain + +@snippet google/cloud/workflows/v1/samples/workflows_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/workflows/executions/v1/samples/executions_client_samples.cc b/google/cloud/workflows/executions/v1/samples/executions_client_samples.cc index d7c2eb61504a2..95658231ac48c 100644 --- a/google/cloud/workflows/executions/v1/samples/executions_client_samples.cc +++ b/google/cloud/workflows/executions/v1/samples/executions_client_samples.cc @@ -23,6 +23,7 @@ #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -48,6 +49,26 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::workflows_executions_v1::ExecutionsClient( + google::cloud::workflows_executions_v1::MakeExecutionsConnection( + *ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::workflows_executions_v1:: ExecutionsConnectionIdempotencyPolicy { @@ -147,6 +168,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -156,6 +180,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-client-endpoint", SetClientEndpoint}, {"set-retry-policy", SetRetryPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/workflows/v1/samples/workflows_client_samples.cc b/google/cloud/workflows/v1/samples/workflows_client_samples.cc index f0827221a9d25..26abad101ea2a 100644 --- a/google/cloud/workflows/v1/samples/workflows_client_samples.cc +++ b/google/cloud/workflows/v1/samples/workflows_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::workflows_v1::WorkflowsClient( + google::cloud::workflows_v1::MakeWorkflowsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::workflows_v1::WorkflowsConnectionIdempotencyPolicy { @@ -184,6 +204,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -194,6 +217,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv); diff --git a/google/cloud/workstations/doc/override-universe-domain.dox b/google/cloud/workstations/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..878fed86703f4 --- /dev/null +++ b/google/cloud/workstations/doc/override-universe-domain.dox @@ -0,0 +1,25 @@ +/*! +@page workstations-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the client +library. Use the +[AddUniverseDomainOption](@ref google::cloud::AddUniverseDomainOption) when initializing the +client library to change this default. + + +For example, this will override the default universe domain for `workstations_v1::WorkstationsClient`: + +@snippet workstations_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page workstations_v1::WorkstationsClient-universe-domain-snippet Override workstations_v1::WorkstationsClient Universe Domain + +@snippet google/cloud/workstations/v1/samples/workstations_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/workstations/v1/samples/workstations_client_samples.cc b/google/cloud/workstations/v1/samples/workstations_client_samples.cc index b37e23108f189..e67282dea462c 100644 --- a/google/cloud/workstations/v1/samples/workstations_client_samples.cc +++ b/google/cloud/workstations/v1/samples/workstations_client_samples.cc @@ -24,6 +24,7 @@ #include "google/cloud/internal/getenv.h" #include "google/cloud/polling_policy.h" #include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" #include #include #include @@ -49,6 +50,25 @@ void SetClientEndpoint(std::vector const& argv) { //! [set-client-endpoint] } +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::workstations_v1::WorkstationsClient( + google::cloud::workstations_v1::MakeWorkstationsConnection(*ud_options)); + //! [set-client-universe-domain] +} + //! [custom-idempotency-policy] class CustomIdempotencyPolicy : public google::cloud::workstations_v1:: WorkstationsConnectionIdempotencyPolicy { @@ -186,6 +206,9 @@ void AutoRun(std::vector const& argv) { std::cout << "\nRunning WithServiceAccount() example" << std::endl; WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); } } // namespace @@ -196,6 +219,7 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) {"set-retry-policy", SetRetryPolicy}, {"set-polling-policy", SetPollingPolicy}, {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, {"auto", AutoRun}, }); return example.Run(argc, argv);