From 685533e9daef6ceaca06a1512680cc7323ee2c02 Mon Sep 17 00:00:00 2001 From: Yao Cui Date: Tue, 13 Aug 2024 16:13:23 +0000 Subject: [PATCH 1/8] mixin draft --- generator/CMakeLists.txt | 2 + generator/google_cloud_cpp_generator.bzl | 2 + .../internal/auth_decorator_generator.cc | 5 +- generator/internal/auth_decorator_generator.h | 3 +- generator/internal/client_generator.cc | 6 +- generator/internal/client_generator.h | 3 +- generator/internal/connection_generator.cc | 6 +- generator/internal/connection_generator.h | 3 +- .../internal/connection_impl_generator.cc | 11 +- .../internal/connection_impl_generator.h | 3 +- .../connection_impl_rest_generator.cc | 11 +- .../internal/connection_impl_rest_generator.h | 3 +- .../internal/connection_rest_generator.cc | 11 +- .../internal/connection_rest_generator.h | 3 +- generator/internal/descriptor_utils.cc | 58 +++++++- generator/internal/descriptor_utils.h | 7 +- generator/internal/descriptor_utils_test.cc | 21 +++ .../internal/forwarding_client_generator.cc | 6 +- .../internal/forwarding_client_generator.h | 3 +- .../forwarding_connection_generator.cc | 6 +- .../forwarding_connection_generator.h | 3 +- ...forwarding_idempotency_policy_generator.cc | 6 +- .../forwarding_idempotency_policy_generator.h | 3 +- .../forwarding_mock_connection_generator.cc | 6 +- .../forwarding_mock_connection_generator.h | 3 +- .../internal/forwarding_options_generator.cc | 6 +- .../internal/forwarding_options_generator.h | 3 +- .../internal/idempotency_policy_generator.cc | 16 ++- .../internal/idempotency_policy_generator.h | 3 +- .../internal/logging_decorator_generator.cc | 6 +- .../internal/logging_decorator_generator.h | 3 +- .../logging_decorator_rest_generator.cc | 6 +- .../logging_decorator_rest_generator.h | 3 +- generator/internal/make_generators.cc | 82 ++++++----- .../internal/metadata_decorator_generator.cc | 6 +- .../internal/metadata_decorator_generator.h | 3 +- .../metadata_decorator_rest_generator.cc | 6 +- .../metadata_decorator_rest_generator.h | 3 +- generator/internal/mixin_utils.cc | 128 ++++++++++++++++++ generator/internal/mixin_utils.h | 51 +++++++ .../internal/mock_connection_generator.cc | 6 +- .../internal/mock_connection_generator.h | 3 +- .../internal/option_defaults_generator.cc | 11 +- .../internal/option_defaults_generator.h | 3 +- generator/internal/options_generator.cc | 9 +- generator/internal/options_generator.h | 3 +- generator/internal/retry_traits_generator.cc | 6 +- generator/internal/retry_traits_generator.h | 3 +- .../round_robin_decorator_generator.cc | 6 +- .../round_robin_decorator_generator.h | 3 +- generator/internal/sample_generator.cc | 9 +- generator/internal/sample_generator.h | 3 +- generator/internal/service_code_generator.cc | 27 +++- generator/internal/service_code_generator.h | 10 +- .../internal/service_code_generator_test.cc | 7 +- generator/internal/sources_generator.cc | 6 +- generator/internal/sources_generator.h | 3 +- generator/internal/stub_factory_generator.cc | 6 +- generator/internal/stub_factory_generator.h | 3 +- .../internal/stub_factory_rest_generator.cc | 11 +- .../internal/stub_factory_rest_generator.h | 3 +- generator/internal/stub_generator.cc | 5 +- generator/internal/stub_generator.h | 3 +- generator/internal/stub_generator_base.cc | 6 +- generator/internal/stub_generator_base.h | 3 +- generator/internal/stub_rest_generator.cc | 6 +- generator/internal/stub_rest_generator.h | 3 +- .../internal/tracing_connection_generator.cc | 11 +- .../internal/tracing_connection_generator.h | 3 +- generator/internal/tracing_stub_generator.cc | 6 +- generator/internal/tracing_stub_generator.h | 3 +- generator/standalone_main.cc | 16 +++ .../datamigration/v1/data_migration_client.cc | 14 ++ .../datamigration/v1/data_migration_client.h | 70 ++++++++++ .../v1/data_migration_connection.cc | 14 ++ .../v1/data_migration_connection.h | 7 + ...migration_connection_idempotency_policy.cc | 10 ++ ..._migration_connection_idempotency_policy.h | 7 + .../internal/data_migration_auth_decorator.cc | 18 +++ .../internal/data_migration_auth_decorator.h | 8 ++ .../data_migration_connection_impl.cc | 49 +++++++ .../internal/data_migration_connection_impl.h | 6 + .../data_migration_logging_decorator.cc | 24 ++++ .../data_migration_logging_decorator.h | 8 ++ .../data_migration_metadata_decorator.cc | 18 +++ .../data_migration_metadata_decorator.h | 8 ++ .../v1/internal/data_migration_stub.cc | 24 ++++ .../v1/internal/data_migration_stub.h | 18 +++ .../data_migration_tracing_connection.cc | 20 +++ .../data_migration_tracing_connection.h | 6 + .../internal/data_migration_tracing_stub.cc | 24 ++++ .../v1/internal/data_migration_tracing_stub.h | 8 ++ .../v1/mocks/mock_data_migration_connection.h | 8 ++ 93 files changed, 935 insertions(+), 159 deletions(-) create mode 100644 generator/internal/mixin_utils.cc create mode 100644 generator/internal/mixin_utils.h diff --git a/generator/CMakeLists.txt b/generator/CMakeLists.txt index e4abeb7990ce7..f404b005214ab 100644 --- a/generator/CMakeLists.txt +++ b/generator/CMakeLists.txt @@ -96,6 +96,8 @@ add_library( internal/metadata_decorator_generator.h internal/metadata_decorator_rest_generator.cc internal/metadata_decorator_rest_generator.h + internal/mixin_utils.cc + internal/mixin_utils.h internal/mock_connection_generator.cc internal/mock_connection_generator.h internal/option_defaults_generator.cc diff --git a/generator/google_cloud_cpp_generator.bzl b/generator/google_cloud_cpp_generator.bzl index 435745a90bde5..29f7a3c9dbe36 100644 --- a/generator/google_cloud_cpp_generator.bzl +++ b/generator/google_cloud_cpp_generator.bzl @@ -50,6 +50,7 @@ google_cloud_cpp_generator_hdrs = [ "internal/make_generators.h", "internal/metadata_decorator_generator.h", "internal/metadata_decorator_rest_generator.h", + "internal/mixin_utils.h", "internal/mock_connection_generator.h", "internal/option_defaults_generator.h", "internal/options_generator.h", @@ -108,6 +109,7 @@ google_cloud_cpp_generator_srcs = [ "internal/make_generators.cc", "internal/metadata_decorator_generator.cc", "internal/metadata_decorator_rest_generator.cc", + "internal/mixin_utils.cc", "internal/mock_connection_generator.cc", "internal/option_defaults_generator.cc", "internal/options_generator.cc", diff --git a/generator/internal/auth_decorator_generator.cc b/generator/internal/auth_decorator_generator.cc index a3f98ee027bef..9e3d961910f0b 100644 --- a/generator/internal/auth_decorator_generator.cc +++ b/generator/internal/auth_decorator_generator.cc @@ -28,10 +28,11 @@ AuthDecoratorGenerator::AuthDecoratorGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) : StubGeneratorBase("auth_header_path", "auth_cc_path", service_descriptor, std::move(service_vars), std::move(service_method_vars), - context) {} + context, mixin_methods) {} Status AuthDecoratorGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); diff --git a/generator/internal/auth_decorator_generator.h b/generator/internal/auth_decorator_generator.h index 868de964ae7e2..7c960b32a93b6 100644 --- a/generator/internal/auth_decorator_generator.h +++ b/generator/internal/auth_decorator_generator.h @@ -37,7 +37,8 @@ class AuthDecoratorGenerator : public StubGeneratorBase { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~AuthDecoratorGenerator() override = default; diff --git a/generator/internal/client_generator.cc b/generator/internal/client_generator.cc index 803cdd05c60d4..0bc2dc51d5d4b 100644 --- a/generator/internal/client_generator.cc +++ b/generator/internal/client_generator.cc @@ -32,10 +32,12 @@ ClientGenerator::ClientGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) : ServiceCodeGenerator("client_header_path", "client_cc_path", service_descriptor, std::move(service_vars), - std::move(service_method_vars), context) { + std::move(service_method_vars), context, + mixin_methods) { // Remember if there are methods from google.iam.v1.GetIamPolicyRequest and // google.iam.v1.SetIamPolicyRequest to google.iam.v1.Policy with signature // extensions. If so, we'll generate a "set" wrapper method to help prevent diff --git a/generator/internal/client_generator.h b/generator/internal/client_generator.h index 63324e87a643f..a4bd65a60bff0 100644 --- a/generator/internal/client_generator.h +++ b/generator/internal/client_generator.h @@ -36,7 +36,8 @@ class ClientGenerator : public ServiceCodeGenerator { ClientGenerator(google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~ClientGenerator() override = default; diff --git a/generator/internal/connection_generator.cc b/generator/internal/connection_generator.cc index 1b5915e2c6a80..b3c79dac61c8c 100644 --- a/generator/internal/connection_generator.cc +++ b/generator/internal/connection_generator.cc @@ -29,10 +29,12 @@ ConnectionGenerator::ConnectionGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) : ServiceCodeGenerator("connection_header_path", "connection_cc_path", service_descriptor, std::move(service_vars), - std::move(service_method_vars), context) {} + std::move(service_method_vars), context, + mixin_methods) {} Status ConnectionGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); diff --git a/generator/internal/connection_generator.h b/generator/internal/connection_generator.h index 33f660edd4cd7..44d9470f9c574 100644 --- a/generator/internal/connection_generator.h +++ b/generator/internal/connection_generator.h @@ -38,7 +38,8 @@ class ConnectionGenerator : public ServiceCodeGenerator { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~ConnectionGenerator() override = default; diff --git a/generator/internal/connection_impl_generator.cc b/generator/internal/connection_impl_generator.cc index a8c30c7370f7b..f322a6707ce4a 100644 --- a/generator/internal/connection_impl_generator.cc +++ b/generator/internal/connection_impl_generator.cc @@ -38,11 +38,12 @@ ConnectionImplGenerator::ConnectionImplGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) - : ServiceCodeGenerator("connection_impl_header_path", - "connection_impl_cc_path", service_descriptor, - std::move(service_vars), - std::move(service_method_vars), context) {} + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) + : ServiceCodeGenerator( + "connection_impl_header_path", "connection_impl_cc_path", + service_descriptor, std::move(service_vars), + std::move(service_method_vars), context, mixin_methods) {} Status ConnectionImplGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); diff --git a/generator/internal/connection_impl_generator.h b/generator/internal/connection_impl_generator.h index 0656f586b96a0..390ec1034ec07 100644 --- a/generator/internal/connection_impl_generator.h +++ b/generator/internal/connection_impl_generator.h @@ -38,7 +38,8 @@ class ConnectionImplGenerator : public ServiceCodeGenerator { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~ConnectionImplGenerator() override = default; diff --git a/generator/internal/connection_impl_rest_generator.cc b/generator/internal/connection_impl_rest_generator.cc index 12b6396a621a2..33bce64b146f0 100644 --- a/generator/internal/connection_impl_rest_generator.cc +++ b/generator/internal/connection_impl_rest_generator.cc @@ -30,11 +30,12 @@ ConnectionImplRestGenerator::ConnectionImplRestGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) - : ServiceCodeGenerator("connection_impl_rest_header_path", - "connection_impl_rest_cc_path", service_descriptor, - std::move(service_vars), - std::move(service_method_vars), context) {} + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) + : ServiceCodeGenerator( + "connection_impl_rest_header_path", "connection_impl_rest_cc_path", + service_descriptor, std::move(service_vars), + std::move(service_method_vars), context, mixin_methods) {} Status ConnectionImplRestGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); diff --git a/generator/internal/connection_impl_rest_generator.h b/generator/internal/connection_impl_rest_generator.h index 383dae6455581..a185174d3b6e5 100644 --- a/generator/internal/connection_impl_rest_generator.h +++ b/generator/internal/connection_impl_rest_generator.h @@ -38,7 +38,8 @@ class ConnectionImplRestGenerator : public ServiceCodeGenerator { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~ConnectionImplRestGenerator() override = default; diff --git a/generator/internal/connection_rest_generator.cc b/generator/internal/connection_rest_generator.cc index 7f2c0f1907493..094cab268f2b8 100644 --- a/generator/internal/connection_rest_generator.cc +++ b/generator/internal/connection_rest_generator.cc @@ -27,11 +27,12 @@ ConnectionRestGenerator::ConnectionRestGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) - : ServiceCodeGenerator("connection_rest_header_path", - "connection_rest_cc_path", service_descriptor, - std::move(service_vars), - std::move(service_method_vars), context) {} + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) + : ServiceCodeGenerator( + "connection_rest_header_path", "connection_rest_cc_path", + service_descriptor, std::move(service_vars), + std::move(service_method_vars), context, mixin_methods) {} Status ConnectionRestGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); diff --git a/generator/internal/connection_rest_generator.h b/generator/internal/connection_rest_generator.h index 03c768f6ab1b0..af88ac733e8d4 100644 --- a/generator/internal/connection_rest_generator.h +++ b/generator/internal/connection_rest_generator.h @@ -38,7 +38,8 @@ class ConnectionRestGenerator : public ServiceCodeGenerator { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~ConnectionRestGenerator() override = default; diff --git a/generator/internal/descriptor_utils.cc b/generator/internal/descriptor_utils.cc index d9fa7252b86fb..622bfed1b7d07 100644 --- a/generator/internal/descriptor_utils.cc +++ b/generator/internal/descriptor_utils.cc @@ -454,6 +454,18 @@ std::string FormatAdditionalPbHeaderPaths(VarsDictionary& vars) { return absl::StrJoin(additional_pb_header_paths, ","); } +std::string FormatMixinPbHeaderPaths( + std::vector const& mixin_methods, std::string suffix) { + std::vector mixin_header_paths; + for (auto const& mixin_method : mixin_methods) { + std::string mixin_header_path = absl::StrCat( + absl::StripSuffix(mixin_method.method.get().file()->name(), ".proto"), + suffix); + mixin_header_paths.push_back(mixin_header_path); + } + return absl::StrJoin(mixin_header_paths, ","); +} + // If a service name mapping exists, return the new name. // Parses a command line argument in the form: // {"service_name_mappings": "service_a=new_service_a,service=new_service"}. @@ -558,7 +570,8 @@ bool CheckParameterCommentSubstitutions() { VarsDictionary CreateServiceVars( google::protobuf::ServiceDescriptor const& descriptor, - std::vector> const& initial_values) { + std::vector> const& initial_values, + std::vector const& mixin_methods) { VarsDictionary vars(initial_values.begin(), initial_values.end()); auto const& service_name = GetEffectiveServiceName(vars, descriptor.name()); vars["product_options_page"] = OptionsGroup(vars["product_path"]); @@ -691,6 +704,10 @@ VarsDictionary CreateServiceVars( absl::StripSuffix(descriptor.file()->name(), ".proto"), ".grpc.pb.h"); vars["proto_header_path"] = absl::StrCat( absl::StripSuffix(descriptor.file()->name(), ".proto"), ".pb.h"); + vars["mixin_proto_grpc_header_paths"] = + FormatMixinPbHeaderPaths(mixin_methods, ".grpc.pb.h"); + vars["mixin_proto_header_paths"] = + FormatMixinPbHeaderPaths(mixin_methods, ".pb.h"); vars["retry_policy_name"] = absl::StrCat(service_name, "RetryPolicy"); vars["retry_traits_name"] = absl::StrCat(service_name, "RetryTraits"); vars["retry_traits_header_path"] = @@ -801,7 +818,8 @@ std::map ParseIdempotencyOverrides( std::map CreateMethodVars( google::protobuf::ServiceDescriptor const& service, - YAML::Node const& service_config, VarsDictionary const& vars) { + YAML::Node const& service_config, VarsDictionary const& vars, + std::vector const& mixin_methods) { auto split_arg = [&vars](std::string const& arg) -> std::set { auto l = vars.find(arg); if (l == vars.end()) return {}; @@ -844,6 +862,42 @@ std::map CreateMethodVars( SetHttpQueryParameters(parsed_http_info, method, method_vars); service_methods_vars[method.full_name()] = method_vars; } + for (auto const& mixin_method : mixin_methods) { + auto const& method = mixin_method.method.get(); + VarsDictionary method_vars; + method_vars["method_return_doxygen_link"] = + FormatDoxygenLink(*method.output_type()); + method_vars["idempotency"] = DefaultIdempotencyFromHttpOperation(method); + if (!idempotency_overrides.empty()) { + auto iter = idempotency_overrides.find( + absl::StrCat(service.name(), ".", method.name())); + if (iter != idempotency_overrides.end()) { + method_vars["idempotency"] = iter->second; + } + } + method_vars["method_name"] = method.name(); + method_vars["method_name_snake"] = CamelCaseToSnakeCase(method.name()); + method_vars["request_type"] = + ProtoNameToCppName(method.input_type()->full_name()); + method_vars["response_message_type"] = method.output_type()->full_name(); + method_vars["response_type"] = + ProtoNameToCppName(method.output_type()->full_name()); + auto request_id_field_name = RequestIdFieldName(service_config, method); + if (!request_id_field_name.empty()) { + method_vars["request_id_field_name"] = std::move(request_id_field_name); + } + SetLongrunningOperationMethodVars(method, method_vars); + AssignPaginationMethodVars(method, method_vars); + SetMethodSignatureMethodVars(service, method, omitted_rpcs, method_vars); + auto parsed_http_info = ParseHttpExtension(method); + method_vars["request_resource"] = + FormatRequestResource(*method.input_type(), parsed_http_info); + SetHttpDerivedMethodVars(parsed_http_info, method, method_vars); + SetHttpQueryParameters(parsed_http_info, method, method_vars); + service_methods_vars[method.full_name()] = method_vars; + std::cout << "*******************************" << method.full_name() + << std::endl; + } return service_methods_vars; } diff --git a/generator/internal/descriptor_utils.h b/generator/internal/descriptor_utils.h index 3b509a835905c..18d97bc9f182b 100644 --- a/generator/internal/descriptor_utils.h +++ b/generator/internal/descriptor_utils.h @@ -16,6 +16,7 @@ #define GOOGLE_CLOUD_CPP_GENERATOR_INTERNAL_DESCRIPTOR_UTILS_H #include "generator/internal/generator_interface.h" +#include "generator/internal/mixin_utils.h" #include "generator/internal/predicate_utils.h" #include "generator/internal/printer.h" #include "absl/types/variant.h" @@ -38,14 +39,16 @@ namespace generator_internal { */ VarsDictionary CreateServiceVars( google::protobuf::ServiceDescriptor const& descriptor, - std::vector> const& initial_values); + std::vector> const& initial_values, + std::vector const& mixin_methods = std::vector()); /** * Extracts method specific substitution data for each method in the service. */ std::map CreateMethodVars( google::protobuf::ServiceDescriptor const& service, - YAML::Node const& service_config, VarsDictionary const& service_vars); + YAML::Node const& service_config, VarsDictionary const& service_vars, + std::vector const& mixin_methods = std::vector()); /** * Determines which `MethodPattern` to use from patterns for the given method diff --git a/generator/internal/descriptor_utils_test.cc b/generator/internal/descriptor_utils_test.cc index 7096610cdb8d2..a4a21f7ce72d5 100644 --- a/generator/internal/descriptor_utils_test.cc +++ b/generator/internal/descriptor_utils_test.cc @@ -1158,6 +1158,27 @@ TEST_F(CreateMethodVarsTest, FormatMethodCommentsMethodSignature) { )"""); } +TEST_F(CreateMethodVarsTest, abc) { + FileDescriptor const* f1 = + pool_.FindFileByName("google/foo/v1/service.proto"); + google::protobuf::ServiceDescriptor const* service = f1->service(0); + google::protobuf::MethodDescriptor const* method = service->method(2); + + std::cout << "service->method_count(): " << service->method_count() + << std::endl; + std::cout << "method->name(): " << method->name() << std::endl; + std::cout << "method->input_type()->full_name(): " + << method->input_type()->full_name() << std::endl; + std::cout << "method->output_type()->full_name(): " + << method->output_type()->full_name() << std::endl; + + FileDescriptor const* f2 = service->file(); + for (int i = 0; i < f2->service_count(); i++) { + std::cout << "f2->service(i)->name(): " << f2->service(i)->name() + << std::endl; + } +} + TEST_F(CreateMethodVarsTest, SkipMethodsWithDeprecatedFields) { FileDescriptor const* service_file_descriptor = pool_.FindFileByName("google/foo/v1/service.proto"); diff --git a/generator/internal/forwarding_client_generator.cc b/generator/internal/forwarding_client_generator.cc index 53d567dc4ba47..73bfff5530528 100644 --- a/generator/internal/forwarding_client_generator.cc +++ b/generator/internal/forwarding_client_generator.cc @@ -22,10 +22,12 @@ ForwardingClientGenerator::ForwardingClientGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) : ServiceCodeGenerator("forwarding_client_header_path", service_descriptor, std::move(service_vars), - std::move(service_method_vars), context) {} + std::move(service_method_vars), context, + mixin_methods) {} Status ForwardingClientGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); diff --git a/generator/internal/forwarding_client_generator.h b/generator/internal/forwarding_client_generator.h index 2e4669d09f9f7..6a348197eda17 100644 --- a/generator/internal/forwarding_client_generator.h +++ b/generator/internal/forwarding_client_generator.h @@ -36,7 +36,8 @@ class ForwardingClientGenerator : public ServiceCodeGenerator { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~ForwardingClientGenerator() override = default; diff --git a/generator/internal/forwarding_connection_generator.cc b/generator/internal/forwarding_connection_generator.cc index 65e80a29e761a..8447ed3dbf0d7 100644 --- a/generator/internal/forwarding_connection_generator.cc +++ b/generator/internal/forwarding_connection_generator.cc @@ -22,10 +22,12 @@ ForwardingConnectionGenerator::ForwardingConnectionGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) : ServiceCodeGenerator("forwarding_connection_header_path", service_descriptor, std::move(service_vars), - std::move(service_method_vars), context) {} + std::move(service_method_vars), context, + mixin_methods) {} Status ForwardingConnectionGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); diff --git a/generator/internal/forwarding_connection_generator.h b/generator/internal/forwarding_connection_generator.h index 64be04a318bff..35a82254f4990 100644 --- a/generator/internal/forwarding_connection_generator.h +++ b/generator/internal/forwarding_connection_generator.h @@ -36,7 +36,8 @@ class ForwardingConnectionGenerator : public ServiceCodeGenerator { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~ForwardingConnectionGenerator() override = default; diff --git a/generator/internal/forwarding_idempotency_policy_generator.cc b/generator/internal/forwarding_idempotency_policy_generator.cc index 44827f97dff6a..3fbab6c018141 100644 --- a/generator/internal/forwarding_idempotency_policy_generator.cc +++ b/generator/internal/forwarding_idempotency_policy_generator.cc @@ -22,10 +22,12 @@ ForwardingIdempotencyPolicyGenerator::ForwardingIdempotencyPolicyGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) : ServiceCodeGenerator("forwarding_idempotency_policy_header_path", service_descriptor, std::move(service_vars), - std::move(service_method_vars), context) {} + std::move(service_method_vars), context, + mixin_methods) {} Status ForwardingIdempotencyPolicyGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); diff --git a/generator/internal/forwarding_idempotency_policy_generator.h b/generator/internal/forwarding_idempotency_policy_generator.h index e7491649ea4ab..6411d109ae8eb 100644 --- a/generator/internal/forwarding_idempotency_policy_generator.h +++ b/generator/internal/forwarding_idempotency_policy_generator.h @@ -36,7 +36,8 @@ class ForwardingIdempotencyPolicyGenerator : public ServiceCodeGenerator { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~ForwardingIdempotencyPolicyGenerator() override = default; diff --git a/generator/internal/forwarding_mock_connection_generator.cc b/generator/internal/forwarding_mock_connection_generator.cc index 701d7f8f0a3e9..4b8cce6971407 100644 --- a/generator/internal/forwarding_mock_connection_generator.cc +++ b/generator/internal/forwarding_mock_connection_generator.cc @@ -22,10 +22,12 @@ ForwardingMockConnectionGenerator::ForwardingMockConnectionGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) : ServiceCodeGenerator("forwarding_mock_connection_header_path", service_descriptor, std::move(service_vars), - std::move(service_method_vars), context) {} + std::move(service_method_vars), context, + mixin_methods) {} Status ForwardingMockConnectionGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); diff --git a/generator/internal/forwarding_mock_connection_generator.h b/generator/internal/forwarding_mock_connection_generator.h index 91a691ad081fa..04b01445c3329 100644 --- a/generator/internal/forwarding_mock_connection_generator.h +++ b/generator/internal/forwarding_mock_connection_generator.h @@ -36,7 +36,8 @@ class ForwardingMockConnectionGenerator : public ServiceCodeGenerator { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~ForwardingMockConnectionGenerator() override = default; diff --git a/generator/internal/forwarding_options_generator.cc b/generator/internal/forwarding_options_generator.cc index a9def4a122eff..d79882fad809e 100644 --- a/generator/internal/forwarding_options_generator.cc +++ b/generator/internal/forwarding_options_generator.cc @@ -22,10 +22,12 @@ ForwardingOptionsGenerator::ForwardingOptionsGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) : ServiceCodeGenerator("forwarding_options_header_path", service_descriptor, std::move(service_vars), - std::move(service_method_vars), context) {} + std::move(service_method_vars), context, + mixin_methods) {} Status ForwardingOptionsGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); diff --git a/generator/internal/forwarding_options_generator.h b/generator/internal/forwarding_options_generator.h index 9e96f044245c3..c2250296c9997 100644 --- a/generator/internal/forwarding_options_generator.h +++ b/generator/internal/forwarding_options_generator.h @@ -36,7 +36,8 @@ class ForwardingOptionsGenerator : public ServiceCodeGenerator { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~ForwardingOptionsGenerator() override = default; diff --git a/generator/internal/idempotency_policy_generator.cc b/generator/internal/idempotency_policy_generator.cc index 164ba78816b87..9dc9c07dd5916 100644 --- a/generator/internal/idempotency_policy_generator.cc +++ b/generator/internal/idempotency_policy_generator.cc @@ -30,11 +30,12 @@ IdempotencyPolicyGenerator::IdempotencyPolicyGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) - : ServiceCodeGenerator("idempotency_policy_header_path", - "idempotency_policy_cc_path", service_descriptor, - std::move(service_vars), - std::move(service_method_vars), context) {} + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) + : ServiceCodeGenerator( + "idempotency_policy_header_path", "idempotency_policy_cc_path", + service_descriptor, std::move(service_vars), + std::move(service_method_vars), context, mixin_methods) {} Status IdempotencyPolicyGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); @@ -51,7 +52,10 @@ Status IdempotencyPolicyGenerator::GenerateHeader() { // includes HeaderPrint("\n"); HeaderLocalIncludes({"google/cloud/idempotency.h", "google/cloud/version.h"}); - HeaderSystemIncludes({GetPbIncludeByTransport(), "memory"}); + + auto headers = GetMixinPbIncludeByTransport(); + headers.insert(headers.end(), {GetPbIncludeByTransport(), "memory"}); + HeaderSystemIncludes(headers); auto result = HeaderOpenNamespaces(); if (!result.ok()) return result; diff --git a/generator/internal/idempotency_policy_generator.h b/generator/internal/idempotency_policy_generator.h index 39414f1e5d321..c27f55d42fb16 100644 --- a/generator/internal/idempotency_policy_generator.h +++ b/generator/internal/idempotency_policy_generator.h @@ -38,7 +38,8 @@ class IdempotencyPolicyGenerator : public ServiceCodeGenerator { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~IdempotencyPolicyGenerator() override = default; diff --git a/generator/internal/logging_decorator_generator.cc b/generator/internal/logging_decorator_generator.cc index a841ee3c4330c..f3d4370e2aa61 100644 --- a/generator/internal/logging_decorator_generator.cc +++ b/generator/internal/logging_decorator_generator.cc @@ -30,10 +30,12 @@ LoggingDecoratorGenerator::LoggingDecoratorGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) : StubGeneratorBase("logging_header_path", "logging_cc_path", service_descriptor, std::move(service_vars), - std::move(service_method_vars), context) {} + std::move(service_method_vars), context, + mixin_methods) {} bool LoggingDecoratorGenerator::HasStreamingMethod() { return HasStreamingReadMethod() || HasStreamingWriteMethod() || diff --git a/generator/internal/logging_decorator_generator.h b/generator/internal/logging_decorator_generator.h index 992377a1cf028..b6de8d88cf78c 100644 --- a/generator/internal/logging_decorator_generator.h +++ b/generator/internal/logging_decorator_generator.h @@ -38,7 +38,8 @@ class LoggingDecoratorGenerator : public StubGeneratorBase { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~LoggingDecoratorGenerator() override = default; diff --git a/generator/internal/logging_decorator_rest_generator.cc b/generator/internal/logging_decorator_rest_generator.cc index 5755437d8f144..11accbe7e9c38 100644 --- a/generator/internal/logging_decorator_rest_generator.cc +++ b/generator/internal/logging_decorator_rest_generator.cc @@ -29,10 +29,12 @@ LoggingDecoratorRestGenerator::LoggingDecoratorRestGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) : ServiceCodeGenerator("logging_rest_header_path", "logging_rest_cc_path", service_descriptor, std::move(service_vars), - std::move(service_method_vars), context) {} + std::move(service_method_vars), context, + mixin_methods) {} Status LoggingDecoratorRestGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); diff --git a/generator/internal/logging_decorator_rest_generator.h b/generator/internal/logging_decorator_rest_generator.h index c0c6504e092f2..35bb3f9fe3959 100644 --- a/generator/internal/logging_decorator_rest_generator.h +++ b/generator/internal/logging_decorator_rest_generator.h @@ -38,7 +38,8 @@ class LoggingDecoratorRestGenerator : public ServiceCodeGenerator { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~LoggingDecoratorRestGenerator() override = default; diff --git a/generator/internal/make_generators.cc b/generator/internal/make_generators.cc index a27248353feb6..9ec01a8d04cb6 100644 --- a/generator/internal/make_generators.cc +++ b/generator/internal/make_generators.cc @@ -30,6 +30,7 @@ #include "generator/internal/logging_decorator_rest_generator.h" #include "generator/internal/metadata_decorator_generator.h" #include "generator/internal/metadata_decorator_rest_generator.h" +#include "generator/internal/mixin_utils.h" #include "generator/internal/mock_connection_generator.h" #include "generator/internal/option_defaults_generator.h" #include "generator/internal/options_generator.h" @@ -59,10 +60,28 @@ std::vector> MakeGenerators( google::protobuf::compiler::GeneratorContext* context, YAML::Node const& service_config, std::vector> const& vars) { + std::vector mixin_methods; + if (service->name() == "DataMigrationService") { + std::cout << "###########################################" + << service->name() << std::endl; + mixin_methods = GetMixinMethods(service_config, *service); + for (auto const& mixin_method : mixin_methods) { + absl::optional body = mixin_method.method_override.http_body; + + std::cout << mixin_method.method.get().full_name() << " " + << mixin_method.method_override.http_verb << " " + << mixin_method.method_override.http_path << " " + << (body.has_value() ? *body : "") << std::endl; + } + + std::cout << "###########################################" << std::endl; + } std::vector sources; std::vector> code_generators; - VarsDictionary service_vars = CreateServiceVars(*service, vars); - auto method_vars = CreateMethodVars(*service, service_config, service_vars); + VarsDictionary service_vars = + CreateServiceVars(*service, vars, mixin_methods); + auto method_vars = + CreateMethodVars(*service, service_config, service_vars, mixin_methods); auto get_flag = [&](std::string const& key, bool default_value = false) { auto iter = service_vars.find(key); if (iter == service_vars.end()) return default_value; @@ -75,70 +94,70 @@ std::vector> MakeGenerators( if (!omit_client) { code_generators.push_back(std::make_unique( - service, service_vars, method_vars, context)); + service, service_vars, method_vars, context, mixin_methods)); code_generators.push_back(std::make_unique( - service, service_vars, method_vars, context)); + service, service_vars, method_vars, context, mixin_methods)); } if (!get_flag("omit_connection")) { if (generate_grpc_transport) { code_generators.push_back(std::make_unique( - service, service_vars, method_vars, context)); + service, service_vars, method_vars, context, mixin_methods)); } code_generators.push_back(std::make_unique( - service, service_vars, method_vars, context)); + service, service_vars, method_vars, context, mixin_methods)); code_generators.push_back(std::make_unique( - service, service_vars, method_vars, context)); + service, service_vars, method_vars, context, mixin_methods)); code_generators.push_back(std::make_unique( - service, service_vars, method_vars, context)); + service, service_vars, method_vars, context, mixin_methods)); code_generators.push_back(std::make_unique( - service, service_vars, method_vars, context)); + service, service_vars, method_vars, context, mixin_methods)); code_generators.push_back(std::make_unique( - service, service_vars, method_vars, context)); + service, service_vars, method_vars, context, mixin_methods)); if (service_vars.find("retry_status_code_expression") != service_vars.end()) { code_generators.push_back(std::make_unique( - service, service_vars, method_vars, context)); + service, service_vars, method_vars, context, mixin_methods)); } code_generators.push_back(std::make_unique( - service, service_vars, method_vars, context)); + service, service_vars, method_vars, context, mixin_methods)); } if (!get_flag("omit_stub_factory") && generate_grpc_transport) { code_generators.push_back(std::make_unique( - service, service_vars, method_vars, context)); + service, service_vars, method_vars, context, mixin_methods)); } auto const forwarding_headers = service_vars.find("forwarding_product_path"); if (forwarding_headers != service_vars.end() && !forwarding_headers->second.empty()) { code_generators.push_back(std::make_unique( - service, service_vars, method_vars, context)); + service, service_vars, method_vars, context, mixin_methods)); code_generators.push_back(std::make_unique( - service, service_vars, method_vars, context)); + service, service_vars, method_vars, context, mixin_methods)); code_generators.push_back( std::make_unique( - service, service_vars, method_vars, context)); + service, service_vars, method_vars, context, mixin_methods)); code_generators.push_back( std::make_unique( - service, service_vars, method_vars, context)); + service, service_vars, method_vars, context, mixin_methods)); code_generators.push_back(std::make_unique( - service, service_vars, method_vars, context)); + service, service_vars, method_vars, context, mixin_methods)); } if (generate_grpc_transport) { code_generators.push_back(std::make_unique( - service, service_vars, method_vars, context)); + service, service_vars, method_vars, context, mixin_methods)); code_generators.push_back(std::make_unique( - service, service_vars, method_vars, context)); + service, service_vars, method_vars, context, mixin_methods)); code_generators.push_back(std::make_unique( - service, service_vars, method_vars, context)); + service, service_vars, method_vars, context, mixin_methods)); code_generators.push_back(std::make_unique( - service, service_vars, method_vars, context)); + service, service_vars, method_vars, context, mixin_methods)); code_generators.push_back(std::make_unique( - service, service_vars, method_vars, context)); + service, service_vars, method_vars, context, mixin_methods)); } if (get_flag("generate_round_robin_decorator")) { code_generators.push_back(std::make_unique( - service, service_vars, method_vars, context)); + service, service_vars, method_vars, context, mixin_methods)); sources.push_back(service_vars["round_robin_cc_path"]); } @@ -148,17 +167,17 @@ std::vector> MakeGenerators( auto rest_service_vars = service_vars; rest_service_vars.erase("backwards_compatibility_namespace_alias"); code_generators.push_back(std::make_unique( - service, rest_service_vars, method_vars, context)); + service, rest_service_vars, method_vars, context, mixin_methods)); code_generators.push_back(std::make_unique( - service, rest_service_vars, method_vars, context)); + service, rest_service_vars, method_vars, context, mixin_methods)); code_generators.push_back(std::make_unique( - service, rest_service_vars, method_vars, context)); + service, rest_service_vars, method_vars, context, mixin_methods)); code_generators.push_back(std::make_unique( - service, rest_service_vars, method_vars, context)); + service, rest_service_vars, method_vars, context, mixin_methods)); code_generators.push_back(std::make_unique( - service, rest_service_vars, method_vars, context)); + service, rest_service_vars, method_vars, context, mixin_methods)); code_generators.push_back(std::make_unique( - service, rest_service_vars, method_vars, context)); + service, rest_service_vars, method_vars, context, mixin_methods)); } if (!omit_client) { @@ -195,7 +214,8 @@ std::vector> MakeGenerators( std::sort(sources.begin(), sources.end()); code_generators.push_back(std::make_unique( - service, service_vars, method_vars, context, std::move(sources))); + service, service_vars, method_vars, context, std::move(sources), + mixin_methods)); } return code_generators; diff --git a/generator/internal/metadata_decorator_generator.cc b/generator/internal/metadata_decorator_generator.cc index 0ba5d6ee4def1..7e915dba47c40 100644 --- a/generator/internal/metadata_decorator_generator.cc +++ b/generator/internal/metadata_decorator_generator.cc @@ -106,10 +106,12 @@ MetadataDecoratorGenerator::MetadataDecoratorGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) : StubGeneratorBase("metadata_header_path", "metadata_cc_path", service_descriptor, std::move(service_vars), - std::move(service_method_vars), context) {} + std::move(service_method_vars), context, + mixin_methods) {} Status MetadataDecoratorGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); diff --git a/generator/internal/metadata_decorator_generator.h b/generator/internal/metadata_decorator_generator.h index 48364c5b9e623..06c9027ece94b 100644 --- a/generator/internal/metadata_decorator_generator.h +++ b/generator/internal/metadata_decorator_generator.h @@ -38,7 +38,8 @@ class MetadataDecoratorGenerator : public StubGeneratorBase { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~MetadataDecoratorGenerator() override = default; diff --git a/generator/internal/metadata_decorator_rest_generator.cc b/generator/internal/metadata_decorator_rest_generator.cc index f89efa5c13c50..1b9148ecc1f95 100644 --- a/generator/internal/metadata_decorator_rest_generator.cc +++ b/generator/internal/metadata_decorator_rest_generator.cc @@ -95,10 +95,12 @@ MetadataDecoratorRestGenerator::MetadataDecoratorRestGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) : ServiceCodeGenerator("metadata_rest_header_path", "metadata_rest_cc_path", service_descriptor, std::move(service_vars), - std::move(service_method_vars), context) {} + std::move(service_method_vars), context, + mixin_methods) {} Status MetadataDecoratorRestGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); diff --git a/generator/internal/metadata_decorator_rest_generator.h b/generator/internal/metadata_decorator_rest_generator.h index c4c35ce1b6b38..0018d702d7ce8 100644 --- a/generator/internal/metadata_decorator_rest_generator.h +++ b/generator/internal/metadata_decorator_rest_generator.h @@ -38,7 +38,8 @@ class MetadataDecoratorRestGenerator : public ServiceCodeGenerator { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~MetadataDecoratorRestGenerator() override = default; diff --git a/generator/internal/mixin_utils.cc b/generator/internal/mixin_utils.cc new file mode 100644 index 0000000000000..e89b8303701e9 --- /dev/null +++ b/generator/internal/mixin_utils.cc @@ -0,0 +1,128 @@ +#include "generator/internal/mixin_utils.h" +#include +#include +#include +#include +#include +#include +#include "google/cloud/log.h" +#include "absl/types/optional.h" + +using ::google::protobuf::FileDescriptor; +using ::google::protobuf::ServiceDescriptor; +using ::google::protobuf::MethodDescriptor; +using ::google::protobuf::DescriptorPool; + +namespace google { +namespace cloud { +namespace generator_internal { +namespace { + +std::unordered_map mixin_proto_path_map = { + {"google.cloud.location.Locations", "google/cloud/location/locations.proto"}, + // {"google.iam.v1.IAMPolicy", "google/iam/v1/iam_policy.proto"}, + // {"google.longrunning.Operations", "google/longrunning/operations.proto"}, +}; + +std::unordered_set http_verbs = {"get", "post", "put", "patch", "delete"}; + +std::unordered_map GetMixinMethodOverrides(YAML::Node const& service_config) { + std::unordered_map mixin_method_overrides; + if (service_config.Type() != YAML::NodeType::Map) return mixin_method_overrides; + auto const& http = service_config["http"]; + if (http.Type() != YAML::NodeType::Map) return mixin_method_overrides; + auto const& rules = http["rules"]; + if (rules.Type() != YAML::NodeType::Sequence) return mixin_method_overrides; + for (auto const& rule : rules) { + if (rule.Type() != YAML::NodeType::Map) continue; + + auto const& selector = rule["selector"]; + if (selector.Type() != YAML::NodeType::Scalar) continue; + std::string method_full_name = selector.as(); + + for (auto const& kv : rule) { + if (kv.first.Type() != YAML::NodeType::Scalar || kv.second.Type() != YAML::NodeType::Scalar) continue; + + std::string http_verb = kv.first.as(); + if (http_verbs.find(http_verb) == http_verbs.end()) continue; + std::string http_path = kv.second.as(); + + absl::optional http_body; + if (rule["body"]) { + http_body = rule["body"].as(); + } + mixin_method_overrides[method_full_name] = MixinMethodOverride{http_verb, http_path, http_body}; + } + } + return mixin_method_overrides; +} + +std::unordered_map GetDedupedMixinMethodOverrides(YAML::Node const& service_config, ServiceDescriptor const& service) { + auto mixin_method_overrides = GetMixinMethodOverrides(service_config); + for (int i = 0; i < service.method_count(); ++i) { + auto const* method = service.method(i); + auto method_full_name = method->full_name(); + if (mixin_method_overrides.find(method_full_name) != mixin_method_overrides.end()) { + mixin_method_overrides.erase(method_full_name); + } + } + return mixin_method_overrides; +} + +} // namespace + +std::vector GetMixinProtoPaths(YAML::Node const& service_config) { + std::vector proto_paths; + if (service_config.Type() != YAML::NodeType::Map) return proto_paths; + auto const& apis = service_config["apis"]; + if (apis.Type() != YAML::NodeType::Sequence) return proto_paths; + for (auto const& api : apis) { + if (api.Type() != YAML::NodeType::Map) continue; + auto const& name = api["name"]; + if (name.Type() != YAML::NodeType::Scalar) continue; + std::string package_path = name.as(); + if (mixin_proto_path_map.find(package_path) == mixin_proto_path_map.end()) continue; + proto_paths.push_back(mixin_proto_path_map[package_path]); + } + return proto_paths; +} + +std::vector GetMixinProtoPaths(std::string& service_yaml_path) { + YAML::Node service_config = YAML::LoadFile(service_yaml_path); + return GetMixinProtoPaths(service_config); +} + +std::vector GetMixinMethods( + YAML::Node const& service_config, ServiceDescriptor const& service) { + std::vector mixin_methods; + DescriptorPool const* pool = service.file()->pool(); + if (pool == nullptr) { + GCP_LOG(FATAL) << __FILE__ << ":" << __LINE__ + << " DescriptorPool doesn't exist for service: " << service.full_name(); + } + auto mixin_proto_paths = GetMixinProtoPaths(service_config); + auto mixin_method_overrides = GetDedupedMixinMethodOverrides(service_config, service); + + for (auto const& mixin_proto_path : mixin_proto_paths) { + FileDescriptor const* mixin_file = pool->FindFileByName(mixin_proto_path); + if (mixin_file == nullptr) { + GCP_LOG(FATAL) << __FILE__ << ":" << __LINE__ + << " Mixin FileDescriptor is not found for path: " << mixin_proto_path + << " in service: " << service.full_name(); + } + for (int i = 0; i < mixin_file->service_count(); ++i) { + ServiceDescriptor const* mixin_service = mixin_file->service(i); + for (int j = 0; j < mixin_service->method_count(); ++j) { + MethodDescriptor const* mixin_method = mixin_service->method(j); + auto mixin_method_full_name = mixin_method->full_name(); + if (mixin_method_overrides.find(mixin_method_full_name) == mixin_method_overrides.end()) continue; + mixin_methods.push_back({*mixin_method, mixin_method_overrides[mixin_method_full_name]}); + } + } + } + return mixin_methods; +} + +} // namespace generator_internal +} // namespace cloud +} // namespace google \ No newline at end of file diff --git a/generator/internal/mixin_utils.h b/generator/internal/mixin_utils.h new file mode 100644 index 0000000000000..b33cfbae783c6 --- /dev/null +++ b/generator/internal/mixin_utils.h @@ -0,0 +1,51 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef GOOGLE_CLOUD_CPP_GENERATOR_INTERNAL_MIXIN_UTILS_H +#define GOOGLE_CLOUD_CPP_GENERATOR_INTERNAL_MIXIN_UTILS_H + +#include +#include +#include "absl/types/optional.h" +#include +#include + + +namespace google { +namespace cloud { +namespace generator_internal { + +struct MixinMethodOverride { + std::string http_verb; + std::string http_path; + absl::optional http_body; +}; + +struct MixinMethod { + std::reference_wrapper method; + MixinMethodOverride method_override; +}; + +std::vector GetMixinProtoPaths(YAML::Node const& service_config); + +std::vector GetMixinProtoPaths(std::string& service_yaml_path); + +std::vector GetMixinMethods( + YAML::Node const& service_config, google::protobuf::ServiceDescriptor const& service); + +} // namespace generator_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GENERATOR_INTERNAL_MIXIN_UTILS_H \ No newline at end of file diff --git a/generator/internal/mock_connection_generator.cc b/generator/internal/mock_connection_generator.cc index c52306a9bef4b..438434ee0bd44 100644 --- a/generator/internal/mock_connection_generator.cc +++ b/generator/internal/mock_connection_generator.cc @@ -29,10 +29,12 @@ MockConnectionGenerator::MockConnectionGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) : ServiceCodeGenerator("mock_connection_header_path", service_descriptor, std::move(service_vars), - std::move(service_method_vars), context) {} + std::move(service_method_vars), context, + mixin_methods) {} Status MockConnectionGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); diff --git a/generator/internal/mock_connection_generator.h b/generator/internal/mock_connection_generator.h index 92975eacc4aec..062f2816b9620 100644 --- a/generator/internal/mock_connection_generator.h +++ b/generator/internal/mock_connection_generator.h @@ -38,7 +38,8 @@ class MockConnectionGenerator : public ServiceCodeGenerator { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~MockConnectionGenerator() override = default; diff --git a/generator/internal/option_defaults_generator.cc b/generator/internal/option_defaults_generator.cc index 6d113059d666d..b621f7558f582 100644 --- a/generator/internal/option_defaults_generator.cc +++ b/generator/internal/option_defaults_generator.cc @@ -25,11 +25,12 @@ OptionDefaultsGenerator::OptionDefaultsGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) - : ServiceCodeGenerator("option_defaults_header_path", - "option_defaults_cc_path", service_descriptor, - std::move(service_vars), - std::move(service_method_vars), context) {} + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) + : ServiceCodeGenerator( + "option_defaults_header_path", "option_defaults_cc_path", + service_descriptor, std::move(service_vars), + std::move(service_method_vars), context, mixin_methods) {} Status OptionDefaultsGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); diff --git a/generator/internal/option_defaults_generator.h b/generator/internal/option_defaults_generator.h index 571069a65329f..6b53fdcda4f79 100644 --- a/generator/internal/option_defaults_generator.h +++ b/generator/internal/option_defaults_generator.h @@ -37,7 +37,8 @@ class OptionDefaultsGenerator : public ServiceCodeGenerator { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~OptionDefaultsGenerator() override = default; diff --git a/generator/internal/options_generator.cc b/generator/internal/options_generator.cc index 71605ff70f1a3..81e703fea4fb5 100644 --- a/generator/internal/options_generator.cc +++ b/generator/internal/options_generator.cc @@ -27,10 +27,11 @@ OptionsGenerator::OptionsGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) - : ServiceCodeGenerator("options_header_path", service_descriptor, - std::move(service_vars), - std::move(service_method_vars), context) {} + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) + : ServiceCodeGenerator( + "options_header_path", service_descriptor, std::move(service_vars), + std::move(service_method_vars), context, mixin_methods) {} Status OptionsGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); diff --git a/generator/internal/options_generator.h b/generator/internal/options_generator.h index 517648b1dce4d..2387248076c43 100644 --- a/generator/internal/options_generator.h +++ b/generator/internal/options_generator.h @@ -38,7 +38,8 @@ class OptionsGenerator : public ServiceCodeGenerator { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~OptionsGenerator() override = default; diff --git a/generator/internal/retry_traits_generator.cc b/generator/internal/retry_traits_generator.cc index 9c4e0c36bb5ab..9e9929d7fee28 100644 --- a/generator/internal/retry_traits_generator.cc +++ b/generator/internal/retry_traits_generator.cc @@ -25,10 +25,12 @@ RetryTraitsGenerator::RetryTraitsGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) : ServiceCodeGenerator("retry_traits_header_path", service_descriptor, std::move(service_vars), - std::move(service_method_vars), context) {} + std::move(service_method_vars), context, + mixin_methods) {} Status RetryTraitsGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); diff --git a/generator/internal/retry_traits_generator.h b/generator/internal/retry_traits_generator.h index 69668e8aca553..7ec2cc5e2e229 100644 --- a/generator/internal/retry_traits_generator.h +++ b/generator/internal/retry_traits_generator.h @@ -36,7 +36,8 @@ class RetryTraitsGenerator : public ServiceCodeGenerator { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~RetryTraitsGenerator() override = default; diff --git a/generator/internal/round_robin_decorator_generator.cc b/generator/internal/round_robin_decorator_generator.cc index e62340426711e..6e45b966ca982 100644 --- a/generator/internal/round_robin_decorator_generator.cc +++ b/generator/internal/round_robin_decorator_generator.cc @@ -28,10 +28,12 @@ RoundRobinDecoratorGenerator::RoundRobinDecoratorGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) : StubGeneratorBase("round_robin_header_path", "round_robin_cc_path", service_descriptor, std::move(service_vars), - std::move(service_method_vars), context) {} + std::move(service_method_vars), context, + mixin_methods) {} Status RoundRobinDecoratorGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); diff --git a/generator/internal/round_robin_decorator_generator.h b/generator/internal/round_robin_decorator_generator.h index 16a078b731844..433b67a962db8 100644 --- a/generator/internal/round_robin_decorator_generator.h +++ b/generator/internal/round_robin_decorator_generator.h @@ -37,7 +37,8 @@ class RoundRobinDecoratorGenerator : public StubGeneratorBase { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~RoundRobinDecoratorGenerator() override = default; diff --git a/generator/internal/sample_generator.cc b/generator/internal/sample_generator.cc index 40c45182b051a..7814dc6896459 100644 --- a/generator/internal/sample_generator.cc +++ b/generator/internal/sample_generator.cc @@ -22,10 +22,11 @@ SampleGenerator::SampleGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) - : ServiceCodeGenerator("client_samples_cc_path", service_descriptor, - std::move(service_vars), - std::move(service_method_vars), context) {} + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) + : ServiceCodeGenerator( + "client_samples_cc_path", service_descriptor, std::move(service_vars), + std::move(service_method_vars), context, mixin_methods) {} Status SampleGenerator::GenerateCc() { return {}; } diff --git a/generator/internal/sample_generator.h b/generator/internal/sample_generator.h index 50459c7f6cff3..c873e40f5aadb 100644 --- a/generator/internal/sample_generator.h +++ b/generator/internal/sample_generator.h @@ -35,7 +35,8 @@ class SampleGenerator : public ServiceCodeGenerator { SampleGenerator(google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~SampleGenerator() override = default; diff --git a/generator/internal/service_code_generator.cc b/generator/internal/service_code_generator.cc index 1e38cb371911f..3ad720e0fe927 100644 --- a/generator/internal/service_code_generator.cc +++ b/generator/internal/service_code_generator.cc @@ -59,12 +59,14 @@ ServiceCodeGenerator::ServiceCodeGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) : service_descriptor_(service_descriptor), service_vars_(std::move(service_vars)), service_method_vars_(std::move(service_method_vars)), header_(context, service_vars_[header_path_key]), - cc_(context, service_vars_[cc_path_key]) { + cc_(context, service_vars_[cc_path_key]), + mixin_methods_(mixin_methods) { assert(service_descriptor != nullptr); assert(context != nullptr); SetVars(service_vars_[header_path_key]); @@ -79,11 +81,13 @@ ServiceCodeGenerator::ServiceCodeGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) : service_descriptor_(service_descriptor), service_vars_(std::move(service_vars)), service_method_vars_(std::move(service_method_vars)), - header_(context, service_vars_[header_path_key]) { + header_(context, service_vars_[header_path_key]), + mixin_methods_(mixin_methods) { assert(service_descriptor != nullptr); assert(context != nullptr); SetVars(service_vars_[header_path_key]); @@ -474,6 +478,12 @@ void ServiceCodeGenerator::SetMethods() { async_methods_.emplace_back(*method); } } + + for (auto const& mixin_method : mixin_methods_) { + methods_.emplace_back(mixin_method.method.get()); + std::cout << "-----------------------" + << mixin_method.method.get().full_name() << std::endl; + } } std::string ServiceCodeGenerator::GetPbIncludeByTransport() const { @@ -481,6 +491,15 @@ std::string ServiceCodeGenerator::GetPbIncludeByTransport() const { return vars("proto_header_path"); } +std::vector ServiceCodeGenerator::GetMixinPbIncludeByTransport() + const { + std::string mixin_pb_header_paths = + HasGenerateGrpcTransport() ? vars("mixin_proto_grpc_header_paths") + : vars("mixin_proto_header_paths"); + + return absl::StrSplit(mixin_pb_header_paths, ","); +} + bool ServiceCodeGenerator::IsDiscoveryDocumentProto() const { auto iter = service_vars_.find("proto_file_source"); return (iter != service_vars_.end() && iter->second == "discovery_document"); diff --git a/generator/internal/service_code_generator.h b/generator/internal/service_code_generator.h index 2c8950d2772c3..333cc4927541c 100644 --- a/generator/internal/service_code_generator.h +++ b/generator/internal/service_code_generator.h @@ -19,6 +19,7 @@ #include "generator/internal/codegen_utils.h" #include "generator/internal/descriptor_utils.h" #include "generator/internal/generator_interface.h" +#include "generator/internal/mixin_utils.h" #include "generator/internal/printer.h" #include "google/cloud/status.h" #include @@ -34,14 +35,16 @@ class ServiceCodeGenerator : public GeneratorInterface { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ServiceCodeGenerator( std::string const& header_path_key, google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~ServiceCodeGenerator() override = default; @@ -221,6 +224,8 @@ class ServiceCodeGenerator : public GeneratorInterface { */ std::string GetPbIncludeByTransport() const; + std::vector GetMixinPbIncludeByTransport() const; + /** * If the service defining protos are produced from a REST Discovery Document. */ @@ -251,6 +256,7 @@ class ServiceCodeGenerator : public GeneratorInterface { MethodDescriptorList async_methods_; Printer header_; Printer cc_; + std::vector mixin_methods_; }; } // namespace generator_internal diff --git a/generator/internal/service_code_generator_test.cc b/generator/internal/service_code_generator_test.cc index 41f10d4f2df59..1bd8678f56258 100644 --- a/generator/internal/service_code_generator_test.cc +++ b/generator/internal/service_code_generator_test.cc @@ -44,9 +44,12 @@ class TestGenerator : public ServiceCodeGenerator { TestGenerator(google::protobuf::ServiceDescriptor const* service_descriptor, google::protobuf::compiler::GeneratorContext* context, VarsDictionary service_vars = {{"header_path_key", - "header_path"}}) + "header_path"}}, + std::vector const& mixin_methods = + std::vector()) : ServiceCodeGenerator("header_path_key", service_descriptor, - std::move(service_vars), {}, context) {} + std::move(service_vars), {}, context, + mixin_methods) {} using ServiceCodeGenerator::GetPbIncludeByTransport; using ServiceCodeGenerator::HasBidirStreamingMethod; diff --git a/generator/internal/sources_generator.cc b/generator/internal/sources_generator.cc index 521d1ca893389..7646797c90870 100644 --- a/generator/internal/sources_generator.cc +++ b/generator/internal/sources_generator.cc @@ -36,10 +36,12 @@ SourcesGenerator::SourcesGenerator( VarsDictionary service_vars, std::map service_method_vars, google::protobuf::compiler::GeneratorContext* context, - std::vector sources) + std::vector sources, + std::vector const& mixin_methods) : ServiceCodeGenerator("sources_cc_path", service_descriptor, ModifyCopyrightYear(std::move(service_vars)), - std::move(service_method_vars), context), + std::move(service_method_vars), context, + mixin_methods), sources_(std::move(sources)) {} Status SourcesGenerator::GenerateHeader() { diff --git a/generator/internal/sources_generator.h b/generator/internal/sources_generator.h index 151f51778e6e8..39b7be6689ab7 100644 --- a/generator/internal/sources_generator.h +++ b/generator/internal/sources_generator.h @@ -47,7 +47,8 @@ class SourcesGenerator : public ServiceCodeGenerator { VarsDictionary service_vars, std::map service_method_vars, google::protobuf::compiler::GeneratorContext* context, - std::vector sources); + std::vector sources, + std::vector const& mixin_methods); ~SourcesGenerator() override = default; diff --git a/generator/internal/stub_factory_generator.cc b/generator/internal/stub_factory_generator.cc index b275f1dc22336..e3695b3a1cb53 100644 --- a/generator/internal/stub_factory_generator.cc +++ b/generator/internal/stub_factory_generator.cc @@ -25,10 +25,12 @@ StubFactoryGenerator::StubFactoryGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) : ServiceCodeGenerator("stub_factory_header_path", "stub_factory_cc_path", service_descriptor, std::move(service_vars), - std::move(service_method_vars), context) {} + std::move(service_method_vars), context, + mixin_methods) {} Status StubFactoryGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); diff --git a/generator/internal/stub_factory_generator.h b/generator/internal/stub_factory_generator.h index 8dba8d26b5773..6c9516fb8b9d6 100644 --- a/generator/internal/stub_factory_generator.h +++ b/generator/internal/stub_factory_generator.h @@ -37,7 +37,8 @@ class StubFactoryGenerator : public ServiceCodeGenerator { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~StubFactoryGenerator() override = default; diff --git a/generator/internal/stub_factory_rest_generator.cc b/generator/internal/stub_factory_rest_generator.cc index f3ddc9aedb40b..914ea19a28d33 100644 --- a/generator/internal/stub_factory_rest_generator.cc +++ b/generator/internal/stub_factory_rest_generator.cc @@ -25,11 +25,12 @@ StubFactoryRestGenerator::StubFactoryRestGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) - : ServiceCodeGenerator("stub_factory_rest_header_path", - "stub_factory_rest_cc_path", service_descriptor, - std::move(service_vars), - std::move(service_method_vars), context) {} + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) + : ServiceCodeGenerator( + "stub_factory_rest_header_path", "stub_factory_rest_cc_path", + service_descriptor, std::move(service_vars), + std::move(service_method_vars), context, mixin_methods) {} Status StubFactoryRestGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); diff --git a/generator/internal/stub_factory_rest_generator.h b/generator/internal/stub_factory_rest_generator.h index 695aac762d818..c8b345f84e83e 100644 --- a/generator/internal/stub_factory_rest_generator.h +++ b/generator/internal/stub_factory_rest_generator.h @@ -37,7 +37,8 @@ class StubFactoryRestGenerator : public ServiceCodeGenerator { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~StubFactoryRestGenerator() override = default; diff --git a/generator/internal/stub_generator.cc b/generator/internal/stub_generator.cc index 670a9aa6aa428..af3098fe6d2db 100644 --- a/generator/internal/stub_generator.cc +++ b/generator/internal/stub_generator.cc @@ -30,10 +30,11 @@ StubGenerator::StubGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) : StubGeneratorBase("stub_header_path", "stub_cc_path", service_descriptor, std::move(service_vars), std::move(service_method_vars), - context) {} + context, mixin_methods) {} Status StubGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); diff --git a/generator/internal/stub_generator.h b/generator/internal/stub_generator.h index b972b32af6fbe..5f46a6fdba169 100644 --- a/generator/internal/stub_generator.h +++ b/generator/internal/stub_generator.h @@ -38,7 +38,8 @@ class StubGenerator : public StubGeneratorBase { StubGenerator(google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~StubGenerator() override = default; diff --git a/generator/internal/stub_generator_base.cc b/generator/internal/stub_generator_base.cc index e41a2b12b6121..eb82a604e0c01 100644 --- a/generator/internal/stub_generator_base.cc +++ b/generator/internal/stub_generator_base.cc @@ -26,10 +26,12 @@ StubGeneratorBase::StubGeneratorBase( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) : ServiceCodeGenerator(header_path_key, cc_path_key, service_descriptor, std::move(service_vars), - std::move(service_method_vars), context) {} + std::move(service_method_vars), context, + mixin_methods) {} void StubGeneratorBase::HeaderPrintPublicMethods() { for (auto const& method : methods()) { diff --git a/generator/internal/stub_generator_base.h b/generator/internal/stub_generator_base.h index 042caf70f5b9c..1eee21975656a 100644 --- a/generator/internal/stub_generator_base.h +++ b/generator/internal/stub_generator_base.h @@ -36,7 +36,8 @@ class StubGeneratorBase : public ServiceCodeGenerator { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); protected: void HeaderPrintPublicMethods(); diff --git a/generator/internal/stub_rest_generator.cc b/generator/internal/stub_rest_generator.cc index a217a67ab870b..e2ebda83aa758 100644 --- a/generator/internal/stub_rest_generator.cc +++ b/generator/internal/stub_rest_generator.cc @@ -29,10 +29,12 @@ StubRestGenerator::StubRestGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) : ServiceCodeGenerator("stub_rest_header_path", "stub_rest_cc_path", service_descriptor, std::move(service_vars), - std::move(service_method_vars), context) {} + std::move(service_method_vars), context, + mixin_methods) {} Status StubRestGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); diff --git a/generator/internal/stub_rest_generator.h b/generator/internal/stub_rest_generator.h index 500721cf25c95..57390fb5f0be0 100644 --- a/generator/internal/stub_rest_generator.h +++ b/generator/internal/stub_rest_generator.h @@ -38,7 +38,8 @@ class StubRestGenerator : public ServiceCodeGenerator { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~StubRestGenerator() override = default; diff --git a/generator/internal/tracing_connection_generator.cc b/generator/internal/tracing_connection_generator.cc index e6452fd1e0497..39cd4118222b2 100644 --- a/generator/internal/tracing_connection_generator.cc +++ b/generator/internal/tracing_connection_generator.cc @@ -29,11 +29,12 @@ TracingConnectionGenerator::TracingConnectionGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) - : ServiceCodeGenerator("tracing_connection_header_path", - "tracing_connection_cc_path", service_descriptor, - std::move(service_vars), - std::move(service_method_vars), context) {} + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) + : ServiceCodeGenerator( + "tracing_connection_header_path", "tracing_connection_cc_path", + service_descriptor, std::move(service_vars), + std::move(service_method_vars), context, mixin_methods) {} Status TracingConnectionGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); diff --git a/generator/internal/tracing_connection_generator.h b/generator/internal/tracing_connection_generator.h index a7322e0e37a81..be41da7133a87 100644 --- a/generator/internal/tracing_connection_generator.h +++ b/generator/internal/tracing_connection_generator.h @@ -38,7 +38,8 @@ class TracingConnectionGenerator : public ServiceCodeGenerator { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~TracingConnectionGenerator() override = default; diff --git a/generator/internal/tracing_stub_generator.cc b/generator/internal/tracing_stub_generator.cc index 675f60105cbc0..84ef4f1880aa4 100644 --- a/generator/internal/tracing_stub_generator.cc +++ b/generator/internal/tracing_stub_generator.cc @@ -25,10 +25,12 @@ TracingStubGenerator::TracingStubGenerator( google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context) + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods) : StubGeneratorBase("tracing_stub_header_path", "tracing_stub_cc_path", service_descriptor, std::move(service_vars), - std::move(service_method_vars), context) {} + std::move(service_method_vars), context, + mixin_methods) {} Status TracingStubGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); diff --git a/generator/internal/tracing_stub_generator.h b/generator/internal/tracing_stub_generator.h index 4812056e7d05a..0897488c1b7a6 100644 --- a/generator/internal/tracing_stub_generator.h +++ b/generator/internal/tracing_stub_generator.h @@ -36,7 +36,8 @@ class TracingStubGenerator : public StubGeneratorBase { google::protobuf::ServiceDescriptor const* service_descriptor, VarsDictionary service_vars, std::map service_method_vars, - google::protobuf::compiler::GeneratorContext* context); + google::protobuf::compiler::GeneratorContext* context, + std::vector const& mixin_methods); ~TracingStubGenerator() override = default; diff --git a/generator/standalone_main.cc b/generator/standalone_main.cc index 26a3210e33721..28e28183765be 100644 --- a/generator/standalone_main.cc +++ b/generator/standalone_main.cc @@ -18,6 +18,7 @@ #include "generator/internal/descriptor_utils.h" #include "generator/internal/discovery_to_proto.h" #include "generator/internal/format_method_comments.h" +#include "generator/internal/mixin_utils.h" #include "generator/internal/scaffold_generator.h" #include "google/cloud/internal/absl_str_cat_quiet.h" #include "google/cloud/internal/absl_str_join_quiet.h" @@ -70,6 +71,7 @@ using ::google::cloud::generator_internal::CheckMethodCommentSubstitutions; using ::google::cloud::generator_internal::CheckParameterCommentSubstitutions; using ::google::cloud::generator_internal::GenerateMetadata; using ::google::cloud::generator_internal::GenerateScaffold; +using ::google::cloud::generator_internal::GetMixinProtoPaths; using ::google::cloud::generator_internal::LibraryName; using ::google::cloud::generator_internal::LibraryPath; using ::google::cloud::generator_internal::LoadApiIndex; @@ -370,6 +372,20 @@ std::vector> GenerateCodeFromProtos( if (!path.empty()) { args.emplace_back(absl::StrCat("--cpp_codegen_opt=service_config_yaml=", std::move(path))); + if (service.service_proto_path() == + "google/cloud/clouddms/v1/clouddms.proto") { + std::vector const mixin_proto_paths = + GetMixinProtoPaths(path); + + std::cout << "-----------------------------" + << service.service_proto_path() << std::endl; + for (auto const& mixin_proto_path : mixin_proto_paths) { + std::cout << mixin_proto_path << std::endl; + args.emplace_back("--cpp_codegen_opt=additional_proto_file=" + + mixin_proto_path); + } + std::cout << "-----------------------------" << std::endl; + } } GCP_LOG(INFO) << "Generating service code using: " diff --git a/google/cloud/datamigration/v1/data_migration_client.cc b/google/cloud/datamigration/v1/data_migration_client.cc index 7abc948a2e3b9..93200e7b4c75e 100644 --- a/google/cloud/datamigration/v1/data_migration_client.cc +++ b/google/cloud/datamigration/v1/data_migration_client.cc @@ -1110,6 +1110,20 @@ StreamRange DataMigrationServiceClient::FetchStaticIps( return connection_->FetchStaticIps(std::move(request)); } +StreamRange +DataMigrationServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +DataMigrationServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datamigration_v1 } // namespace cloud diff --git a/google/cloud/datamigration/v1/data_migration_client.h b/google/cloud/datamigration/v1/data_migration_client.h index 189b3e4236a5a..6f15df2721d8a 100644 --- a/google/cloud/datamigration/v1/data_migration_client.h +++ b/google/cloud/datamigration/v1/data_migration_client.h @@ -3273,6 +3273,76 @@ class DataMigrationServiceClient { google::cloud::clouddms::v1::FetchStaticIpsRequest request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/datamigration/v1/data_migration_connection.cc b/google/cloud/datamigration/v1/data_migration_connection.cc index bef403aa3cea0..b16503d49f37d 100644 --- a/google/cloud/datamigration/v1/data_migration_connection.cc +++ b/google/cloud/datamigration/v1/data_migration_connection.cc @@ -704,6 +704,20 @@ StreamRange DataMigrationServiceConnection::FetchStaticIps( StreamRange>(); } +StreamRange +DataMigrationServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DataMigrationServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDataMigrationServiceConnection(Options options) { internal::CheckExpectedOptions +#include #include #include @@ -539,6 +540,12 @@ class DataMigrationServiceConnection { virtual StreamRange FetchStaticIps( google::cloud::clouddms::v1::FetchStaticIpsRequest request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/datamigration/v1/data_migration_connection_idempotency_policy.cc b/google/cloud/datamigration/v1/data_migration_connection_idempotency_policy.cc index 237529d1dda8a..7ea7f7e1caaee 100644 --- a/google/cloud/datamigration/v1/data_migration_connection_idempotency_policy.cc +++ b/google/cloud/datamigration/v1/data_migration_connection_idempotency_policy.cc @@ -266,6 +266,16 @@ Idempotency DataMigrationServiceConnectionIdempotencyPolicy::FetchStaticIps( return Idempotency::kIdempotent; } +Idempotency DataMigrationServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DataMigrationServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultDataMigrationServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/datamigration/v1/data_migration_connection_idempotency_policy.h b/google/cloud/datamigration/v1/data_migration_connection_idempotency_policy.h index 9460da30f8e13..e9cc47ace9333 100644 --- a/google/cloud/datamigration/v1/data_migration_connection_idempotency_policy.h +++ b/google/cloud/datamigration/v1/data_migration_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -175,6 +176,12 @@ class DataMigrationServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency FetchStaticIps( google::cloud::clouddms::v1::FetchStaticIpsRequest request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/datamigration/v1/internal/data_migration_auth_decorator.cc b/google/cloud/datamigration/v1/internal/data_migration_auth_decorator.cc index 16c53499dfca3..f0ead4edd2c9a 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_auth_decorator.cc +++ b/google/cloud/datamigration/v1/internal/data_migration_auth_decorator.cc @@ -890,6 +890,24 @@ DataMigrationServiceAuth::FetchStaticIps( return child_->FetchStaticIps(context, options, request); } +StatusOr +DataMigrationServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +DataMigrationServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> DataMigrationServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datamigration/v1/internal/data_migration_auth_decorator.h b/google/cloud/datamigration/v1/internal/data_migration_auth_decorator.h index af726a20955f6..0c8558e68f285 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_auth_decorator.h +++ b/google/cloud/datamigration/v1/internal/data_migration_auth_decorator.h @@ -420,6 +420,14 @@ class DataMigrationServiceAuth : public DataMigrationServiceStub { google::cloud::clouddms::v1::FetchStaticIpsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datamigration/v1/internal/data_migration_connection_impl.cc b/google/cloud/datamigration/v1/internal/data_migration_connection_impl.cc index 65839e58ef177..5d8f2af406df6 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_connection_impl.cc +++ b/google/cloud/datamigration/v1/internal/data_migration_connection_impl.cc @@ -2657,6 +2657,55 @@ StreamRange DataMigrationServiceConnectionImpl::FetchStaticIps( }); } +StreamRange +DataMigrationServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = + std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DataMigrationServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datamigration_v1_internal } // namespace cloud diff --git a/google/cloud/datamigration/v1/internal/data_migration_connection_impl.h b/google/cloud/datamigration/v1/internal/data_migration_connection_impl.h index 7ece5cafa9455..23a61255fa821 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_connection_impl.h +++ b/google/cloud/datamigration/v1/internal/data_migration_connection_impl.h @@ -439,6 +439,12 @@ class DataMigrationServiceConnectionImpl StreamRange FetchStaticIps( google::cloud::clouddms::v1::FetchStaticIpsRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/datamigration/v1/internal/data_migration_logging_decorator.cc b/google/cloud/datamigration/v1/internal/data_migration_logging_decorator.cc index 6635cde73fa52..4a8d1d35b09e7 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_logging_decorator.cc +++ b/google/cloud/datamigration/v1/internal/data_migration_logging_decorator.cc @@ -1047,6 +1047,30 @@ DataMigrationServiceLogging::FetchStaticIps( context, options, request, __func__, tracing_options_); } +StatusOr +DataMigrationServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataMigrationServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> DataMigrationServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datamigration/v1/internal/data_migration_logging_decorator.h b/google/cloud/datamigration/v1/internal/data_migration_logging_decorator.h index 8137deb98d43b..defdb92bce389 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_logging_decorator.h +++ b/google/cloud/datamigration/v1/internal/data_migration_logging_decorator.h @@ -420,6 +420,14 @@ class DataMigrationServiceLogging : public DataMigrationServiceStub { google::cloud::clouddms::v1::FetchStaticIpsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datamigration/v1/internal/data_migration_metadata_decorator.cc b/google/cloud/datamigration/v1/internal/data_migration_metadata_decorator.cc index cf60dd518a133..3a30c488b9504 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_metadata_decorator.cc +++ b/google/cloud/datamigration/v1/internal/data_migration_metadata_decorator.cc @@ -739,6 +739,24 @@ DataMigrationServiceMetadata::FetchStaticIps( return child_->FetchStaticIps(context, options, request); } +StatusOr +DataMigrationServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +DataMigrationServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> DataMigrationServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datamigration/v1/internal/data_migration_metadata_decorator.h b/google/cloud/datamigration/v1/internal/data_migration_metadata_decorator.h index cb48d1d963bd7..f3826d572288c 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_metadata_decorator.h +++ b/google/cloud/datamigration/v1/internal/data_migration_metadata_decorator.h @@ -421,6 +421,14 @@ class DataMigrationServiceMetadata : public DataMigrationServiceStub { google::cloud::clouddms::v1::FetchStaticIpsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datamigration/v1/internal/data_migration_stub.cc b/google/cloud/datamigration/v1/internal/data_migration_stub.cc index e050dbd5f3b50..2b5f63b897677 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_stub.cc +++ b/google/cloud/datamigration/v1/internal/data_migration_stub.cc @@ -1018,6 +1018,30 @@ DefaultDataMigrationServiceStub::FetchStaticIps( return response; } +StatusOr +DefaultDataMigrationServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = grpc_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataMigrationServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = grpc_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultDataMigrationServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datamigration/v1/internal/data_migration_stub.h b/google/cloud/datamigration/v1/internal/data_migration_stub.h index ac88f9f3cced8..52607a4f03f16 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_stub.h +++ b/google/cloud/datamigration/v1/internal/data_migration_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -431,6 +432,15 @@ class DataMigrationServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::clouddms::v1::FetchStaticIpsRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -835,6 +845,14 @@ class DefaultDataMigrationServiceStub : public DataMigrationServiceStub { google::cloud::clouddms::v1::FetchStaticIpsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datamigration/v1/internal/data_migration_tracing_connection.cc b/google/cloud/datamigration/v1/internal/data_migration_tracing_connection.cc index ed63cbb3af2cd..7dc2bc3f4d7a3 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_tracing_connection.cc +++ b/google/cloud/datamigration/v1/internal/data_migration_tracing_connection.cc @@ -998,6 +998,26 @@ StreamRange DataMigrationServiceTracingConnection::FetchStaticIps( std::move(sr)); } +StreamRange +DataMigrationServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "datamigration_v1::DataMigrationServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DataMigrationServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "datamigration_v1::DataMigrationServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/datamigration/v1/internal/data_migration_tracing_connection.h b/google/cloud/datamigration/v1/internal/data_migration_tracing_connection.h index 36b76f4c0b405..90a3a8c04a8aa 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_tracing_connection.h +++ b/google/cloud/datamigration/v1/internal/data_migration_tracing_connection.h @@ -427,6 +427,12 @@ class DataMigrationServiceTracingConnection StreamRange FetchStaticIps( google::cloud::clouddms::v1::FetchStaticIpsRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/datamigration/v1/internal/data_migration_tracing_stub.cc b/google/cloud/datamigration/v1/internal/data_migration_tracing_stub.cc index 695e627426760..62f11ee123fb1 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_tracing_stub.cc +++ b/google/cloud/datamigration/v1/internal/data_migration_tracing_stub.cc @@ -951,6 +951,30 @@ DataMigrationServiceTracingStub::FetchStaticIps( child_->FetchStaticIps(context, options, request)); } +StatusOr +DataMigrationServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.clouddms.v1.DataMigrationService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +DataMigrationServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.clouddms.v1.DataMigrationService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> DataMigrationServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datamigration/v1/internal/data_migration_tracing_stub.h b/google/cloud/datamigration/v1/internal/data_migration_tracing_stub.h index 642a4cc90c43e..78876e20a49f0 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_tracing_stub.h +++ b/google/cloud/datamigration/v1/internal/data_migration_tracing_stub.h @@ -420,6 +420,14 @@ class DataMigrationServiceTracingStub : public DataMigrationServiceStub { google::cloud::clouddms::v1::FetchStaticIpsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datamigration/v1/mocks/mock_data_migration_connection.h b/google/cloud/datamigration/v1/mocks/mock_data_migration_connection.h index 77de8d82f462a..2a665f2d3f64f 100644 --- a/google/cloud/datamigration/v1/mocks/mock_data_migration_connection.h +++ b/google/cloud/datamigration/v1/mocks/mock_data_migration_connection.h @@ -1090,6 +1090,14 @@ class MockDataMigrationServiceConnection MOCK_METHOD((StreamRange), FetchStaticIps, (google::cloud::clouddms::v1::FetchStaticIpsRequest request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END From 83ac54d909a7c4bbae6c47756ceba6de78462128 Mon Sep 17 00:00:00 2001 From: Yao Cui Date: Tue, 13 Aug 2024 18:00:36 +0000 Subject: [PATCH 2/8] except stub and stubfactory --- generator/internal/mixin_utils.cc | 197 ++++++++++-------- generator/internal/mixin_utils.h | 20 +- generator/internal/stub_factory_generator.cc | 7 +- generator/internal/stub_generator.cc | 4 + .../v1/internal/data_migration_stub.h | 1 + .../internal/data_migration_stub_factory.cc | 1 + 6 files changed, 129 insertions(+), 101 deletions(-) diff --git a/generator/internal/mixin_utils.cc b/generator/internal/mixin_utils.cc index e89b8303701e9..245003df427da 100644 --- a/generator/internal/mixin_utils.cc +++ b/generator/internal/mixin_utils.cc @@ -1,17 +1,17 @@ #include "generator/internal/mixin_utils.h" +#include "google/cloud/log.h" +#include "absl/types/optional.h" #include -#include -#include -#include #include #include -#include "google/cloud/log.h" -#include "absl/types/optional.h" +#include +#include +#include +using ::google::protobuf::DescriptorPool; using ::google::protobuf::FileDescriptor; -using ::google::protobuf::ServiceDescriptor; using ::google::protobuf::MethodDescriptor; -using ::google::protobuf::DescriptorPool; +using ::google::protobuf::ServiceDescriptor; namespace google { namespace cloud { @@ -19,108 +19,125 @@ namespace generator_internal { namespace { std::unordered_map mixin_proto_path_map = { - {"google.cloud.location.Locations", "google/cloud/location/locations.proto"}, + {"google.cloud.location.Locations", + "google/cloud/location/locations.proto"}, // {"google.iam.v1.IAMPolicy", "google/iam/v1/iam_policy.proto"}, // {"google.longrunning.Operations", "google/longrunning/operations.proto"}, }; -std::unordered_set http_verbs = {"get", "post", "put", "patch", "delete"}; - -std::unordered_map GetMixinMethodOverrides(YAML::Node const& service_config) { - std::unordered_map mixin_method_overrides; - if (service_config.Type() != YAML::NodeType::Map) return mixin_method_overrides; - auto const& http = service_config["http"]; - if (http.Type() != YAML::NodeType::Map) return mixin_method_overrides; - auto const& rules = http["rules"]; - if (rules.Type() != YAML::NodeType::Sequence) return mixin_method_overrides; - for (auto const& rule : rules) { - if (rule.Type() != YAML::NodeType::Map) continue; - - auto const& selector = rule["selector"]; - if (selector.Type() != YAML::NodeType::Scalar) continue; - std::string method_full_name = selector.as(); - - for (auto const& kv : rule) { - if (kv.first.Type() != YAML::NodeType::Scalar || kv.second.Type() != YAML::NodeType::Scalar) continue; - - std::string http_verb = kv.first.as(); - if (http_verbs.find(http_verb) == http_verbs.end()) continue; - std::string http_path = kv.second.as(); - - absl::optional http_body; - if (rule["body"]) { - http_body = rule["body"].as(); - } - mixin_method_overrides[method_full_name] = MixinMethodOverride{http_verb, http_path, http_body}; - } - } +std::unordered_set http_verbs = {"get", "post", "put", "patch", + "delete"}; + +std::unordered_map GetMixinMethodOverrides( + YAML::Node const& service_config) { + std::unordered_map mixin_method_overrides; + if (service_config.Type() != YAML::NodeType::Map) return mixin_method_overrides; + auto const& http = service_config["http"]; + if (http.Type() != YAML::NodeType::Map) return mixin_method_overrides; + auto const& rules = http["rules"]; + if (rules.Type() != YAML::NodeType::Sequence) return mixin_method_overrides; + for (auto const& rule : rules) { + if (rule.Type() != YAML::NodeType::Map) continue; + + auto const& selector = rule["selector"]; + if (selector.Type() != YAML::NodeType::Scalar) continue; + std::string method_full_name = selector.as(); + + for (auto const& kv : rule) { + if (kv.first.Type() != YAML::NodeType::Scalar || + kv.second.Type() != YAML::NodeType::Scalar) + continue; + + std::string http_verb = kv.first.as(); + if (http_verbs.find(http_verb) == http_verbs.end()) continue; + std::string http_path = kv.second.as(); + + absl::optional http_body; + if (rule["body"]) { + http_body = rule["body"].as(); + } + mixin_method_overrides[method_full_name] = + MixinMethodOverride{http_verb, http_path, http_body}; + } + } + return mixin_method_overrides; } -std::unordered_map GetDedupedMixinMethodOverrides(YAML::Node const& service_config, ServiceDescriptor const& service) { - auto mixin_method_overrides = GetMixinMethodOverrides(service_config); - for (int i = 0; i < service.method_count(); ++i) { - auto const* method = service.method(i); - auto method_full_name = method->full_name(); - if (mixin_method_overrides.find(method_full_name) != mixin_method_overrides.end()) { - mixin_method_overrides.erase(method_full_name); - } +std::unordered_map +GetDedupedMixinMethodOverrides(YAML::Node const& service_config, + ServiceDescriptor const& service) { + auto mixin_method_overrides = GetMixinMethodOverrides(service_config); + for (int i = 0; i < service.method_count(); ++i) { + auto const* method = service.method(i); + auto method_full_name = method->full_name(); + if (mixin_method_overrides.find(method_full_name) != + mixin_method_overrides.end()) { + mixin_method_overrides.erase(method_full_name); } - return mixin_method_overrides; + } + return mixin_method_overrides; } -} // namespace +} // namespace std::vector GetMixinProtoPaths(YAML::Node const& service_config) { - std::vector proto_paths; - if (service_config.Type() != YAML::NodeType::Map) return proto_paths; - auto const& apis = service_config["apis"]; - if (apis.Type() != YAML::NodeType::Sequence) return proto_paths; - for (auto const& api : apis) { - if (api.Type() != YAML::NodeType::Map) continue; - auto const& name = api["name"]; - if (name.Type() != YAML::NodeType::Scalar) continue; - std::string package_path = name.as(); - if (mixin_proto_path_map.find(package_path) == mixin_proto_path_map.end()) continue; - proto_paths.push_back(mixin_proto_path_map[package_path]); - } - return proto_paths; + std::vector proto_paths; + if (service_config.Type() != YAML::NodeType::Map) return proto_paths; + auto const& apis = service_config["apis"]; + if (apis.Type() != YAML::NodeType::Sequence) return proto_paths; + for (auto const& api : apis) { + if (api.Type() != YAML::NodeType::Map) continue; + auto const& name = api["name"]; + if (name.Type() != YAML::NodeType::Scalar) continue; + std::string package_path = name.as(); + if (mixin_proto_path_map.find(package_path) == mixin_proto_path_map.end()) + continue; + proto_paths.push_back(mixin_proto_path_map[package_path]); + } + return proto_paths; } std::vector GetMixinProtoPaths(std::string& service_yaml_path) { - YAML::Node service_config = YAML::LoadFile(service_yaml_path); - return GetMixinProtoPaths(service_config); + YAML::Node service_config = YAML::LoadFile(service_yaml_path); + return GetMixinProtoPaths(service_config); } -std::vector GetMixinMethods( - YAML::Node const& service_config, ServiceDescriptor const& service) { - std::vector mixin_methods; - DescriptorPool const* pool = service.file()->pool(); - if (pool == nullptr) { - GCP_LOG(FATAL) << __FILE__ << ":" << __LINE__ - << " DescriptorPool doesn't exist for service: " << service.full_name(); - } - auto mixin_proto_paths = GetMixinProtoPaths(service_config); - auto mixin_method_overrides = GetDedupedMixinMethodOverrides(service_config, service); - - for (auto const& mixin_proto_path : mixin_proto_paths) { - FileDescriptor const* mixin_file = pool->FindFileByName(mixin_proto_path); - if (mixin_file == nullptr) { - GCP_LOG(FATAL) << __FILE__ << ":" << __LINE__ - << " Mixin FileDescriptor is not found for path: " << mixin_proto_path +std::vector GetMixinMethods(YAML::Node const& service_config, + ServiceDescriptor const& service) { + std::vector mixin_methods; + DescriptorPool const* pool = service.file()->pool(); + if (pool == nullptr) { + GCP_LOG(FATAL) << __FILE__ << ":" << __LINE__ + << " DescriptorPool doesn't exist for service: " + << service.full_name(); + } + auto mixin_proto_paths = GetMixinProtoPaths(service_config); + auto mixin_method_overrides = + GetDedupedMixinMethodOverrides(service_config, service); + + for (auto const& mixin_proto_path : mixin_proto_paths) { + FileDescriptor const* mixin_file = pool->FindFileByName(mixin_proto_path); + if (mixin_file == nullptr) { + GCP_LOG(FATAL) << __FILE__ << ":" << __LINE__ + << " Mixin FileDescriptor is not found for path: " + << mixin_proto_path << " in service: " << service.full_name(); - } - for (int i = 0; i < mixin_file->service_count(); ++i) { - ServiceDescriptor const* mixin_service = mixin_file->service(i); - for (int j = 0; j < mixin_service->method_count(); ++j) { - MethodDescriptor const* mixin_method = mixin_service->method(j); - auto mixin_method_full_name = mixin_method->full_name(); - if (mixin_method_overrides.find(mixin_method_full_name) == mixin_method_overrides.end()) continue; - mixin_methods.push_back({*mixin_method, mixin_method_overrides[mixin_method_full_name]}); - } - } } - return mixin_methods; + for (int i = 0; i < mixin_file->service_count(); ++i) { + ServiceDescriptor const* mixin_service = mixin_file->service(i); + for (int j = 0; j < mixin_service->method_count(); ++j) { + MethodDescriptor const* mixin_method = mixin_service->method(j); + auto mixin_method_full_name = mixin_method->full_name(); + if (mixin_method_overrides.find(mixin_method_full_name) == + mixin_method_overrides.end()) + continue; + mixin_methods.push_back( + {*mixin_method, mixin_method_overrides[mixin_method_full_name]}); + } + } + } + return mixin_methods; } } // namespace generator_internal diff --git a/generator/internal/mixin_utils.h b/generator/internal/mixin_utils.h index b33cfbae783c6..ac1a9a4584481 100644 --- a/generator/internal/mixin_utils.h +++ b/generator/internal/mixin_utils.h @@ -15,26 +15,25 @@ #ifndef GOOGLE_CLOUD_CPP_GENERATOR_INTERNAL_MIXIN_UTILS_H #define GOOGLE_CLOUD_CPP_GENERATOR_INTERNAL_MIXIN_UTILS_H -#include -#include #include "absl/types/optional.h" -#include #include - +#include +#include +#include namespace google { namespace cloud { namespace generator_internal { struct MixinMethodOverride { - std::string http_verb; - std::string http_path; - absl::optional http_body; + std::string http_verb; + std::string http_path; + absl::optional http_body; }; struct MixinMethod { - std::reference_wrapper method; - MixinMethodOverride method_override; + std::reference_wrapper method; + MixinMethodOverride method_override; }; std::vector GetMixinProtoPaths(YAML::Node const& service_config); @@ -42,7 +41,8 @@ std::vector GetMixinProtoPaths(YAML::Node const& service_config); std::vector GetMixinProtoPaths(std::string& service_yaml_path); std::vector GetMixinMethods( - YAML::Node const& service_config, google::protobuf::ServiceDescriptor const& service); + YAML::Node const& service_config, + google::protobuf::ServiceDescriptor const& service); } // namespace generator_internal } // namespace cloud diff --git a/generator/internal/stub_factory_generator.cc b/generator/internal/stub_factory_generator.cc index e3695b3a1cb53..79dd6e5af10c9 100644 --- a/generator/internal/stub_factory_generator.cc +++ b/generator/internal/stub_factory_generator.cc @@ -15,6 +15,7 @@ #include "generator/internal/stub_factory_generator.h" #include "generator/internal/codegen_utils.h" #include "generator/internal/printer.h" +#include "absl/strings/str_split.h" #include namespace google { @@ -86,7 +87,11 @@ Status StubFactoryGenerator::GenerateCc() { "google/cloud/internal/algorithm.h", "google/cloud/internal/opentelemetry.h", "google/cloud/options.h", "google/cloud/log.h"}); - CcSystemIncludes({vars("proto_grpc_header_path"), "memory", "utility"}); + std::vector headers = + absl::StrSplit(vars("mixin_proto_grpc_header_paths"), ","); + headers.insert(headers.end(), + {vars("proto_grpc_header_path"), "memory", "utility"}); + CcSystemIncludes(headers); auto result = CcOpenNamespaces(NamespaceType::kInternal); if (!result.ok()) return result; diff --git a/generator/internal/stub_generator.cc b/generator/internal/stub_generator.cc index af3098fe6d2db..1b38af2e23614 100644 --- a/generator/internal/stub_generator.cc +++ b/generator/internal/stub_generator.cc @@ -21,6 +21,7 @@ #include "google/cloud/internal/absl_str_cat_quiet.h" #include "absl/strings/str_split.h" #include +#include namespace google { namespace cloud { @@ -73,6 +74,9 @@ Status StubGenerator::GenerateHeader() { std::vector additional_pb_header_paths = absl::StrSplit(vars("additional_pb_header_paths"), absl::ByChar(',')); HeaderSystemIncludes(additional_pb_header_paths); + std::vector mixin_headers = + absl::StrSplit(vars("mixin_proto_grpc_header_paths"), ","); + HeaderSystemIncludes(mixin_headers); HeaderSystemIncludes( {vars("proto_grpc_header_path"), HasLongrunningMethod() ? "google/longrunning/operations.grpc.pb.h" : "", diff --git a/google/cloud/datamigration/v1/internal/data_migration_stub.h b/google/cloud/datamigration/v1/internal/data_migration_stub.h index 52607a4f03f16..96dae4d79c0c5 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_stub.h +++ b/google/cloud/datamigration/v1/internal/data_migration_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include diff --git a/google/cloud/datamigration/v1/internal/data_migration_stub_factory.cc b/google/cloud/datamigration/v1/internal/data_migration_stub_factory.cc index bb3630665cb4f..7e340e5cd2163 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_stub_factory.cc +++ b/google/cloud/datamigration/v1/internal/data_migration_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include From 5ddde991a073f872b55fcc729ecfd71ba108c14d Mon Sep 17 00:00:00 2001 From: Yao Cui Date: Tue, 13 Aug 2024 18:56:59 +0000 Subject: [PATCH 3/8] . --- generator/internal/make_generators.cc | 2 ++ generator/internal/mixin_utils.cc | 6 +++++- generator/internal/mixin_utils.h | 2 ++ generator/internal/stub_factory_generator.cc | 2 +- generator/internal/stub_generator.cc | 7 ++++++- generator/internal/stub_generator.h | 1 + 6 files changed, 17 insertions(+), 3 deletions(-) diff --git a/generator/internal/make_generators.cc b/generator/internal/make_generators.cc index 9ec01a8d04cb6..f999eb3c14ba5 100644 --- a/generator/internal/make_generators.cc +++ b/generator/internal/make_generators.cc @@ -69,6 +69,8 @@ std::vector> MakeGenerators( absl::optional body = mixin_method.method_override.http_body; std::cout << mixin_method.method.get().full_name() << " " + << mixin_method.grpc_stub_fqn << " " + << mixin_method.grpc_stub_name << " " << mixin_method.method_override.http_verb << " " << mixin_method.method_override.http_path << " " << (body.has_value() ? *body : "") << std::endl; diff --git a/generator/internal/mixin_utils.cc b/generator/internal/mixin_utils.cc index 245003df427da..f2e2b93a1b557 100644 --- a/generator/internal/mixin_utils.cc +++ b/generator/internal/mixin_utils.cc @@ -1,5 +1,7 @@ #include "generator/internal/mixin_utils.h" +#include "generator/internal/codegen_utils.h" #include "google/cloud/log.h" +#include "absl/strings/ascii.h" #include "absl/types/optional.h" #include #include @@ -133,7 +135,9 @@ std::vector GetMixinMethods(YAML::Node const& service_config, mixin_method_overrides.end()) continue; mixin_methods.push_back( - {*mixin_method, mixin_method_overrides[mixin_method_full_name]}); + {absl::AsciiStrToLower(mixin_service->name()) + "_stub", + ProtoNameToCppName(mixin_service->full_name()), *mixin_method, + mixin_method_overrides[mixin_method_full_name]}); } } } diff --git a/generator/internal/mixin_utils.h b/generator/internal/mixin_utils.h index ac1a9a4584481..45bc7c7aad722 100644 --- a/generator/internal/mixin_utils.h +++ b/generator/internal/mixin_utils.h @@ -32,6 +32,8 @@ struct MixinMethodOverride { }; struct MixinMethod { + std::string grpc_stub_name; + std::string grpc_stub_fqn; std::reference_wrapper method; MixinMethodOverride method_override; }; diff --git a/generator/internal/stub_factory_generator.cc b/generator/internal/stub_factory_generator.cc index 79dd6e5af10c9..f0f8cd5a54291 100644 --- a/generator/internal/stub_factory_generator.cc +++ b/generator/internal/stub_factory_generator.cc @@ -90,7 +90,7 @@ Status StubFactoryGenerator::GenerateCc() { std::vector headers = absl::StrSplit(vars("mixin_proto_grpc_header_paths"), ","); headers.insert(headers.end(), - {vars("proto_grpc_header_path"), "memory", "utility"}); + {vars("proto_grpc_header_path"), "memory", "utility"}); CcSystemIncludes(headers); auto result = CcOpenNamespaces(NamespaceType::kInternal); diff --git a/generator/internal/stub_generator.cc b/generator/internal/stub_generator.cc index 1b38af2e23614..e88e2a4404e42 100644 --- a/generator/internal/stub_generator.cc +++ b/generator/internal/stub_generator.cc @@ -35,7 +35,8 @@ StubGenerator::StubGenerator( std::vector const& mixin_methods) : StubGeneratorBase("stub_header_path", "stub_cc_path", service_descriptor, std::move(service_vars), std::move(service_method_vars), - context, mixin_methods) {} + context, mixin_methods), + mixin_methods_(mixin_methods) {} Status StubGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); @@ -236,6 +237,10 @@ Status StubGenerator::GenerateHeader() { "\n" "class Default$stub_class_name$ : public $stub_class_name$ {\n" " public:"); + // std::string mixin_stub = ""; + // for (auto const& mixin_method : mixin_methods_) { + // mixin_stub += ",\n " + mixin_method.grpc_stub_name + "_(std::move" + // } if (HasLongrunningMethod()) { HeaderPrint( // clang-format off "\n" diff --git a/generator/internal/stub_generator.h b/generator/internal/stub_generator.h index 5f46a6fdba169..3f1c3df3c6f61 100644 --- a/generator/internal/stub_generator.h +++ b/generator/internal/stub_generator.h @@ -51,6 +51,7 @@ class StubGenerator : public StubGeneratorBase { private: Status GenerateHeader() override; Status GenerateCc() override; + std::vector mixin_methods_; }; } // namespace generator_internal From 9d3f524d2135b0f6ff95f91f2baf4dfca67f9a8b Mon Sep 17 00:00:00 2001 From: Yao Cui Date: Wed, 14 Aug 2024 16:30:06 +0000 Subject: [PATCH 4/8] stub stubfactory http mixin --- generator/internal/descriptor_utils.cc | 5 +- generator/internal/http_option_utils.cc | 56 +++--- generator/internal/http_option_utils.h | 5 +- generator/internal/mixin_utils.cc | 10 +- generator/internal/service_code_generator.cc | 2 - generator/internal/stub_factory_generator.cc | 34 +++- generator/internal/stub_factory_generator.h | 1 + generator/internal/stub_generator.cc | 170 ++++++++++++------ .../v1/internal/data_migration_stub.cc | 4 +- .../v1/internal/data_migration_stub.h | 8 +- .../internal/data_migration_stub_factory.cc | 4 +- 11 files changed, 195 insertions(+), 104 deletions(-) diff --git a/generator/internal/descriptor_utils.cc b/generator/internal/descriptor_utils.cc index 622bfed1b7d07..31cf5d884b0da 100644 --- a/generator/internal/descriptor_utils.cc +++ b/generator/internal/descriptor_utils.cc @@ -889,14 +889,13 @@ std::map CreateMethodVars( SetLongrunningOperationMethodVars(method, method_vars); AssignPaginationMethodVars(method, method_vars); SetMethodSignatureMethodVars(service, method, omitted_rpcs, method_vars); - auto parsed_http_info = ParseHttpExtension(method); + auto parsed_http_info = + ParseHttpExtension(method, mixin_method.method_override); method_vars["request_resource"] = FormatRequestResource(*method.input_type(), parsed_http_info); SetHttpDerivedMethodVars(parsed_http_info, method, method_vars); SetHttpQueryParameters(parsed_http_info, method, method_vars); service_methods_vars[method.full_name()] = method_vars; - std::cout << "*******************************" << method.full_name() - << std::endl; } return service_methods_vars; } diff --git a/generator/internal/http_option_utils.cc b/generator/internal/http_option_utils.cc index 2687ec47a7216..2104d2c0ddde2 100644 --- a/generator/internal/http_option_utils.cc +++ b/generator/internal/http_option_utils.cc @@ -263,7 +263,8 @@ void SetHttpQueryParameters(HttpExtensionInfo const& info, } HttpExtensionInfo ParseHttpExtension( - google::protobuf::MethodDescriptor const& method) { + google::protobuf::MethodDescriptor const& method, + absl::optional method_override) { if (!method.options().HasExtension(google::api::http)) return {}; HttpExtensionInfo info; @@ -271,30 +272,35 @@ HttpExtensionInfo ParseHttpExtension( method.options().GetExtension(google::api::http); std::string url_pattern; - switch (http_rule.pattern_case()) { - case google::api::HttpRule::kGet: - info.http_verb = "Get"; - url_pattern = http_rule.get(); - break; - case google::api::HttpRule::kPut: - info.http_verb = "Put"; - url_pattern = http_rule.put(); - break; - case google::api::HttpRule::kPost: - info.http_verb = "Post"; - url_pattern = http_rule.post(); - break; - case google::api::HttpRule::kDelete: - info.http_verb = "Delete"; - url_pattern = http_rule.delete_(); - break; - case google::api::HttpRule::kPatch: - info.http_verb = "Patch"; - url_pattern = http_rule.patch(); - break; - default: - GCP_LOG(FATAL) << __FILE__ << ":" << __LINE__ - << ": google::api::HttpRule not handled"; + if (method_override) { + url_pattern = method_override->http_path; + info.http_verb = method_override->http_verb; + } else { + switch (http_rule.pattern_case()) { + case google::api::HttpRule::kGet: + info.http_verb = "Get"; + url_pattern = http_rule.get(); + break; + case google::api::HttpRule::kPut: + info.http_verb = "Put"; + url_pattern = http_rule.put(); + break; + case google::api::HttpRule::kPost: + info.http_verb = "Post"; + url_pattern = http_rule.post(); + break; + case google::api::HttpRule::kDelete: + info.http_verb = "Delete"; + url_pattern = http_rule.delete_(); + break; + case google::api::HttpRule::kPatch: + info.http_verb = "Patch"; + url_pattern = http_rule.patch(); + break; + default: + GCP_LOG(FATAL) << __FILE__ << ":" << __LINE__ + << ": google::api::HttpRule not handled"; + } } auto parsed_http_rule = ParsePathTemplate(url_pattern); diff --git a/generator/internal/http_option_utils.h b/generator/internal/http_option_utils.h index 1d9975d432fa2..5117d7152a893 100644 --- a/generator/internal/http_option_utils.h +++ b/generator/internal/http_option_utils.h @@ -16,7 +16,9 @@ #define GOOGLE_CLOUD_CPP_GENERATOR_INTERNAL_HTTP_OPTION_UTILS_H #include "generator/internal/http_annotation_parser.h" +#include "generator/internal/mixin_utils.h" #include "generator/internal/printer.h" +#include "absl/types/optional.h" #include #include @@ -41,7 +43,8 @@ struct HttpExtensionInfo { * transcoding and REST transport. */ HttpExtensionInfo ParseHttpExtension( - google::protobuf::MethodDescriptor const& method); + google::protobuf::MethodDescriptor const& method, + absl::optional method_override = absl::nullopt); /** * Sets the following method_vars based on the provided parsed_http_info: diff --git a/generator/internal/mixin_utils.cc b/generator/internal/mixin_utils.cc index f2e2b93a1b557..55cc53d961ca1 100644 --- a/generator/internal/mixin_utils.cc +++ b/generator/internal/mixin_utils.cc @@ -27,8 +27,10 @@ std::unordered_map mixin_proto_path_map = { // {"google.longrunning.Operations", "google/longrunning/operations.proto"}, }; -std::unordered_set http_verbs = {"get", "post", "put", "patch", - "delete"}; +std::unordered_map http_verbs = { + {"get", "Get"}, {"post", "Post"}, {"put", "Put"}, + {"patch", "Patch"}, {"delete", "Delete"}, +}; std::unordered_map GetMixinMethodOverrides( YAML::Node const& service_config) { @@ -51,8 +53,10 @@ std::unordered_map GetMixinMethodOverrides( kv.second.Type() != YAML::NodeType::Scalar) continue; - std::string http_verb = kv.first.as(); + std::string http_verb = absl::AsciiStrToLower(kv.first.as()); if (http_verbs.find(http_verb) == http_verbs.end()) continue; + http_verb = http_verbs[http_verb]; + std::string http_path = kv.second.as(); absl::optional http_body; diff --git a/generator/internal/service_code_generator.cc b/generator/internal/service_code_generator.cc index 3ad720e0fe927..fbede7a411710 100644 --- a/generator/internal/service_code_generator.cc +++ b/generator/internal/service_code_generator.cc @@ -481,8 +481,6 @@ void ServiceCodeGenerator::SetMethods() { for (auto const& mixin_method : mixin_methods_) { methods_.emplace_back(mixin_method.method.get()); - std::cout << "-----------------------" - << mixin_method.method.get().full_name() << std::endl; } } diff --git a/generator/internal/stub_factory_generator.cc b/generator/internal/stub_factory_generator.cc index f0f8cd5a54291..139258cfd2a4e 100644 --- a/generator/internal/stub_factory_generator.cc +++ b/generator/internal/stub_factory_generator.cc @@ -31,7 +31,8 @@ StubFactoryGenerator::StubFactoryGenerator( : ServiceCodeGenerator("stub_factory_header_path", "stub_factory_cc_path", service_descriptor, std::move(service_vars), std::move(service_method_vars), context, - mixin_methods) {} + mixin_methods), + mixin_methods_(mixin_methods) {} Status StubFactoryGenerator::GenerateHeader() { HeaderPrint(CopyrightLicenseFileHeader()); @@ -96,6 +97,21 @@ Status StubFactoryGenerator::GenerateCc() { auto result = CcOpenNamespaces(NamespaceType::kInternal); if (!result.ok()) return result; + std::unordered_map mixin_grpc_stubs; + for (auto const& mixin_method : mixin_methods_) { + mixin_grpc_stubs[mixin_method.grpc_stub_name] = mixin_method.grpc_stub_fqn; + } + std::string mixin_stub_inits = ""; + std::string mixin_stub_moves = ""; + for (auto const& mixin_grpc_stub : mixin_grpc_stubs) { + mixin_stub_inits += absl::StrFormat( + R"""( + auto service_%s = %s::NewStub(channel);)""", + mixin_grpc_stub.first, mixin_grpc_stub.second); + mixin_stub_moves += + absl::StrFormat(", std::move(service_%s)", mixin_grpc_stub.first); + } + // factory function implementation CcPrint(R"""( std::shared_ptr<$stub_class_name$> @@ -106,18 +122,22 @@ CreateDefault$stub_class_name$( options.get(), internal::MakeChannelArguments(options)); auto service_grpc_stub = $grpc_stub_fqn$::NewStub(channel);)"""); + CcPrint(mixin_stub_inits); + if (!HasLongrunningMethod()) { - CcPrint(R"""( + CcPrint(absl::StrFormat(R"""( std::shared_ptr<$stub_class_name$> stub = - std::make_shared(std::move(service_grpc_stub)); -)"""); + std::make_shared(std::move(service_grpc_stub)%s); +)""", + mixin_stub_moves)); } else { - CcPrint(R"""( + CcPrint(absl::StrFormat(R"""( std::shared_ptr<$stub_class_name$> stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub)%s, google::longrunning::Operations::NewStub(channel)); -)"""); +)""", + mixin_stub_moves)); } CcPrint(R"""( if (auth->RequiresConfigureContext()) { diff --git a/generator/internal/stub_factory_generator.h b/generator/internal/stub_factory_generator.h index 6c9516fb8b9d6..7feb7040614be 100644 --- a/generator/internal/stub_factory_generator.h +++ b/generator/internal/stub_factory_generator.h @@ -50,6 +50,7 @@ class StubFactoryGenerator : public ServiceCodeGenerator { private: Status GenerateHeader() override; Status GenerateCc() override; + std::vector mixin_methods_; }; } // namespace generator_internal diff --git a/generator/internal/stub_generator.cc b/generator/internal/stub_generator.cc index e88e2a4404e42..fb3339df769d4 100644 --- a/generator/internal/stub_generator.cc +++ b/generator/internal/stub_generator.cc @@ -19,6 +19,7 @@ #include "generator/internal/predicate_utils.h" #include "generator/internal/printer.h" #include "google/cloud/internal/absl_str_cat_quiet.h" +#include "absl/strings/str_format.h" #include "absl/strings/str_split.h" #include #include @@ -237,37 +238,54 @@ Status StubGenerator::GenerateHeader() { "\n" "class Default$stub_class_name$ : public $stub_class_name$ {\n" " public:"); - // std::string mixin_stub = ""; - // for (auto const& mixin_method : mixin_methods_) { - // mixin_stub += ",\n " + mixin_method.grpc_stub_name + "_(std::move" - // } + + std::unordered_map mixin_grpc_stubs; + for (auto const& mixin_method : mixin_methods_) { + mixin_grpc_stubs[mixin_method.grpc_stub_name] = mixin_method.grpc_stub_fqn; + } + + std::string mixin_stub_inputs = ""; + std::string mixin_stub_members_init = ""; + std::string mixin_stub_members = ""; + for (auto const& mixin_grpc_stub : mixin_grpc_stubs) { + mixin_stub_inputs += absl::StrFormat( + " std::unique_ptr<%s::StubInterface> %s,", mixin_grpc_stub.second, mixin_grpc_stub.first); + mixin_stub_members_init += absl::StrFormat( + " %s_(std::move(%s)),", mixin_grpc_stub.first, mixin_grpc_stub.first); + mixin_stub_members += absl::StrFormat( + "std::unique_ptr<%s::StubInterface> %s_;\n", mixin_grpc_stub.second, mixin_grpc_stub.first); + } + if (HasLongrunningMethod()) { - HeaderPrint( // clang-format off - "\n" - " Default$stub_class_name$(\n" - " std::unique_ptr<$grpc_stub_fqn$::StubInterface> grpc_stub,\n" - " std::unique_ptr " - "operations)\n" - " : grpc_stub_(std::move(grpc_stub)),\n" - " operations_(std::move(operations)) {}\n"); - // clang-format on + HeaderPrint( + absl::StrCat(R"""( + Default$stub_class_name$( + std::unique_ptr<$grpc_stub_fqn$::StubInterface> grpc_stub,)""" + , mixin_stub_inputs, + R"""( + std::unique_ptr operations) + : grpc_stub_(std::move(grpc_stub)),)""" + , mixin_stub_members_init, + R"""( + operations_(std::move(operations)) {} +)""")); } else { - HeaderPrint( // clang-format off - "\n" - " explicit Default$stub_class_name$(\n" - " std::unique_ptr<$grpc_stub_fqn$::StubInterface> grpc_stub)\n" - " : grpc_stub_(std::move(grpc_stub)) {}\n"); - // clang-format on + HeaderPrint( + R"""( + explicit Default$stub_class_name$( + std::unique_ptr<$grpc_stub_fqn$::StubInterface> grpc_stub) + : grpc_stub_(std::move(grpc_stub)) {} +)"""); } HeaderPrintPublicMethods(); // private members and close default stub class definition - HeaderPrint( // clang-format off - "\n" - " private:\n" - " std::unique_ptr<$grpc_stub_fqn$::StubInterface> grpc_stub_;\n" - ); + HeaderPrint( + absl::StrCat(R"""( + private: + std::unique_ptr<$grpc_stub_fqn$::StubInterface> grpc_stub_; +)""", mixin_stub_members)); if (HasLongrunningMethod()) { HeaderPrint( // clang-format off " std::unique_ptr operations_;\n"); @@ -320,11 +338,21 @@ Status StubGenerator::GenerateCc() { "$stub_class_name$::~$stub_class_name$() = default;\n"); // clang-format on + std::unordered_map mixin_grpc_stubs; + for (auto const& mixin_method : mixin_methods_) { + mixin_grpc_stubs[mixin_method.method.get().name()] = + mixin_method.grpc_stub_name; + } + // default stub class member methods for (auto const& method : methods()) { + std::string const grpc_stub = + mixin_grpc_stubs.find(method.get().name()) == mixin_grpc_stubs.end() + ? "grpc_stub_" + : mixin_grpc_stubs[method.get().name()] + "_"; if (IsStreamingWrite(method)) { CcPrintMethod(method, __FILE__, __LINE__, - R"""( + absl::StrFormat(R"""( std::unique_ptr<::google::cloud::internal::StreamingWriteRpc< $request_type$, $response_type$>> @@ -332,17 +360,18 @@ Default$stub_class_name$::$method_name$( std::shared_ptr context, Options const&) { auto response = std::make_unique<$response_type$>(); - auto stream = grpc_stub_->$method_name$(context.get(), response.get()); + auto stream = %s->$method_name$(context.get(), response.get()); return std::make_unique<::google::cloud::internal::StreamingWriteRpcImpl< $request_type$, $response_type$>>( std::move(context), std::move(response), std::move(stream)); } -)"""); +)""", + grpc_stub)); continue; } if (IsBidirStreaming(method)) { CcPrintMethod(method, __FILE__, __LINE__, - R"""( + absl::StrFormat(R"""( std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< $request_type$, $response_type$>> @@ -353,14 +382,16 @@ Default$stub_class_name$::Async$method_name$( return google::cloud::internal::MakeStreamingReadWriteRpc<$request_type$, $response_type$>( cq, std::move(context), std::move(options), [this](grpc::ClientContext* context, grpc::CompletionQueue* cq) { - return grpc_stub_->PrepareAsync$method_name$(context, cq); + return %s->PrepareAsync$method_name$(context, cq); }); } -)"""); +)""", + grpc_stub)); continue; } if (IsLongrunningOperation(method)) { - CcPrintMethod(method, __FILE__, __LINE__, R"""( + CcPrintMethod(method, __FILE__, __LINE__, + absl::StrFormat(R"""( future> Default$stub_class_name$::Async$method_name$( google::cloud::CompletionQueue& cq, @@ -373,13 +404,15 @@ Default$stub_class_name$::Async$method_name$( [this](grpc::ClientContext* context, $request_type$ const& request, grpc::CompletionQueue* cq) { - return grpc_stub_->Async$method_name$(context, request, cq); + return %s->Async$method_name$(context, request, cq); }, request, std::move(context)); } -)"""); +)""", + grpc_stub)); - CcPrintMethod(method, __FILE__, __LINE__, R"""( + CcPrintMethod(method, __FILE__, __LINE__, + absl::StrFormat(R"""( StatusOr Default$stub_class_name$::$method_name$( grpc::ClientContext& context, @@ -387,70 +420,83 @@ Default$stub_class_name$::$method_name$( $request_type$ const& request) { $response_type$ response; auto status = - grpc_stub_->$method_name$(&context, request, &response); + %s->$method_name$(&context, request, &response); if (!status.ok()) { return google::cloud::MakeStatusFromRpcError(status); } return response; } -)"""); +)""", + grpc_stub)); continue; } if (IsStreamingRead(method)) { - CcPrintMethod(method, __FILE__, __LINE__, R"""( + CcPrintMethod(method, __FILE__, __LINE__, + absl::StrFormat(R"""( std::unique_ptr> Default$stub_class_name$::$method_name$( std::shared_ptr context, Options const&, $request_type$ const& request) { - auto stream = grpc_stub_->$method_name$(context.get(), request); + auto stream = %s->$method_name$(context.get(), request); return std::make_unique>( std::move(context), std::move(stream)); } -)"""); +)""", + grpc_stub)); continue; } if (IsResponseTypeEmpty(method)) { - CcPrintMethod(method, __FILE__, __LINE__, R"""( + CcPrintMethod(method, __FILE__, __LINE__, + absl::StrFormat(R"""( Status Default$stub_class_name$::$method_name$( grpc::ClientContext& context, Options const&, $request_type$ const& request) { $response_type$ response; auto status = - grpc_stub_->$method_name$(&context, request, &response); + %s->$method_name$(&context, request, &response); if (!status.ok()) { return google::cloud::MakeStatusFromRpcError(status); } return google::cloud::Status(); } -)"""); +)""", + grpc_stub)); continue; } - CcPrintMethod(method, __FILE__, __LINE__, R"""( + CcPrintMethod(method, __FILE__, __LINE__, + absl::StrFormat(R"""( StatusOr<$response_type$> Default$stub_class_name$::$method_name$( grpc::ClientContext& context, Options const&, $request_type$ const& request) { $response_type$ response; auto status = - grpc_stub_->$method_name$(&context, request, &response); + %s->$method_name$(&context, request, &response); if (!status.ok()) { return google::cloud::MakeStatusFromRpcError(status); } return response; } -)"""); +)""", + grpc_stub)); } for (auto const& method : async_methods()) { // Nothing to do, these are always asynchronous. if (IsBidirStreaming(method) || IsLongrunningOperation(method)) continue; + + std::string const grpc_stub = + mixin_grpc_stubs.find(method.get().name()) == mixin_grpc_stubs.end() + ? "grpc_stub_" + : mixin_grpc_stubs[method.get().name()] + "_"; + if (IsStreamingRead(method)) { - auto constexpr kDefinition = R"""( + auto const definiation = absl::StrFormat(R"""( std::unique_ptr<::google::cloud::internal::AsyncStreamingReadRpc< $response_type$>> Default$stub_class_name$::Async$method_name$( @@ -461,15 +507,16 @@ Default$stub_class_name$::Async$method_name$( return google::cloud::internal::MakeStreamingReadRpc<$request_type$, $response_type$>( cq, std::move(context), std::move(options), request, [this](grpc::ClientContext* context, $request_type$ const& request, grpc::CompletionQueue* cq) { - return grpc_stub_->PrepareAsync$method_name$(context, request, cq); + return %s->PrepareAsync$method_name$(context, request, cq); }); } -)"""; - CcPrintMethod(method, __FILE__, __LINE__, kDefinition); +)""", + grpc_stub); + CcPrintMethod(method, __FILE__, __LINE__, definiation); continue; } if (IsStreamingWrite(method)) { - auto constexpr kDefinition = R"""( + auto const definiation = absl::StrFormat(R"""( std::unique_ptr<::google::cloud::internal::AsyncStreamingWriteRpc< $request_type$, $response_type$>> Default$stub_class_name$::Async$method_name$( @@ -479,15 +526,17 @@ Default$stub_class_name$::Async$method_name$( return google::cloud::internal::MakeStreamingWriteRpc<$request_type$, $response_type$>( cq, std::move(context), std::move(options), [this](grpc::ClientContext* context, $response_type$* response, grpc::CompletionQueue* cq) { - return grpc_stub_->PrepareAsync$method_name$(context, response, cq); + return %s->PrepareAsync$method_name$(context, response, cq); }); } -)"""; - CcPrintMethod(method, __FILE__, __LINE__, kDefinition); +)""", + grpc_stub); + CcPrintMethod(method, __FILE__, __LINE__, definiation); continue; } if (IsResponseTypeEmpty(method)) { - CcPrintMethod(method, __FILE__, __LINE__, R"""( + CcPrintMethod(method, __FILE__, __LINE__, + absl::StrFormat(R"""( future Default$stub_class_name$::Async$method_name$( google::cloud::CompletionQueue& cq, @@ -501,17 +550,19 @@ Default$stub_class_name$::Async$method_name$( [this](grpc::ClientContext* context, $request_type$ const& request, grpc::CompletionQueue* cq) { - return grpc_stub_->Async$method_name$(context, request, cq); + return %s->Async$method_name$(context, request, cq); }, request, std::move(context)) .then([](future> f) { return f.get().status(); }); } -)"""); +)""", + grpc_stub)); continue; } - CcPrintMethod(method, __FILE__, __LINE__, R"""( + CcPrintMethod(method, __FILE__, __LINE__, + absl::StrFormat(R"""( future> Default$stub_class_name$::Async$method_name$( google::cloud::CompletionQueue& cq, @@ -525,11 +576,12 @@ Default$stub_class_name$::Async$method_name$( [this](grpc::ClientContext* context, $request_type$ const& request, grpc::CompletionQueue* cq) { - return grpc_stub_->Async$method_name$(context, request, cq); + return %s->Async$method_name$(context, request, cq); }, request, std::move(context)); } -)"""); +)""", + grpc_stub)); } if (HasLongrunningMethod()) { diff --git a/google/cloud/datamigration/v1/internal/data_migration_stub.cc b/google/cloud/datamigration/v1/internal/data_migration_stub.cc index 2b5f63b897677..6eca400ef94da 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_stub.cc +++ b/google/cloud/datamigration/v1/internal/data_migration_stub.cc @@ -1023,7 +1023,7 @@ DefaultDataMigrationServiceStub::ListLocations( grpc::ClientContext& context, Options const&, google::cloud::location::ListLocationsRequest const& request) { google::cloud::location::ListLocationsResponse response; - auto status = grpc_stub_->ListLocations(&context, request, &response); + auto status = locations_stub_->ListLocations(&context, request, &response); if (!status.ok()) { return google::cloud::MakeStatusFromRpcError(status); } @@ -1035,7 +1035,7 @@ DefaultDataMigrationServiceStub::GetLocation( grpc::ClientContext& context, Options const&, google::cloud::location::GetLocationRequest const& request) { google::cloud::location::Location response; - auto status = grpc_stub_->GetLocation(&context, request, &response); + auto status = locations_stub_->GetLocation(&context, request, &response); if (!status.ok()) { return google::cloud::MakeStatusFromRpcError(status); } diff --git a/google/cloud/datamigration/v1/internal/data_migration_stub.h b/google/cloud/datamigration/v1/internal/data_migration_stub.h index 96dae4d79c0c5..1eb8cf81d19ff 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_stub.h +++ b/google/cloud/datamigration/v1/internal/data_migration_stub.h @@ -461,9 +461,13 @@ class DefaultDataMigrationServiceStub : public DataMigrationServiceStub { std::unique_ptr< google::cloud::clouddms::v1::DataMigrationService::StubInterface> grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListMigrationJobs(grpc::ClientContext& context, Options const& options, @@ -870,6 +874,8 @@ class DefaultDataMigrationServiceStub : public DataMigrationServiceStub { std::unique_ptr< google::cloud::clouddms::v1::DataMigrationService::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/datamigration/v1/internal/data_migration_stub_factory.cc b/google/cloud/datamigration/v1/internal/data_migration_stub_factory.cc index 7e340e5cd2163..d3f3508a2cf30 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_stub_factory.cc +++ b/google/cloud/datamigration/v1/internal/data_migration_stub_factory.cc @@ -45,9 +45,11 @@ std::shared_ptr CreateDefaultDataMigrationServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::clouddms::v1::DataMigrationService::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { From 3220f50e1552aeb5de0d03b32d02d3d8717e2328 Mon Sep 17 00:00:00 2001 From: Yao Cui Date: Fri, 16 Aug 2024 16:01:27 +0000 Subject: [PATCH 5/8] add tests --- google/cloud/datamigration/BUILD.bazel | 1 + .../datamigration/quickstart/quickstart.cc | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/google/cloud/datamigration/BUILD.bazel b/google/cloud/datamigration/BUILD.bazel index 2e50d98b52e8b..a6426221ed0f2 100644 --- a/google/cloud/datamigration/BUILD.bazel +++ b/google/cloud/datamigration/BUILD.bazel @@ -26,6 +26,7 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/clouddms/logging/v1:logging_cc_grpc", "@com_google_googleapis//google/cloud/clouddms/v1:clouddms_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/datamigration/quickstart/quickstart.cc b/google/cloud/datamigration/quickstart/quickstart.cc index 8f4dae71d95d9..de11c9c822faa 100644 --- a/google/cloud/datamigration/quickstart/quickstart.cc +++ b/google/cloud/datamigration/quickstart/quickstart.cc @@ -29,11 +29,29 @@ int main(int argc, char* argv[]) try { auto client = datamigration::DataMigrationServiceClient( datamigration::MakeDataMigrationServiceConnection()); + + std::cout << "------------------------TEST ListMigrationJobs------------------------" << std::endl; for (auto mj : client.ListMigrationJobs(location.FullName())) { if (!mj) throw std::move(mj).status(); std::cout << mj->DebugString() << "\n"; } + std::cout << "------------------------TEST ListLocations------------------------" << std::endl; + google::cloud::location::ListLocationsRequest ll_req; + *ll_req.mutable_name() = "projects/" + std::string(argv[1]); + std::cout << "ListLocationsRequest name = " << ll_req.name() << "\n"; + for (auto l : client.ListLocations(ll_req)) { + if (!l) throw std::move(l).status(); + std::cout << l->DebugString() << "\n"; + } + + std::cout << "------------------------TEST GetLocation------------------------" << std::endl; + google::cloud::location::GetLocationRequest gl_req; + *gl_req.mutable_name() = "projects/" + std::string(argv[1]) + "/locations/" + argv[2]; + google::cloud::StatusOr gl_res = client.GetLocation(gl_req); + if (!gl_res) throw std::move(gl_res).status(); + std::cout << gl_res->DebugString() << "\n"; + return 0; } catch (google::cloud::Status const& status) { std::cerr << "google::cloud::Status thrown: " << status << "\n"; From 9cf59e9b5f0f6b2a8eeb288c7f3c4de54c31b71b Mon Sep 17 00:00:00 2001 From: Yao Cui Date: Fri, 16 Aug 2024 16:32:30 +0000 Subject: [PATCH 6/8] add iam mixin --- generator/internal/connection_generator.cc | 14 ++- generator/internal/mixin_utils.cc | 2 +- google/cloud/datamigration/BUILD.bazel | 1 + .../datamigration/quickstart/MODULE.bazel | 6 ++ .../datamigration/quickstart/quickstart.cc | 19 ++-- .../datamigration/v1/data_migration_client.cc | 19 ++++ .../datamigration/v1/data_migration_client.h | 102 ++++++++++++++++++ .../v1/data_migration_connection.cc | 16 +++ .../v1/data_migration_connection.h | 10 ++ ...migration_connection_idempotency_policy.cc | 16 +++ ..._migration_connection_idempotency_policy.h | 10 ++ .../internal/data_migration_auth_decorator.cc | 25 +++++ .../internal/data_migration_auth_decorator.h | 12 +++ .../data_migration_connection_impl.cc | 42 ++++++++ .../internal/data_migration_connection_impl.h | 9 ++ .../data_migration_logging_decorator.cc | 34 ++++++ .../data_migration_logging_decorator.h | 12 +++ .../data_migration_metadata_decorator.cc | 28 +++++ .../data_migration_metadata_decorator.h | 12 +++ .../v1/internal/data_migration_stub.cc | 35 ++++++ .../v1/internal/data_migration_stub.h | 30 ++++++ .../internal/data_migration_stub_factory.cc | 5 +- .../data_migration_tracing_connection.cc | 27 +++++ .../data_migration_tracing_connection.h | 9 ++ .../internal/data_migration_tracing_stub.cc | 34 ++++++ .../v1/internal/data_migration_tracing_stub.h | 12 +++ .../v1/mocks/mock_data_migration_connection.h | 13 +++ 27 files changed, 541 insertions(+), 13 deletions(-) create mode 100644 google/cloud/datamigration/quickstart/MODULE.bazel diff --git a/generator/internal/connection_generator.cc b/generator/internal/connection_generator.cc index b3c79dac61c8c..78ed261c73e18 100644 --- a/generator/internal/connection_generator.cc +++ b/generator/internal/connection_generator.cc @@ -19,6 +19,7 @@ #include "generator/internal/pagination.h" #include "generator/internal/predicate_utils.h" #include "generator/internal/printer.h" +#include "absl/strings/str_split.h" #include namespace google { @@ -70,11 +71,14 @@ Status ConnectionGenerator::GenerateHeader() { : "", IsExperimental() ? "google/cloud/experimental_tag.h" : "", "google/cloud/version.h"}); - HeaderSystemIncludes( - {vars("proto_header_path"), vars("additional_pb_header_paths"), - HasGRPCLongrunningOperation() ? "google/longrunning/operations.grpc.pb.h" - : "", - "memory"}); + std::vector const additional_pb_header_paths = + absl::StrSplit(vars("additional_pb_header_paths"), absl::ByChar(',')); + HeaderSystemIncludes(additional_pb_header_paths); + HeaderSystemIncludes({vars("proto_header_path"), + HasGRPCLongrunningOperation() + ? "google/longrunning/operations.grpc.pb.h" + : "", + "memory"}); switch (endpoint_location_style) { case ServiceConfiguration::LOCATION_DEPENDENT: case ServiceConfiguration::LOCATION_DEPENDENT_COMPAT: diff --git a/generator/internal/mixin_utils.cc b/generator/internal/mixin_utils.cc index 55cc53d961ca1..266a457501548 100644 --- a/generator/internal/mixin_utils.cc +++ b/generator/internal/mixin_utils.cc @@ -23,7 +23,7 @@ namespace { std::unordered_map mixin_proto_path_map = { {"google.cloud.location.Locations", "google/cloud/location/locations.proto"}, - // {"google.iam.v1.IAMPolicy", "google/iam/v1/iam_policy.proto"}, + {"google.iam.v1.IAMPolicy", "google/iam/v1/iam_policy.proto"}, // {"google.longrunning.Operations", "google/longrunning/operations.proto"}, }; diff --git a/google/cloud/datamigration/BUILD.bazel b/google/cloud/datamigration/BUILD.bazel index a6426221ed0f2..2905f872556eb 100644 --- a/google/cloud/datamigration/BUILD.bazel +++ b/google/cloud/datamigration/BUILD.bazel @@ -27,6 +27,7 @@ googleapis_deps = [ "@com_google_googleapis//google/cloud/clouddms/logging/v1:logging_cc_grpc", "@com_google_googleapis//google/cloud/clouddms/v1:clouddms_cc_grpc", "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/datamigration/quickstart/MODULE.bazel b/google/cloud/datamigration/quickstart/MODULE.bazel new file mode 100644 index 0000000000000..00bb18361f7f6 --- /dev/null +++ b/google/cloud/datamigration/quickstart/MODULE.bazel @@ -0,0 +1,6 @@ +############################################################################### +# Bazel now uses Bzlmod by default to manage external dependencies. +# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel. +# +# For more details, please check https://github.com/bazelbuild/bazel/issues/18958 +############################################################################### diff --git a/google/cloud/datamigration/quickstart/quickstart.cc b/google/cloud/datamigration/quickstart/quickstart.cc index de11c9c822faa..d8b00cec7b29f 100644 --- a/google/cloud/datamigration/quickstart/quickstart.cc +++ b/google/cloud/datamigration/quickstart/quickstart.cc @@ -29,14 +29,17 @@ int main(int argc, char* argv[]) try { auto client = datamigration::DataMigrationServiceClient( datamigration::MakeDataMigrationServiceConnection()); - - std::cout << "------------------------TEST ListMigrationJobs------------------------" << std::endl; + std::cout << "------------------------TEST " + "ListMigrationJobs------------------------" + << std::endl; for (auto mj : client.ListMigrationJobs(location.FullName())) { if (!mj) throw std::move(mj).status(); std::cout << mj->DebugString() << "\n"; } - std::cout << "------------------------TEST ListLocations------------------------" << std::endl; + std::cout + << "------------------------TEST ListLocations------------------------" + << std::endl; google::cloud::location::ListLocationsRequest ll_req; *ll_req.mutable_name() = "projects/" + std::string(argv[1]); std::cout << "ListLocationsRequest name = " << ll_req.name() << "\n"; @@ -45,10 +48,14 @@ int main(int argc, char* argv[]) try { std::cout << l->DebugString() << "\n"; } - std::cout << "------------------------TEST GetLocation------------------------" << std::endl; + std::cout + << "------------------------TEST GetLocation------------------------" + << std::endl; google::cloud::location::GetLocationRequest gl_req; - *gl_req.mutable_name() = "projects/" + std::string(argv[1]) + "/locations/" + argv[2]; - google::cloud::StatusOr gl_res = client.GetLocation(gl_req); + *gl_req.mutable_name() = + "projects/" + std::string(argv[1]) + "/locations/" + argv[2]; + google::cloud::StatusOr gl_res = + client.GetLocation(gl_req); if (!gl_res) throw std::move(gl_res).status(); std::cout << gl_res->DebugString() << "\n"; diff --git a/google/cloud/datamigration/v1/data_migration_client.cc b/google/cloud/datamigration/v1/data_migration_client.cc index 93200e7b4c75e..d442151e13056 100644 --- a/google/cloud/datamigration/v1/data_migration_client.cc +++ b/google/cloud/datamigration/v1/data_migration_client.cc @@ -1124,6 +1124,25 @@ DataMigrationServiceClient::GetLocation( return connection_->GetLocation(request); } +StatusOr DataMigrationServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr DataMigrationServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +DataMigrationServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datamigration_v1 } // namespace cloud diff --git a/google/cloud/datamigration/v1/data_migration_client.h b/google/cloud/datamigration/v1/data_migration_client.h index 6f15df2721d8a..cc42549d5eb31 100644 --- a/google/cloud/datamigration/v1/data_migration_client.h +++ b/google/cloud/datamigration/v1/data_migration_client.h @@ -3343,6 +3343,108 @@ class DataMigrationServiceClient { google::cloud::location::GetLocationRequest const& request, Options opts = {}); + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/datamigration/v1/data_migration_connection.cc b/google/cloud/datamigration/v1/data_migration_connection.cc index b16503d49f37d..be0257783884e 100644 --- a/google/cloud/datamigration/v1/data_migration_connection.cc +++ b/google/cloud/datamigration/v1/data_migration_connection.cc @@ -718,6 +718,22 @@ DataMigrationServiceConnection::GetLocation( return Status(StatusCode::kUnimplemented, "not implemented"); } +StatusOr DataMigrationServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr DataMigrationServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +DataMigrationServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDataMigrationServiceConnection(Options options) { internal::CheckExpectedOptions #include +#include #include #include @@ -546,6 +547,15 @@ class DataMigrationServiceConnection { virtual StatusOr GetLocation( google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/datamigration/v1/data_migration_connection_idempotency_policy.cc b/google/cloud/datamigration/v1/data_migration_connection_idempotency_policy.cc index 7ea7f7e1caaee..c2516613f6e05 100644 --- a/google/cloud/datamigration/v1/data_migration_connection_idempotency_policy.cc +++ b/google/cloud/datamigration/v1/data_migration_connection_idempotency_policy.cc @@ -276,6 +276,22 @@ Idempotency DataMigrationServiceConnectionIdempotencyPolicy::GetLocation( return Idempotency::kIdempotent; } +Idempotency DataMigrationServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency DataMigrationServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DataMigrationServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultDataMigrationServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/datamigration/v1/data_migration_connection_idempotency_policy.h b/google/cloud/datamigration/v1/data_migration_connection_idempotency_policy.h index e9cc47ace9333..b2bc1672bbf34 100644 --- a/google/cloud/datamigration/v1/data_migration_connection_idempotency_policy.h +++ b/google/cloud/datamigration/v1/data_migration_connection_idempotency_policy.h @@ -23,6 +23,7 @@ #include "google/cloud/version.h" #include #include +#include #include namespace google { @@ -182,6 +183,15 @@ class DataMigrationServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GetLocation( google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/datamigration/v1/internal/data_migration_auth_decorator.cc b/google/cloud/datamigration/v1/internal/data_migration_auth_decorator.cc index f0ead4edd2c9a..86bc7056e936a 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_auth_decorator.cc +++ b/google/cloud/datamigration/v1/internal/data_migration_auth_decorator.cc @@ -908,6 +908,31 @@ DataMigrationServiceAuth::GetLocation( return child_->GetLocation(context, options, request); } +StatusOr DataMigrationServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr DataMigrationServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +DataMigrationServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> DataMigrationServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datamigration/v1/internal/data_migration_auth_decorator.h b/google/cloud/datamigration/v1/internal/data_migration_auth_decorator.h index 0c8558e68f285..88f6ad93314df 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_auth_decorator.h +++ b/google/cloud/datamigration/v1/internal/data_migration_auth_decorator.h @@ -428,6 +428,18 @@ class DataMigrationServiceAuth : public DataMigrationServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::location::GetLocationRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datamigration/v1/internal/data_migration_connection_impl.cc b/google/cloud/datamigration/v1/internal/data_migration_connection_impl.cc index 5d8f2af406df6..dffb52a7b99fd 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_connection_impl.cc +++ b/google/cloud/datamigration/v1/internal/data_migration_connection_impl.cc @@ -2706,6 +2706,48 @@ DataMigrationServiceConnectionImpl::GetLocation( *current, request, __func__); } +StatusOr +DataMigrationServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +DataMigrationServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +DataMigrationServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datamigration_v1_internal } // namespace cloud diff --git a/google/cloud/datamigration/v1/internal/data_migration_connection_impl.h b/google/cloud/datamigration/v1/internal/data_migration_connection_impl.h index 23a61255fa821..b4577f8ea346f 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_connection_impl.h +++ b/google/cloud/datamigration/v1/internal/data_migration_connection_impl.h @@ -445,6 +445,15 @@ class DataMigrationServiceConnectionImpl StatusOr GetLocation( google::cloud::location::GetLocationRequest const& request) override; + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/datamigration/v1/internal/data_migration_logging_decorator.cc b/google/cloud/datamigration/v1/internal/data_migration_logging_decorator.cc index 4a8d1d35b09e7..593e28e58ab0b 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_logging_decorator.cc +++ b/google/cloud/datamigration/v1/internal/data_migration_logging_decorator.cc @@ -1071,6 +1071,40 @@ DataMigrationServiceLogging::GetLocation( context, options, request, __func__, tracing_options_); } +StatusOr DataMigrationServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DataMigrationServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataMigrationServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> DataMigrationServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datamigration/v1/internal/data_migration_logging_decorator.h b/google/cloud/datamigration/v1/internal/data_migration_logging_decorator.h index defdb92bce389..004481b60f67e 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_logging_decorator.h +++ b/google/cloud/datamigration/v1/internal/data_migration_logging_decorator.h @@ -428,6 +428,18 @@ class DataMigrationServiceLogging : public DataMigrationServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::location::GetLocationRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datamigration/v1/internal/data_migration_metadata_decorator.cc b/google/cloud/datamigration/v1/internal/data_migration_metadata_decorator.cc index 3a30c488b9504..40dc3ed172ab6 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_metadata_decorator.cc +++ b/google/cloud/datamigration/v1/internal/data_migration_metadata_decorator.cc @@ -757,6 +757,34 @@ DataMigrationServiceMetadata::GetLocation( return child_->GetLocation(context, options, request); } +StatusOr DataMigrationServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr DataMigrationServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +DataMigrationServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> DataMigrationServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datamigration/v1/internal/data_migration_metadata_decorator.h b/google/cloud/datamigration/v1/internal/data_migration_metadata_decorator.h index f3826d572288c..9528269171eaf 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_metadata_decorator.h +++ b/google/cloud/datamigration/v1/internal/data_migration_metadata_decorator.h @@ -429,6 +429,18 @@ class DataMigrationServiceMetadata : public DataMigrationServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::location::GetLocationRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datamigration/v1/internal/data_migration_stub.cc b/google/cloud/datamigration/v1/internal/data_migration_stub.cc index 6eca400ef94da..fb7a5e03f88ab 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_stub.cc +++ b/google/cloud/datamigration/v1/internal/data_migration_stub.cc @@ -1042,6 +1042,41 @@ DefaultDataMigrationServiceStub::GetLocation( return response; } +StatusOr DefaultDataMigrationServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultDataMigrationServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataMigrationServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultDataMigrationServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datamigration/v1/internal/data_migration_stub.h b/google/cloud/datamigration/v1/internal/data_migration_stub.h index 1eb8cf81d19ff..ea066214676f0 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_stub.h +++ b/google/cloud/datamigration/v1/internal/data_migration_stub.h @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #include #include @@ -442,6 +444,19 @@ class DataMigrationServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::location::GetLocationRequest const& request) = 0; + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -461,11 +476,13 @@ class DefaultDataMigrationServiceStub : public DataMigrationServiceStub { std::unique_ptr< google::cloud::clouddms::v1::DataMigrationService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, std::unique_ptr locations_stub, std::unique_ptr operations) : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), locations_stub_(std::move(locations_stub)), operations_(std::move(operations)) {} @@ -858,6 +875,18 @@ class DefaultDataMigrationServiceStub : public DataMigrationServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::location::GetLocationRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -874,6 +903,7 @@ class DefaultDataMigrationServiceStub : public DataMigrationServiceStub { std::unique_ptr< google::cloud::clouddms::v1::DataMigrationService::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; std::unique_ptr locations_stub_; std::unique_ptr operations_; diff --git a/google/cloud/datamigration/v1/internal/data_migration_stub_factory.cc b/google/cloud/datamigration/v1/internal/data_migration_stub_factory.cc index d3f3508a2cf30..78920981f04fc 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_stub_factory.cc +++ b/google/cloud/datamigration/v1/internal/data_migration_stub_factory.cc @@ -30,6 +30,7 @@ #include "google/cloud/options.h" #include #include +#include #include #include @@ -45,11 +46,13 @@ std::shared_ptr CreateDefaultDataMigrationServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::clouddms::v1::DataMigrationService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); auto service_locations_stub = google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), std::move(service_locations_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/datamigration/v1/internal/data_migration_tracing_connection.cc b/google/cloud/datamigration/v1/internal/data_migration_tracing_connection.cc index 7dc2bc3f4d7a3..629b0943f53b4 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_tracing_connection.cc +++ b/google/cloud/datamigration/v1/internal/data_migration_tracing_connection.cc @@ -1018,6 +1018,33 @@ DataMigrationServiceTracingConnection::GetLocation( return internal::EndSpan(*span, child_->GetLocation(request)); } +StatusOr +DataMigrationServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "datamigration_v1::DataMigrationServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +DataMigrationServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "datamigration_v1::DataMigrationServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +DataMigrationServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "datamigration_v1::DataMigrationServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/datamigration/v1/internal/data_migration_tracing_connection.h b/google/cloud/datamigration/v1/internal/data_migration_tracing_connection.h index 90a3a8c04a8aa..f5da7c49c155b 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_tracing_connection.h +++ b/google/cloud/datamigration/v1/internal/data_migration_tracing_connection.h @@ -433,6 +433,15 @@ class DataMigrationServiceTracingConnection StatusOr GetLocation( google::cloud::location::GetLocationRequest const& request) override; + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/datamigration/v1/internal/data_migration_tracing_stub.cc b/google/cloud/datamigration/v1/internal/data_migration_tracing_stub.cc index 62f11ee123fb1..442c888e3e820 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_tracing_stub.cc +++ b/google/cloud/datamigration/v1/internal/data_migration_tracing_stub.cc @@ -975,6 +975,40 @@ DataMigrationServiceTracingStub::GetLocation( child_->GetLocation(context, options, request)); } +StatusOr DataMigrationServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.clouddms.v1.DataMigrationService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr DataMigrationServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.clouddms.v1.DataMigrationService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +DataMigrationServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.clouddms.v1.DataMigrationService", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> DataMigrationServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datamigration/v1/internal/data_migration_tracing_stub.h b/google/cloud/datamigration/v1/internal/data_migration_tracing_stub.h index 78876e20a49f0..61818168bb946 100644 --- a/google/cloud/datamigration/v1/internal/data_migration_tracing_stub.h +++ b/google/cloud/datamigration/v1/internal/data_migration_tracing_stub.h @@ -428,6 +428,18 @@ class DataMigrationServiceTracingStub : public DataMigrationServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::location::GetLocationRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datamigration/v1/mocks/mock_data_migration_connection.h b/google/cloud/datamigration/v1/mocks/mock_data_migration_connection.h index 2a665f2d3f64f..db8a00b217961 100644 --- a/google/cloud/datamigration/v1/mocks/mock_data_migration_connection.h +++ b/google/cloud/datamigration/v1/mocks/mock_data_migration_connection.h @@ -1098,6 +1098,19 @@ class MockDataMigrationServiceConnection MOCK_METHOD(StatusOr, GetLocation, (google::cloud::location::GetLocationRequest const& request), (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END From fae6d820e1d673e7ca034b807704580800eeb513 Mon Sep 17 00:00:00 2001 From: Yao Cui Date: Mon, 19 Aug 2024 18:06:03 +0000 Subject: [PATCH 7/8] more mixins except pubsub --- .../v1/internal/golden_kitchen_sink_stub.h | 2 +- .../v1/internal/golden_thing_admin_stub.h | 8 +- .../golden/v1/internal/request_id_stub.h | 8 +- generator/internal/descriptor_utils.cc | 3 +- generator/internal/http_option_utils.cc | 11 +- generator/internal/http_option_utils.h | 3 +- generator/internal/http_option_utils_test.cc | 19 +- generator/internal/make_generators.cc | 30 +-- generator/internal/mixin_utils.cc | 26 +-- generator/internal/stub_generator.cc | 24 ++- generator/standalone_main.cc | 25 ++- google/cloud/aiplatform/BUILD.bazel | 2 + google/cloud/aiplatform/v1/dataset_client.cc | 32 ++++ google/cloud/aiplatform/v1/dataset_client.h | 172 +++++++++++++++++ .../cloud/aiplatform/v1/dataset_connection.cc | 30 +++ .../cloud/aiplatform/v1/dataset_connection.h | 17 ++ .../dataset_connection_idempotency_policy.cc | 26 +++ .../dataset_connection_idempotency_policy.h | 17 ++ .../v1/deployment_resource_pool_client.cc | 35 ++++ .../v1/deployment_resource_pool_client.h | 173 ++++++++++++++++++ .../v1/deployment_resource_pool_connection.cc | 32 ++++ .../v1/deployment_resource_pool_connection.h | 17 ++ ...urce_pool_connection_idempotency_policy.cc | 31 ++++ ...ource_pool_connection_idempotency_policy.h | 17 ++ google/cloud/aiplatform/v1/endpoint_client.cc | 32 ++++ google/cloud/aiplatform/v1/endpoint_client.h | 172 +++++++++++++++++ .../aiplatform/v1/endpoint_connection.cc | 30 +++ .../cloud/aiplatform/v1/endpoint_connection.h | 17 ++ .../endpoint_connection_idempotency_policy.cc | 26 +++ .../endpoint_connection_idempotency_policy.h | 17 ++ .../v1/feature_online_store_admin_client.cc | 35 ++++ .../v1/feature_online_store_admin_client.h | 172 +++++++++++++++++ .../feature_online_store_admin_connection.cc | 32 ++++ .../feature_online_store_admin_connection.h | 17 ++ ...ore_admin_connection_idempotency_policy.cc | 31 ++++ ...tore_admin_connection_idempotency_policy.h | 17 ++ .../v1/feature_online_store_client.cc | 33 ++++ .../v1/feature_online_store_client.h | 173 ++++++++++++++++++ .../v1/feature_online_store_connection.cc | 33 ++++ .../v1/feature_online_store_connection.h | 18 ++ ...ine_store_connection_idempotency_policy.cc | 27 +++ ...line_store_connection_idempotency_policy.h | 17 ++ .../aiplatform/v1/feature_registry_client.cc | 33 ++++ .../aiplatform/v1/feature_registry_client.h | 172 +++++++++++++++++ .../v1/feature_registry_connection.cc | 32 ++++ .../v1/feature_registry_connection.h | 17 ++ ..._registry_connection_idempotency_policy.cc | 27 +++ ...e_registry_connection_idempotency_policy.h | 17 ++ .../aiplatform/v1/featurestore_client.cc | 33 ++++ .../cloud/aiplatform/v1/featurestore_client.h | 172 +++++++++++++++++ .../aiplatform/v1/featurestore_connection.cc | 30 +++ .../aiplatform/v1/featurestore_connection.h | 17 ++ ...turestore_connection_idempotency_policy.cc | 26 +++ ...aturestore_connection_idempotency_policy.h | 17 ++ .../v1/featurestore_online_serving_client.cc | 35 ++++ .../v1/featurestore_online_serving_client.h | 173 ++++++++++++++++++ .../featurestore_online_serving_connection.cc | 33 ++++ .../featurestore_online_serving_connection.h | 17 ++ ...e_serving_connection_idempotency_policy.cc | 31 ++++ ...ne_serving_connection_idempotency_policy.h | 17 ++ .../aiplatform/v1/gen_ai_tuning_client.cc | 33 ++++ .../aiplatform/v1/gen_ai_tuning_client.h | 172 +++++++++++++++++ .../aiplatform/v1/gen_ai_tuning_connection.cc | 30 +++ .../aiplatform/v1/gen_ai_tuning_connection.h | 17 ++ ...ai_tuning_connection_idempotency_policy.cc | 26 +++ ..._ai_tuning_connection_idempotency_policy.h | 17 ++ google/cloud/aiplatform/v1/index_client.cc | 32 ++++ google/cloud/aiplatform/v1/index_client.h | 172 +++++++++++++++++ .../cloud/aiplatform/v1/index_connection.cc | 29 +++ google/cloud/aiplatform/v1/index_connection.h | 17 ++ .../v1/index_connection_idempotency_policy.cc | 26 +++ .../v1/index_connection_idempotency_policy.h | 17 ++ .../aiplatform/v1/index_endpoint_client.cc | 33 ++++ .../aiplatform/v1/index_endpoint_client.h | 172 +++++++++++++++++ .../v1/index_endpoint_connection.cc | 30 +++ .../aiplatform/v1/index_endpoint_connection.h | 17 ++ ..._endpoint_connection_idempotency_policy.cc | 26 +++ ...x_endpoint_connection_idempotency_policy.h | 17 ++ .../v1/internal/dataset_auth_decorator.cc | 42 +++++ .../v1/internal/dataset_auth_decorator.h | 20 ++ .../v1/internal/dataset_connection_impl.cc | 88 +++++++++ .../v1/internal/dataset_connection_impl.h | 15 ++ .../v1/internal/dataset_logging_decorator.cc | 57 ++++++ .../v1/internal/dataset_logging_decorator.h | 20 ++ .../v1/internal/dataset_metadata_decorator.cc | 45 +++++ .../v1/internal/dataset_metadata_decorator.h | 20 ++ .../aiplatform/v1/internal/dataset_stub.cc | 59 ++++++ .../aiplatform/v1/internal/dataset_stub.h | 57 +++++- .../v1/internal/dataset_stub_factory.cc | 8 +- .../v1/internal/dataset_tracing_connection.cc | 45 +++++ .../v1/internal/dataset_tracing_connection.h | 15 ++ .../v1/internal/dataset_tracing_stub.cc | 58 ++++++ .../v1/internal/dataset_tracing_stub.h | 20 ++ ...deployment_resource_pool_auth_decorator.cc | 45 +++++ .../deployment_resource_pool_auth_decorator.h | 20 ++ ...eployment_resource_pool_connection_impl.cc | 91 +++++++++ ...deployment_resource_pool_connection_impl.h | 15 ++ ...loyment_resource_pool_logging_decorator.cc | 60 ++++++ ...ployment_resource_pool_logging_decorator.h | 20 ++ ...oyment_resource_pool_metadata_decorator.cc | 48 +++++ ...loyment_resource_pool_metadata_decorator.h | 20 ++ .../internal/deployment_resource_pool_stub.cc | 61 ++++++ .../internal/deployment_resource_pool_stub.h | 57 +++++- .../deployment_resource_pool_stub_factory.cc | 8 +- ...oyment_resource_pool_tracing_connection.cc | 48 +++++ ...loyment_resource_pool_tracing_connection.h | 15 ++ .../deployment_resource_pool_tracing_stub.cc | 65 +++++++ .../deployment_resource_pool_tracing_stub.h | 20 ++ .../v1/internal/endpoint_auth_decorator.cc | 42 +++++ .../v1/internal/endpoint_auth_decorator.h | 20 ++ .../v1/internal/endpoint_connection_impl.cc | 88 +++++++++ .../v1/internal/endpoint_connection_impl.h | 15 ++ .../v1/internal/endpoint_logging_decorator.cc | 57 ++++++ .../v1/internal/endpoint_logging_decorator.h | 20 ++ .../internal/endpoint_metadata_decorator.cc | 46 +++++ .../v1/internal/endpoint_metadata_decorator.h | 20 ++ .../aiplatform/v1/internal/endpoint_stub.cc | 59 ++++++ .../aiplatform/v1/internal/endpoint_stub.h | 57 +++++- .../v1/internal/endpoint_stub_factory.cc | 8 +- .../internal/endpoint_tracing_connection.cc | 47 +++++ .../v1/internal/endpoint_tracing_connection.h | 15 ++ .../v1/internal/endpoint_tracing_stub.cc | 58 ++++++ .../v1/internal/endpoint_tracing_stub.h | 20 ++ ...ature_online_store_admin_auth_decorator.cc | 45 +++++ ...eature_online_store_admin_auth_decorator.h | 20 ++ ...ture_online_store_admin_connection_impl.cc | 91 +++++++++ ...ature_online_store_admin_connection_impl.h | 15 ++ ...re_online_store_admin_logging_decorator.cc | 60 ++++++ ...ure_online_store_admin_logging_decorator.h | 20 ++ ...e_online_store_admin_metadata_decorator.cc | 48 +++++ ...re_online_store_admin_metadata_decorator.h | 20 ++ .../feature_online_store_admin_stub.cc | 61 ++++++ .../feature_online_store_admin_stub.h | 57 +++++- ...feature_online_store_admin_stub_factory.cc | 8 +- ...e_online_store_admin_tracing_connection.cc | 48 +++++ ...re_online_store_admin_tracing_connection.h | 15 ++ ...feature_online_store_admin_tracing_stub.cc | 65 +++++++ .../feature_online_store_admin_tracing_stub.h | 20 ++ .../feature_online_store_auth_decorator.cc | 43 +++++ .../feature_online_store_auth_decorator.h | 20 ++ .../feature_online_store_connection_impl.cc | 92 ++++++++++ .../feature_online_store_connection_impl.h | 16 ++ .../feature_online_store_logging_decorator.cc | 60 ++++++ .../feature_online_store_logging_decorator.h | 20 ++ ...feature_online_store_metadata_decorator.cc | 48 +++++ .../feature_online_store_metadata_decorator.h | 20 ++ .../v1/internal/feature_online_store_stub.cc | 61 ++++++ .../v1/internal/feature_online_store_stub.h | 58 +++++- .../feature_online_store_stub_factory.cc | 8 +- ...feature_online_store_tracing_connection.cc | 48 +++++ .../feature_online_store_tracing_connection.h | 15 ++ .../feature_online_store_tracing_stub.cc | 61 ++++++ .../feature_online_store_tracing_stub.h | 20 ++ .../feature_registry_auth_decorator.cc | 43 +++++ .../feature_registry_auth_decorator.h | 20 ++ .../feature_registry_connection_impl.cc | 91 +++++++++ .../feature_registry_connection_impl.h | 15 ++ .../feature_registry_logging_decorator.cc | 58 ++++++ .../feature_registry_logging_decorator.h | 20 ++ .../feature_registry_metadata_decorator.cc | 46 +++++ .../feature_registry_metadata_decorator.h | 20 ++ .../v1/internal/feature_registry_stub.cc | 61 ++++++ .../v1/internal/feature_registry_stub.h | 57 +++++- .../internal/feature_registry_stub_factory.cc | 8 +- .../feature_registry_tracing_connection.cc | 47 +++++ .../feature_registry_tracing_connection.h | 15 ++ .../internal/feature_registry_tracing_stub.cc | 61 ++++++ .../internal/feature_registry_tracing_stub.h | 20 ++ .../internal/featurestore_auth_decorator.cc | 43 +++++ .../v1/internal/featurestore_auth_decorator.h | 20 ++ .../internal/featurestore_connection_impl.cc | 90 +++++++++ .../internal/featurestore_connection_impl.h | 15 ++ .../featurestore_logging_decorator.cc | 58 ++++++ .../internal/featurestore_logging_decorator.h | 20 ++ .../featurestore_metadata_decorator.cc | 46 +++++ .../featurestore_metadata_decorator.h | 20 ++ ...turestore_online_serving_auth_decorator.cc | 45 +++++ ...aturestore_online_serving_auth_decorator.h | 20 ++ ...urestore_online_serving_connection_impl.cc | 92 ++++++++++ ...turestore_online_serving_connection_impl.h | 15 ++ ...estore_online_serving_logging_decorator.cc | 60 ++++++ ...restore_online_serving_logging_decorator.h | 20 ++ ...store_online_serving_metadata_decorator.cc | 48 +++++ ...estore_online_serving_metadata_decorator.h | 20 ++ .../featurestore_online_serving_stub.cc | 61 ++++++ .../featurestore_online_serving_stub.h | 58 +++++- ...eaturestore_online_serving_stub_factory.cc | 8 +- ...store_online_serving_tracing_connection.cc | 51 ++++++ ...estore_online_serving_tracing_connection.h | 15 ++ ...eaturestore_online_serving_tracing_stub.cc | 65 +++++++ ...featurestore_online_serving_tracing_stub.h | 20 ++ .../v1/internal/featurestore_stub.cc | 59 ++++++ .../v1/internal/featurestore_stub.h | 57 +++++- .../v1/internal/featurestore_stub_factory.cc | 8 +- .../featurestore_tracing_connection.cc | 47 +++++ .../featurestore_tracing_connection.h | 15 ++ .../v1/internal/featurestore_tracing_stub.cc | 58 ++++++ .../v1/internal/featurestore_tracing_stub.h | 20 ++ .../internal/gen_ai_tuning_auth_decorator.cc | 42 +++++ .../internal/gen_ai_tuning_auth_decorator.h | 20 ++ .../internal/gen_ai_tuning_connection_impl.cc | 90 +++++++++ .../internal/gen_ai_tuning_connection_impl.h | 15 ++ .../gen_ai_tuning_logging_decorator.cc | 58 ++++++ .../gen_ai_tuning_logging_decorator.h | 20 ++ .../gen_ai_tuning_metadata_decorator.cc | 46 +++++ .../gen_ai_tuning_metadata_decorator.h | 20 ++ .../v1/internal/gen_ai_tuning_stub.cc | 59 ++++++ .../v1/internal/gen_ai_tuning_stub.h | 58 +++++- .../v1/internal/gen_ai_tuning_stub_factory.cc | 8 +- .../gen_ai_tuning_tracing_connection.cc | 47 +++++ .../gen_ai_tuning_tracing_connection.h | 15 ++ .../v1/internal/gen_ai_tuning_tracing_stub.cc | 58 ++++++ .../v1/internal/gen_ai_tuning_tracing_stub.h | 20 ++ .../v1/internal/index_auth_decorator.cc | 42 +++++ .../v1/internal/index_auth_decorator.h | 20 ++ .../v1/internal/index_connection_impl.cc | 88 +++++++++ .../v1/internal/index_connection_impl.h | 15 ++ .../internal/index_endpoint_auth_decorator.cc | 43 +++++ .../internal/index_endpoint_auth_decorator.h | 20 ++ .../index_endpoint_connection_impl.cc | 90 +++++++++ .../internal/index_endpoint_connection_impl.h | 15 ++ .../index_endpoint_logging_decorator.cc | 58 ++++++ .../index_endpoint_logging_decorator.h | 20 ++ .../index_endpoint_metadata_decorator.cc | 46 +++++ .../index_endpoint_metadata_decorator.h | 20 ++ .../v1/internal/index_endpoint_stub.cc | 59 ++++++ .../v1/internal/index_endpoint_stub.h | 57 +++++- .../internal/index_endpoint_stub_factory.cc | 8 +- .../index_endpoint_tracing_connection.cc | 47 +++++ .../index_endpoint_tracing_connection.h | 15 ++ .../internal/index_endpoint_tracing_stub.cc | 58 ++++++ .../v1/internal/index_endpoint_tracing_stub.h | 20 ++ .../v1/internal/index_logging_decorator.cc | 57 ++++++ .../v1/internal/index_logging_decorator.h | 20 ++ .../v1/internal/index_metadata_decorator.cc | 45 +++++ .../v1/internal/index_metadata_decorator.h | 20 ++ .../aiplatform/v1/internal/index_stub.cc | 59 ++++++ .../cloud/aiplatform/v1/internal/index_stub.h | 57 +++++- .../v1/internal/index_stub_factory.cc | 8 +- .../v1/internal/index_tracing_connection.cc | 45 +++++ .../v1/internal/index_tracing_connection.h | 15 ++ .../v1/internal/index_tracing_stub.cc | 58 ++++++ .../v1/internal/index_tracing_stub.h | 20 ++ .../v1/internal/job_auth_decorator.cc | 42 +++++ .../v1/internal/job_auth_decorator.h | 20 ++ .../v1/internal/job_connection_impl.cc | 88 +++++++++ .../v1/internal/job_connection_impl.h | 15 ++ .../v1/internal/job_logging_decorator.cc | 57 ++++++ .../v1/internal/job_logging_decorator.h | 20 ++ .../v1/internal/job_metadata_decorator.cc | 45 +++++ .../v1/internal/job_metadata_decorator.h | 20 ++ .../cloud/aiplatform/v1/internal/job_stub.cc | 58 ++++++ .../cloud/aiplatform/v1/internal/job_stub.h | 57 +++++- .../v1/internal/job_stub_factory.cc | 8 +- .../v1/internal/job_tracing_connection.cc | 45 +++++ .../v1/internal/job_tracing_connection.h | 15 ++ .../v1/internal/job_tracing_stub.cc | 57 ++++++ .../aiplatform/v1/internal/job_tracing_stub.h | 20 ++ .../v1/internal/llm_utility_auth_decorator.cc | 42 +++++ .../v1/internal/llm_utility_auth_decorator.h | 20 ++ .../internal/llm_utility_connection_impl.cc | 89 +++++++++ .../v1/internal/llm_utility_connection_impl.h | 16 ++ .../internal/llm_utility_logging_decorator.cc | 58 ++++++ .../internal/llm_utility_logging_decorator.h | 20 ++ .../llm_utility_metadata_decorator.cc | 46 +++++ .../internal/llm_utility_metadata_decorator.h | 20 ++ .../v1/internal/llm_utility_stub.cc | 59 ++++++ .../aiplatform/v1/internal/llm_utility_stub.h | 58 +++++- .../v1/internal/llm_utility_stub_factory.cc | 8 +- .../llm_utility_tracing_connection.cc | 48 +++++ .../internal/llm_utility_tracing_connection.h | 15 ++ .../v1/internal/llm_utility_tracing_stub.cc | 58 ++++++ .../v1/internal/llm_utility_tracing_stub.h | 20 ++ .../v1/internal/match_auth_decorator.cc | 42 +++++ .../v1/internal/match_auth_decorator.h | 20 ++ .../v1/internal/match_connection_impl.cc | 89 +++++++++ .../v1/internal/match_connection_impl.h | 16 ++ .../v1/internal/match_logging_decorator.cc | 57 ++++++ .../v1/internal/match_logging_decorator.h | 20 ++ .../v1/internal/match_metadata_decorator.cc | 45 +++++ .../v1/internal/match_metadata_decorator.h | 20 ++ .../aiplatform/v1/internal/match_stub.cc | 59 ++++++ .../cloud/aiplatform/v1/internal/match_stub.h | 58 +++++- .../v1/internal/match_stub_factory.cc | 9 +- .../v1/internal/match_tracing_connection.cc | 46 +++++ .../v1/internal/match_tracing_connection.h | 15 ++ .../v1/internal/match_tracing_stub.cc | 58 ++++++ .../v1/internal/match_tracing_stub.h | 20 ++ .../v1/internal/metadata_auth_decorator.cc | 42 +++++ .../v1/internal/metadata_auth_decorator.h | 20 ++ .../v1/internal/metadata_connection_impl.cc | 88 +++++++++ .../v1/internal/metadata_connection_impl.h | 15 ++ .../v1/internal/metadata_logging_decorator.cc | 57 ++++++ .../v1/internal/metadata_logging_decorator.h | 20 ++ .../internal/metadata_metadata_decorator.cc | 46 +++++ .../v1/internal/metadata_metadata_decorator.h | 20 ++ .../aiplatform/v1/internal/metadata_stub.cc | 59 ++++++ .../aiplatform/v1/internal/metadata_stub.h | 57 +++++- .../v1/internal/metadata_stub_factory.cc | 8 +- .../internal/metadata_tracing_connection.cc | 47 +++++ .../v1/internal/metadata_tracing_connection.h | 15 ++ .../v1/internal/metadata_tracing_stub.cc | 58 ++++++ .../v1/internal/metadata_tracing_stub.h | 20 ++ .../v1/internal/migration_auth_decorator.cc | 42 +++++ .../v1/internal/migration_auth_decorator.h | 20 ++ .../v1/internal/migration_connection_impl.cc | 88 +++++++++ .../v1/internal/migration_connection_impl.h | 15 ++ .../internal/migration_logging_decorator.cc | 58 ++++++ .../v1/internal/migration_logging_decorator.h | 20 ++ .../internal/migration_metadata_decorator.cc | 46 +++++ .../internal/migration_metadata_decorator.h | 20 ++ .../aiplatform/v1/internal/migration_stub.cc | 59 ++++++ .../aiplatform/v1/internal/migration_stub.h | 57 +++++- .../v1/internal/migration_stub_factory.cc | 8 +- .../internal/migration_tracing_connection.cc | 47 +++++ .../internal/migration_tracing_connection.h | 15 ++ .../v1/internal/migration_tracing_stub.cc | 58 ++++++ .../v1/internal/migration_tracing_stub.h | 20 ++ .../v1/internal/model_auth_decorator.cc | 42 +++++ .../v1/internal/model_auth_decorator.h | 20 ++ .../v1/internal/model_connection_impl.cc | 88 +++++++++ .../v1/internal/model_connection_impl.h | 15 ++ .../internal/model_garden_auth_decorator.cc | 42 +++++ .../v1/internal/model_garden_auth_decorator.h | 20 ++ .../internal/model_garden_connection_impl.cc | 91 +++++++++ .../internal/model_garden_connection_impl.h | 16 ++ .../model_garden_logging_decorator.cc | 58 ++++++ .../internal/model_garden_logging_decorator.h | 20 ++ .../model_garden_metadata_decorator.cc | 46 +++++ .../model_garden_metadata_decorator.h | 20 ++ .../v1/internal/model_garden_stub.cc | 59 ++++++ .../v1/internal/model_garden_stub.h | 58 +++++- .../v1/internal/model_garden_stub_factory.cc | 8 +- .../model_garden_tracing_connection.cc | 48 +++++ .../model_garden_tracing_connection.h | 15 ++ .../v1/internal/model_garden_tracing_stub.cc | 58 ++++++ .../v1/internal/model_garden_tracing_stub.h | 20 ++ .../v1/internal/model_logging_decorator.cc | 57 ++++++ .../v1/internal/model_logging_decorator.h | 20 ++ .../v1/internal/model_metadata_decorator.cc | 45 +++++ .../v1/internal/model_metadata_decorator.h | 20 ++ .../aiplatform/v1/internal/model_stub.cc | 59 ++++++ .../cloud/aiplatform/v1/internal/model_stub.h | 57 +++++- .../v1/internal/model_stub_factory.cc | 8 +- .../v1/internal/model_tracing_connection.cc | 45 +++++ .../v1/internal/model_tracing_connection.h | 15 ++ .../v1/internal/model_tracing_stub.cc | 58 ++++++ .../v1/internal/model_tracing_stub.h | 20 ++ .../v1/internal/notebook_auth_decorator.cc | 42 +++++ .../v1/internal/notebook_auth_decorator.h | 20 ++ .../v1/internal/notebook_connection_impl.cc | 88 +++++++++ .../v1/internal/notebook_connection_impl.h | 15 ++ .../v1/internal/notebook_logging_decorator.cc | 57 ++++++ .../v1/internal/notebook_logging_decorator.h | 20 ++ .../internal/notebook_metadata_decorator.cc | 46 +++++ .../v1/internal/notebook_metadata_decorator.h | 20 ++ .../aiplatform/v1/internal/notebook_stub.cc | 59 ++++++ .../aiplatform/v1/internal/notebook_stub.h | 57 +++++- .../v1/internal/notebook_stub_factory.cc | 8 +- .../internal/notebook_tracing_connection.cc | 47 +++++ .../v1/internal/notebook_tracing_connection.h | 15 ++ .../v1/internal/notebook_tracing_stub.cc | 58 ++++++ .../v1/internal/notebook_tracing_stub.h | 20 ++ .../persistent_resource_auth_decorator.cc | 43 +++++ .../persistent_resource_auth_decorator.h | 20 ++ .../persistent_resource_connection_impl.cc | 91 +++++++++ .../persistent_resource_connection_impl.h | 15 ++ .../persistent_resource_logging_decorator.cc | 60 ++++++ .../persistent_resource_logging_decorator.h | 20 ++ .../persistent_resource_metadata_decorator.cc | 48 +++++ .../persistent_resource_metadata_decorator.h | 20 ++ .../v1/internal/persistent_resource_stub.cc | 61 ++++++ .../v1/internal/persistent_resource_stub.h | 57 +++++- .../persistent_resource_stub_factory.cc | 8 +- .../persistent_resource_tracing_connection.cc | 47 +++++ .../persistent_resource_tracing_connection.h | 15 ++ .../persistent_resource_tracing_stub.cc | 61 ++++++ .../persistent_resource_tracing_stub.h | 20 ++ .../v1/internal/pipeline_auth_decorator.cc | 42 +++++ .../v1/internal/pipeline_auth_decorator.h | 20 ++ .../v1/internal/pipeline_connection_impl.cc | 88 +++++++++ .../v1/internal/pipeline_connection_impl.h | 15 ++ .../v1/internal/pipeline_logging_decorator.cc | 57 ++++++ .../v1/internal/pipeline_logging_decorator.h | 20 ++ .../internal/pipeline_metadata_decorator.cc | 46 +++++ .../v1/internal/pipeline_metadata_decorator.h | 20 ++ .../aiplatform/v1/internal/pipeline_stub.cc | 59 ++++++ .../aiplatform/v1/internal/pipeline_stub.h | 57 +++++- .../v1/internal/pipeline_stub_factory.cc | 8 +- .../internal/pipeline_tracing_connection.cc | 47 +++++ .../v1/internal/pipeline_tracing_connection.h | 15 ++ .../v1/internal/pipeline_tracing_stub.cc | 58 ++++++ .../v1/internal/pipeline_tracing_stub.h | 20 ++ .../v1/internal/prediction_auth_decorator.cc | 42 +++++ .../v1/internal/prediction_auth_decorator.h | 20 ++ .../v1/internal/prediction_connection_impl.cc | 89 +++++++++ .../v1/internal/prediction_connection_impl.h | 15 ++ .../internal/prediction_logging_decorator.cc | 58 ++++++ .../internal/prediction_logging_decorator.h | 20 ++ .../internal/prediction_metadata_decorator.cc | 46 +++++ .../internal/prediction_metadata_decorator.h | 20 ++ .../aiplatform/v1/internal/prediction_stub.cc | 59 ++++++ .../aiplatform/v1/internal/prediction_stub.h | 58 +++++- .../v1/internal/prediction_stub_factory.cc | 8 +- .../internal/prediction_tracing_connection.cc | 47 +++++ .../internal/prediction_tracing_connection.h | 15 ++ .../v1/internal/prediction_tracing_stub.cc | 58 ++++++ .../v1/internal/prediction_tracing_stub.h | 20 ++ .../v1/internal/schedule_auth_decorator.cc | 42 +++++ .../v1/internal/schedule_auth_decorator.h | 20 ++ .../v1/internal/schedule_connection_impl.cc | 88 +++++++++ .../v1/internal/schedule_connection_impl.h | 15 ++ .../v1/internal/schedule_logging_decorator.cc | 57 ++++++ .../v1/internal/schedule_logging_decorator.h | 20 ++ .../internal/schedule_metadata_decorator.cc | 46 +++++ .../v1/internal/schedule_metadata_decorator.h | 20 ++ .../aiplatform/v1/internal/schedule_stub.cc | 59 ++++++ .../aiplatform/v1/internal/schedule_stub.h | 57 +++++- .../v1/internal/schedule_stub_factory.cc | 8 +- .../internal/schedule_tracing_connection.cc | 47 +++++ .../v1/internal/schedule_tracing_connection.h | 15 ++ .../v1/internal/schedule_tracing_stub.cc | 58 ++++++ .../v1/internal/schedule_tracing_stub.h | 20 ++ .../specialist_pool_auth_decorator.cc | 43 +++++ .../internal/specialist_pool_auth_decorator.h | 20 ++ .../specialist_pool_connection_impl.cc | 90 +++++++++ .../specialist_pool_connection_impl.h | 15 ++ .../specialist_pool_logging_decorator.cc | 58 ++++++ .../specialist_pool_logging_decorator.h | 20 ++ .../specialist_pool_metadata_decorator.cc | 46 +++++ .../specialist_pool_metadata_decorator.h | 20 ++ .../v1/internal/specialist_pool_stub.cc | 61 ++++++ .../v1/internal/specialist_pool_stub.h | 57 +++++- .../internal/specialist_pool_stub_factory.cc | 8 +- .../specialist_pool_tracing_connection.cc | 47 +++++ .../specialist_pool_tracing_connection.h | 15 ++ .../internal/specialist_pool_tracing_stub.cc | 60 ++++++ .../internal/specialist_pool_tracing_stub.h | 20 ++ .../v1/internal/tensorboard_auth_decorator.cc | 42 +++++ .../v1/internal/tensorboard_auth_decorator.h | 20 ++ .../internal/tensorboard_connection_impl.cc | 90 +++++++++ .../v1/internal/tensorboard_connection_impl.h | 15 ++ .../internal/tensorboard_logging_decorator.cc | 58 ++++++ .../internal/tensorboard_logging_decorator.h | 20 ++ .../tensorboard_metadata_decorator.cc | 46 +++++ .../internal/tensorboard_metadata_decorator.h | 20 ++ .../v1/internal/tensorboard_stub.cc | 59 ++++++ .../aiplatform/v1/internal/tensorboard_stub.h | 57 +++++- .../v1/internal/tensorboard_stub_factory.cc | 8 +- .../tensorboard_tracing_connection.cc | 47 +++++ .../internal/tensorboard_tracing_connection.h | 15 ++ .../v1/internal/tensorboard_tracing_stub.cc | 58 ++++++ .../v1/internal/tensorboard_tracing_stub.h | 20 ++ .../v1/internal/vizier_auth_decorator.cc | 42 +++++ .../v1/internal/vizier_auth_decorator.h | 20 ++ .../v1/internal/vizier_connection_impl.cc | 88 +++++++++ .../v1/internal/vizier_connection_impl.h | 15 ++ .../v1/internal/vizier_logging_decorator.cc | 57 ++++++ .../v1/internal/vizier_logging_decorator.h | 20 ++ .../v1/internal/vizier_metadata_decorator.cc | 45 +++++ .../v1/internal/vizier_metadata_decorator.h | 20 ++ .../aiplatform/v1/internal/vizier_stub.cc | 59 ++++++ .../aiplatform/v1/internal/vizier_stub.h | 57 +++++- .../v1/internal/vizier_stub_factory.cc | 8 +- .../v1/internal/vizier_tracing_connection.cc | 45 +++++ .../v1/internal/vizier_tracing_connection.h | 15 ++ .../v1/internal/vizier_tracing_stub.cc | 58 ++++++ .../v1/internal/vizier_tracing_stub.h | 20 ++ google/cloud/aiplatform/v1/job_client.cc | 31 ++++ google/cloud/aiplatform/v1/job_client.h | 172 +++++++++++++++++ google/cloud/aiplatform/v1/job_connection.cc | 29 +++ google/cloud/aiplatform/v1/job_connection.h | 17 ++ .../v1/job_connection_idempotency_policy.cc | 26 +++ .../v1/job_connection_idempotency_policy.h | 17 ++ .../cloud/aiplatform/v1/llm_utility_client.cc | 33 ++++ .../cloud/aiplatform/v1/llm_utility_client.h | 173 ++++++++++++++++++ .../aiplatform/v1/llm_utility_connection.cc | 31 ++++ .../aiplatform/v1/llm_utility_connection.h | 18 ++ ...m_utility_connection_idempotency_policy.cc | 26 +++ ...lm_utility_connection_idempotency_policy.h | 17 ++ google/cloud/aiplatform/v1/match_client.cc | 32 ++++ google/cloud/aiplatform/v1/match_client.h | 173 ++++++++++++++++++ .../cloud/aiplatform/v1/match_connection.cc | 30 +++ google/cloud/aiplatform/v1/match_connection.h | 18 ++ .../v1/match_connection_idempotency_policy.cc | 26 +++ .../v1/match_connection_idempotency_policy.h | 17 ++ google/cloud/aiplatform/v1/metadata_client.cc | 32 ++++ google/cloud/aiplatform/v1/metadata_client.h | 172 +++++++++++++++++ .../aiplatform/v1/metadata_connection.cc | 30 +++ .../cloud/aiplatform/v1/metadata_connection.h | 17 ++ .../metadata_connection_idempotency_policy.cc | 26 +++ .../metadata_connection_idempotency_policy.h | 17 ++ .../cloud/aiplatform/v1/migration_client.cc | 32 ++++ google/cloud/aiplatform/v1/migration_client.h | 173 ++++++++++++++++++ .../aiplatform/v1/migration_connection.cc | 30 +++ .../aiplatform/v1/migration_connection.h | 17 ++ ...migration_connection_idempotency_policy.cc | 26 +++ .../migration_connection_idempotency_policy.h | 17 ++ .../v1/mocks/mock_dataset_connection.h | 21 +++ ...mock_deployment_resource_pool_connection.h | 21 +++ .../v1/mocks/mock_endpoint_connection.h | 21 +++ ...ck_feature_online_store_admin_connection.h | 21 +++ .../mock_feature_online_store_connection.h | 21 +++ .../mocks/mock_feature_registry_connection.h | 21 +++ .../v1/mocks/mock_featurestore_connection.h | 21 +++ ...k_featurestore_online_serving_connection.h | 21 +++ .../v1/mocks/mock_gen_ai_tuning_connection.h | 21 +++ .../v1/mocks/mock_index_connection.h | 21 +++ .../v1/mocks/mock_index_endpoint_connection.h | 21 +++ .../aiplatform/v1/mocks/mock_job_connection.h | 21 +++ .../v1/mocks/mock_llm_utility_connection.h | 21 +++ .../v1/mocks/mock_match_connection.h | 21 +++ .../v1/mocks/mock_metadata_connection.h | 21 +++ .../v1/mocks/mock_migration_connection.h | 21 +++ .../v1/mocks/mock_model_connection.h | 21 +++ .../v1/mocks/mock_model_garden_connection.h | 21 +++ .../v1/mocks/mock_notebook_connection.h | 21 +++ .../mock_persistent_resource_connection.h | 21 +++ .../v1/mocks/mock_pipeline_connection.h | 21 +++ .../v1/mocks/mock_prediction_connection.h | 21 +++ .../v1/mocks/mock_schedule_connection.h | 21 +++ .../mocks/mock_specialist_pool_connection.h | 21 +++ .../v1/mocks/mock_tensorboard_connection.h | 21 +++ .../v1/mocks/mock_vizier_connection.h | 21 +++ google/cloud/aiplatform/v1/model_client.cc | 32 ++++ google/cloud/aiplatform/v1/model_client.h | 172 +++++++++++++++++ .../cloud/aiplatform/v1/model_connection.cc | 29 +++ google/cloud/aiplatform/v1/model_connection.h | 17 ++ .../v1/model_connection_idempotency_policy.cc | 26 +++ .../v1/model_connection_idempotency_policy.h | 17 ++ .../aiplatform/v1/model_garden_client.cc | 33 ++++ .../cloud/aiplatform/v1/model_garden_client.h | 173 ++++++++++++++++++ .../aiplatform/v1/model_garden_connection.cc | 31 ++++ .../aiplatform/v1/model_garden_connection.h | 18 ++ ...el_garden_connection_idempotency_policy.cc | 26 +++ ...del_garden_connection_idempotency_policy.h | 17 ++ google/cloud/aiplatform/v1/notebook_client.cc | 32 ++++ google/cloud/aiplatform/v1/notebook_client.h | 172 +++++++++++++++++ .../aiplatform/v1/notebook_connection.cc | 30 +++ .../cloud/aiplatform/v1/notebook_connection.h | 17 ++ .../notebook_connection_idempotency_policy.cc | 26 +++ .../notebook_connection_idempotency_policy.h | 17 ++ .../v1/persistent_resource_client.cc | 33 ++++ .../v1/persistent_resource_client.h | 172 +++++++++++++++++ .../v1/persistent_resource_connection.cc | 32 ++++ .../v1/persistent_resource_connection.h | 17 ++ ..._resource_connection_idempotency_policy.cc | 27 +++ ...t_resource_connection_idempotency_policy.h | 17 ++ google/cloud/aiplatform/v1/pipeline_client.cc | 32 ++++ google/cloud/aiplatform/v1/pipeline_client.h | 172 +++++++++++++++++ .../aiplatform/v1/pipeline_connection.cc | 30 +++ .../cloud/aiplatform/v1/pipeline_connection.h | 17 ++ .../pipeline_connection_idempotency_policy.cc | 26 +++ .../pipeline_connection_idempotency_policy.h | 17 ++ .../cloud/aiplatform/v1/prediction_client.cc | 33 ++++ .../cloud/aiplatform/v1/prediction_client.h | 173 ++++++++++++++++++ .../aiplatform/v1/prediction_connection.cc | 31 ++++ .../aiplatform/v1/prediction_connection.h | 17 ++ ...rediction_connection_idempotency_policy.cc | 26 +++ ...prediction_connection_idempotency_policy.h | 17 ++ google/cloud/aiplatform/v1/schedule_client.cc | 32 ++++ google/cloud/aiplatform/v1/schedule_client.h | 173 ++++++++++++++++++ .../aiplatform/v1/schedule_connection.cc | 30 +++ .../cloud/aiplatform/v1/schedule_connection.h | 17 ++ .../schedule_connection_idempotency_policy.cc | 26 +++ .../schedule_connection_idempotency_policy.h | 17 ++ .../aiplatform/v1/specialist_pool_client.cc | 33 ++++ .../aiplatform/v1/specialist_pool_client.h | 173 ++++++++++++++++++ .../v1/specialist_pool_connection.cc | 30 +++ .../v1/specialist_pool_connection.h | 17 ++ ...list_pool_connection_idempotency_policy.cc | 27 +++ ...alist_pool_connection_idempotency_policy.h | 17 ++ .../cloud/aiplatform/v1/tensorboard_client.cc | 33 ++++ .../cloud/aiplatform/v1/tensorboard_client.h | 172 +++++++++++++++++ .../aiplatform/v1/tensorboard_connection.cc | 30 +++ .../aiplatform/v1/tensorboard_connection.h | 17 ++ ...nsorboard_connection_idempotency_policy.cc | 26 +++ ...ensorboard_connection_idempotency_policy.h | 17 ++ google/cloud/aiplatform/v1/vizier_client.cc | 32 ++++ google/cloud/aiplatform/v1/vizier_client.h | 172 +++++++++++++++++ .../cloud/aiplatform/v1/vizier_connection.cc | 30 +++ .../cloud/aiplatform/v1/vizier_connection.h | 17 ++ .../vizier_connection_idempotency_policy.cc | 26 +++ .../v1/vizier_connection_idempotency_policy.h | 17 ++ google/cloud/alloydb/BUILD.bazel | 2 + .../cloud/alloydb/v1/alloy_db_admin_client.cc | 13 ++ .../cloud/alloydb/v1/alloy_db_admin_client.h | 70 +++++++ .../alloydb/v1/alloy_db_admin_connection.cc | 13 ++ .../alloydb/v1/alloy_db_admin_connection.h | 8 + ..._db_admin_connection_idempotency_policy.cc | 10 + ...y_db_admin_connection_idempotency_policy.h | 7 + .../internal/alloy_db_admin_auth_decorator.cc | 17 ++ .../internal/alloy_db_admin_auth_decorator.h | 8 + .../alloy_db_admin_connection_impl.cc | 48 +++++ .../internal/alloy_db_admin_connection_impl.h | 6 + .../alloy_db_admin_logging_decorator.cc | 23 +++ .../alloy_db_admin_logging_decorator.h | 8 + .../alloy_db_admin_metadata_decorator.cc | 17 ++ .../alloy_db_admin_metadata_decorator.h | 8 + .../v1/internal/alloy_db_admin_stub.cc | 24 +++ .../alloydb/v1/internal/alloy_db_admin_stub.h | 28 ++- .../internal/alloy_db_admin_stub_factory.cc | 5 +- .../alloy_db_admin_tracing_connection.cc | 20 ++ .../alloy_db_admin_tracing_connection.h | 6 + .../internal/alloy_db_admin_tracing_stub.cc | 24 +++ .../v1/internal/alloy_db_admin_tracing_stub.h | 8 + .../v1/mocks/mock_alloy_db_admin_connection.h | 8 + google/cloud/apphub/BUILD.bazel | 2 + google/cloud/apphub/v1/app_hub_client.cc | 31 ++++ google/cloud/apphub/v1/app_hub_client.h | 173 ++++++++++++++++++ google/cloud/apphub/v1/app_hub_connection.cc | 28 +++ google/cloud/apphub/v1/app_hub_connection.h | 17 ++ .../app_hub_connection_idempotency_policy.cc | 26 +++ .../app_hub_connection_idempotency_policy.h | 17 ++ .../v1/internal/app_hub_auth_decorator.cc | 42 +++++ .../v1/internal/app_hub_auth_decorator.h | 20 ++ .../v1/internal/app_hub_connection_impl.cc | 87 +++++++++ .../v1/internal/app_hub_connection_impl.h | 15 ++ .../v1/internal/app_hub_logging_decorator.cc | 57 ++++++ .../v1/internal/app_hub_logging_decorator.h | 20 ++ .../v1/internal/app_hub_metadata_decorator.cc | 45 +++++ .../v1/internal/app_hub_metadata_decorator.h | 20 ++ .../cloud/apphub/v1/internal/app_hub_stub.cc | 58 ++++++ .../cloud/apphub/v1/internal/app_hub_stub.h | 57 +++++- .../v1/internal/app_hub_stub_factory.cc | 8 +- .../v1/internal/app_hub_tracing_connection.cc | 41 +++++ .../v1/internal/app_hub_tracing_connection.h | 15 ++ .../v1/internal/app_hub_tracing_stub.cc | 57 ++++++ .../apphub/v1/internal/app_hub_tracing_stub.h | 20 ++ .../apphub/v1/mocks/mock_app_hub_connection.h | 21 +++ google/cloud/artifactregistry/BUILD.bazel | 2 + .../v1/artifact_registry_client.cc | 13 ++ .../v1/artifact_registry_client.h | 70 +++++++ .../v1/artifact_registry_connection.cc | 14 ++ .../v1/artifact_registry_connection.h | 7 + ..._registry_connection_idempotency_policy.cc | 10 + ...t_registry_connection_idempotency_policy.h | 7 + .../artifact_registry_auth_decorator.cc | 17 ++ .../artifact_registry_auth_decorator.h | 8 + .../artifact_registry_connection_impl.cc | 49 +++++ .../artifact_registry_connection_impl.h | 6 + .../artifact_registry_logging_decorator.cc | 24 +++ .../artifact_registry_logging_decorator.h | 8 + .../artifact_registry_metadata_decorator.cc | 18 ++ .../artifact_registry_metadata_decorator.h | 8 + .../v1/internal/artifact_registry_stub.cc | 24 +++ .../v1/internal/artifact_registry_stub.h | 27 ++- .../artifact_registry_stub_factory.cc | 5 +- .../artifact_registry_tracing_connection.cc | 20 ++ .../artifact_registry_tracing_connection.h | 6 + .../artifact_registry_tracing_stub.cc | 24 +++ .../internal/artifact_registry_tracing_stub.h | 8 + .../mocks/mock_artifact_registry_connection.h | 8 + google/cloud/backupdr/BUILD.bazel | 2 + google/cloud/backupdr/v1/backup_dr_client.cc | 31 ++++ google/cloud/backupdr/v1/backup_dr_client.h | 172 +++++++++++++++++ .../cloud/backupdr/v1/backup_dr_connection.cc | 29 +++ .../cloud/backupdr/v1/backup_dr_connection.h | 17 ++ ...backup_dr_connection_idempotency_policy.cc | 26 +++ .../backup_dr_connection_idempotency_policy.h | 17 ++ .../v1/internal/backup_dr_auth_decorator.cc | 42 +++++ .../v1/internal/backup_dr_auth_decorator.h | 20 ++ .../v1/internal/backup_dr_connection_impl.cc | 87 +++++++++ .../v1/internal/backup_dr_connection_impl.h | 15 ++ .../internal/backup_dr_logging_decorator.cc | 57 ++++++ .../v1/internal/backup_dr_logging_decorator.h | 20 ++ .../internal/backup_dr_metadata_decorator.cc | 45 +++++ .../internal/backup_dr_metadata_decorator.h | 20 ++ .../backupdr/v1/internal/backup_dr_stub.cc | 58 ++++++ .../backupdr/v1/internal/backup_dr_stub.h | 57 +++++- .../v1/internal/backup_dr_stub_factory.cc | 8 +- .../internal/backup_dr_tracing_connection.cc | 45 +++++ .../internal/backup_dr_tracing_connection.h | 15 ++ .../v1/internal/backup_dr_tracing_stub.cc | 57 ++++++ .../v1/internal/backup_dr_tracing_stub.h | 20 ++ .../v1/mocks/mock_backup_dr_connection.h | 21 +++ google/cloud/baremetalsolution/BUILD.bazel | 2 + .../v2/bare_metal_solution_client.cc | 14 ++ .../v2/bare_metal_solution_client.h | 70 +++++++ .../v2/bare_metal_solution_connection.cc | 14 ++ .../v2/bare_metal_solution_connection.h | 8 + ..._solution_connection_idempotency_policy.cc | 10 + ...l_solution_connection_idempotency_policy.h | 7 + .../bare_metal_solution_auth_decorator.cc | 17 ++ .../bare_metal_solution_auth_decorator.h | 8 + .../bare_metal_solution_connection_impl.cc | 49 +++++ .../bare_metal_solution_connection_impl.h | 6 + .../bare_metal_solution_logging_decorator.cc | 24 +++ .../bare_metal_solution_logging_decorator.h | 8 + .../bare_metal_solution_metadata_decorator.cc | 18 ++ .../bare_metal_solution_metadata_decorator.h | 8 + .../v2/internal/bare_metal_solution_stub.cc | 24 +++ .../v2/internal/bare_metal_solution_stub.h | 28 ++- .../bare_metal_solution_stub_factory.cc | 5 +- .../bare_metal_solution_tracing_connection.cc | 20 ++ .../bare_metal_solution_tracing_connection.h | 6 + .../bare_metal_solution_tracing_stub.cc | 24 +++ .../bare_metal_solution_tracing_stub.h | 8 + .../mock_bare_metal_solution_connection.h | 8 + google/cloud/batch/BUILD.bazel | 2 + google/cloud/batch/v1/batch_client.cc | 13 ++ google/cloud/batch/v1/batch_client.h | 70 +++++++ google/cloud/batch/v1/batch_connection.cc | 13 ++ google/cloud/batch/v1/batch_connection.h | 7 + .../v1/batch_connection_idempotency_policy.cc | 10 + .../v1/batch_connection_idempotency_policy.h | 7 + .../batch/v1/internal/batch_auth_decorator.cc | 17 ++ .../batch/v1/internal/batch_auth_decorator.h | 8 + .../v1/internal/batch_connection_impl.cc | 48 +++++ .../batch/v1/internal/batch_connection_impl.h | 6 + .../v1/internal/batch_logging_decorator.cc | 23 +++ .../v1/internal/batch_logging_decorator.h | 8 + .../v1/internal/batch_metadata_decorator.cc | 17 ++ .../v1/internal/batch_metadata_decorator.h | 8 + google/cloud/batch/v1/internal/batch_stub.cc | 24 +++ google/cloud/batch/v1/internal/batch_stub.h | 27 ++- .../batch/v1/internal/batch_stub_factory.cc | 5 +- .../v1/internal/batch_tracing_connection.cc | 20 ++ .../v1/internal/batch_tracing_connection.h | 6 + .../batch/v1/internal/batch_tracing_stub.cc | 24 +++ .../batch/v1/internal/batch_tracing_stub.h | 8 + .../batch/v1/mocks/mock_batch_connection.h | 8 + google/cloud/beyondcorp/BUILD.bazel | 2 + .../v1/app_connections_client.cc | 33 ++++ .../v1/app_connections_client.h | 172 +++++++++++++++++ .../v1/app_connections_connection.cc | 30 +++ .../v1/app_connections_connection.h | 17 ++ ...nnections_connection_idempotency_policy.cc | 27 +++ ...onnections_connection_idempotency_policy.h | 17 ++ .../app_connections_auth_decorator.cc | 43 +++++ .../internal/app_connections_auth_decorator.h | 20 ++ .../app_connections_connection_impl.cc | 91 +++++++++ .../app_connections_connection_impl.h | 15 ++ .../app_connections_logging_decorator.cc | 58 ++++++ .../app_connections_logging_decorator.h | 20 ++ .../app_connections_metadata_decorator.cc | 46 +++++ .../app_connections_metadata_decorator.h | 20 ++ .../v1/internal/app_connections_stub.cc | 61 ++++++ .../v1/internal/app_connections_stub.h | 57 +++++- .../internal/app_connections_stub_factory.cc | 8 +- .../app_connections_tracing_connection.cc | 52 ++++++ .../app_connections_tracing_connection.h | 15 ++ .../internal/app_connections_tracing_stub.cc | 65 +++++++ .../internal/app_connections_tracing_stub.h | 20 ++ .../mocks/mock_app_connections_connection.h | 21 +++ .../appconnectors/v1/app_connectors_client.cc | 33 ++++ .../appconnectors/v1/app_connectors_client.h | 172 +++++++++++++++++ .../v1/app_connectors_connection.cc | 30 +++ .../v1/app_connectors_connection.h | 17 ++ ...onnectors_connection_idempotency_policy.cc | 26 +++ ...connectors_connection_idempotency_policy.h | 17 ++ .../internal/app_connectors_auth_decorator.cc | 43 +++++ .../internal/app_connectors_auth_decorator.h | 20 ++ .../app_connectors_connection_impl.cc | 91 +++++++++ .../internal/app_connectors_connection_impl.h | 15 ++ .../app_connectors_logging_decorator.cc | 58 ++++++ .../app_connectors_logging_decorator.h | 20 ++ .../app_connectors_metadata_decorator.cc | 46 +++++ .../app_connectors_metadata_decorator.h | 20 ++ .../v1/internal/app_connectors_stub.cc | 59 ++++++ .../v1/internal/app_connectors_stub.h | 57 +++++- .../internal/app_connectors_stub_factory.cc | 8 +- .../app_connectors_tracing_connection.cc | 52 ++++++ .../app_connectors_tracing_connection.h | 15 ++ .../internal/app_connectors_tracing_stub.cc | 63 +++++++ .../v1/internal/app_connectors_tracing_stub.h | 20 ++ .../v1/mocks/mock_app_connectors_connection.h | 21 +++ .../appgateways/v1/app_gateways_client.cc | 33 ++++ .../appgateways/v1/app_gateways_client.h | 172 +++++++++++++++++ .../appgateways/v1/app_gateways_connection.cc | 30 +++ .../appgateways/v1/app_gateways_connection.h | 17 ++ ..._gateways_connection_idempotency_policy.cc | 26 +++ ...p_gateways_connection_idempotency_policy.h | 17 ++ .../internal/app_gateways_auth_decorator.cc | 42 +++++ .../v1/internal/app_gateways_auth_decorator.h | 20 ++ .../internal/app_gateways_connection_impl.cc | 91 +++++++++ .../internal/app_gateways_connection_impl.h | 15 ++ .../app_gateways_logging_decorator.cc | 58 ++++++ .../internal/app_gateways_logging_decorator.h | 20 ++ .../app_gateways_metadata_decorator.cc | 46 +++++ .../app_gateways_metadata_decorator.h | 20 ++ .../v1/internal/app_gateways_stub.cc | 59 ++++++ .../v1/internal/app_gateways_stub.h | 57 +++++- .../v1/internal/app_gateways_stub_factory.cc | 8 +- .../app_gateways_tracing_connection.cc | 48 +++++ .../app_gateways_tracing_connection.h | 15 ++ .../v1/internal/app_gateways_tracing_stub.cc | 63 +++++++ .../v1/internal/app_gateways_tracing_stub.h | 20 ++ .../v1/mocks/mock_app_gateways_connection.h | 21 +++ google/cloud/bigquery/BUILD.bazel | 2 + .../datatransfer/v1/data_transfer_client.cc | 14 ++ .../datatransfer/v1/data_transfer_client.h | 71 +++++++ .../v1/data_transfer_connection.cc | 14 ++ .../v1/data_transfer_connection.h | 7 + ..._transfer_connection_idempotency_policy.cc | 10 + ...a_transfer_connection_idempotency_policy.h | 7 + .../internal/data_transfer_auth_decorator.cc | 18 ++ .../internal/data_transfer_auth_decorator.h | 8 + .../internal/data_transfer_connection_impl.cc | 49 +++++ .../internal/data_transfer_connection_impl.h | 6 + .../data_transfer_logging_decorator.cc | 24 +++ .../data_transfer_logging_decorator.h | 8 + .../data_transfer_metadata_decorator.cc | 18 ++ .../data_transfer_metadata_decorator.h | 8 + .../v1/internal/data_transfer_stub.cc | 24 +++ .../v1/internal/data_transfer_stub.h | 28 ++- .../v1/internal/data_transfer_stub_factory.cc | 5 +- .../data_transfer_tracing_connection.cc | 20 ++ .../data_transfer_tracing_connection.h | 6 + .../v1/internal/data_transfer_tracing_stub.cc | 26 +++ .../v1/internal/data_transfer_tracing_stub.h | 8 + .../v1/mocks/mock_data_transfer_connection.h | 8 + google/cloud/certificatemanager/BUILD.bazel | 2 + .../v1/certificate_manager_client.cc | 14 ++ .../v1/certificate_manager_client.h | 70 +++++++ .../v1/certificate_manager_connection.cc | 14 ++ .../v1/certificate_manager_connection.h | 7 + ...e_manager_connection_idempotency_policy.cc | 10 + ...te_manager_connection_idempotency_policy.h | 7 + .../certificate_manager_auth_decorator.cc | 17 ++ .../certificate_manager_auth_decorator.h | 8 + .../certificate_manager_connection_impl.cc | 49 +++++ .../certificate_manager_connection_impl.h | 6 + .../certificate_manager_logging_decorator.cc | 24 +++ .../certificate_manager_logging_decorator.h | 8 + .../certificate_manager_metadata_decorator.cc | 18 ++ .../certificate_manager_metadata_decorator.h | 8 + .../v1/internal/certificate_manager_stub.cc | 24 +++ .../v1/internal/certificate_manager_stub.h | 27 ++- .../certificate_manager_stub_factory.cc | 5 +- .../certificate_manager_tracing_connection.cc | 20 ++ .../certificate_manager_tracing_connection.h | 6 + .../certificate_manager_tracing_stub.cc | 24 +++ .../certificate_manager_tracing_stub.h | 8 + .../mock_certificate_manager_connection.h | 8 + google/cloud/cloudbuild/BUILD.bazel | 2 + .../repository_manager_auth_decorator.cc | 25 +++ .../repository_manager_auth_decorator.h | 12 ++ .../repository_manager_connection_impl.cc | 40 ++++ .../repository_manager_connection_impl.h | 9 + .../repository_manager_logging_decorator.cc | 34 ++++ .../repository_manager_logging_decorator.h | 12 ++ .../repository_manager_metadata_decorator.cc | 28 +++ .../repository_manager_metadata_decorator.h | 12 ++ .../v2/internal/repository_manager_stub.cc | 35 ++++ .../v2/internal/repository_manager_stub.h | 34 +++- .../repository_manager_stub_factory.cc | 4 +- .../repository_manager_tracing_connection.cc | 27 +++ .../repository_manager_tracing_connection.h | 9 + .../repository_manager_tracing_stub.cc | 34 ++++ .../repository_manager_tracing_stub.h | 12 ++ .../mock_repository_manager_connection.h | 13 ++ .../v2/repository_manager_client.cc | 19 ++ .../cloudbuild/v2/repository_manager_client.h | 102 +++++++++++ .../v2/repository_manager_connection.cc | 16 ++ .../v2/repository_manager_connection.h | 11 ++ ...y_manager_connection_idempotency_policy.cc | 16 ++ ...ry_manager_connection_idempotency_policy.h | 10 + .../cloud/confidentialcomputing/BUILD.bazel | 2 + .../v1/confidential_computing_client.cc | 14 ++ .../v1/confidential_computing_client.h | 71 +++++++ .../v1/confidential_computing_connection.cc | 15 ++ .../v1/confidential_computing_connection.h | 8 + ...computing_connection_idempotency_policy.cc | 10 + ..._computing_connection_idempotency_policy.h | 7 + .../confidential_computing_auth_decorator.cc | 18 ++ .../confidential_computing_auth_decorator.h | 8 + .../confidential_computing_connection_impl.cc | 50 +++++ .../confidential_computing_connection_impl.h | 7 + ...onfidential_computing_logging_decorator.cc | 24 +++ ...confidential_computing_logging_decorator.h | 8 + ...nfidential_computing_metadata_decorator.cc | 18 ++ ...onfidential_computing_metadata_decorator.h | 8 + .../internal/confidential_computing_stub.cc | 24 +++ .../v1/internal/confidential_computing_stub.h | 28 ++- .../confidential_computing_stub_factory.cc | 5 +- ...nfidential_computing_tracing_connection.cc | 22 +++ ...onfidential_computing_tracing_connection.h | 6 + .../confidential_computing_tracing_stub.cc | 26 +++ .../confidential_computing_tracing_stub.h | 8 + .../mock_confidential_computing_connection.h | 8 + google/cloud/config/BUILD.bazel | 2 + google/cloud/config/v1/config_client.cc | 31 ++++ google/cloud/config/v1/config_client.h | 172 +++++++++++++++++ google/cloud/config/v1/config_connection.cc | 28 +++ google/cloud/config/v1/config_connection.h | 17 ++ .../config_connection_idempotency_policy.cc | 26 +++ .../v1/config_connection_idempotency_policy.h | 17 ++ .../v1/internal/config_auth_decorator.cc | 42 +++++ .../v1/internal/config_auth_decorator.h | 20 ++ .../v1/internal/config_connection_impl.cc | 87 +++++++++ .../v1/internal/config_connection_impl.h | 15 ++ .../v1/internal/config_logging_decorator.cc | 57 ++++++ .../v1/internal/config_logging_decorator.h | 20 ++ .../v1/internal/config_metadata_decorator.cc | 45 +++++ .../v1/internal/config_metadata_decorator.h | 20 ++ .../cloud/config/v1/internal/config_stub.cc | 58 ++++++ google/cloud/config/v1/internal/config_stub.h | 57 +++++- .../config/v1/internal/config_stub_factory.cc | 8 +- .../v1/internal/config_tracing_connection.cc | 41 +++++ .../v1/internal/config_tracing_connection.h | 15 ++ .../config/v1/internal/config_tracing_stub.cc | 57 ++++++ .../config/v1/internal/config_tracing_stub.h | 20 ++ .../config/v1/mocks/mock_config_connection.h | 21 +++ google/cloud/connectors/BUILD.bazel | 2 + .../cloud/connectors/v1/connectors_client.cc | 31 ++++ .../cloud/connectors/v1/connectors_client.h | 172 +++++++++++++++++ .../connectors/v1/connectors_connection.cc | 29 +++ .../connectors/v1/connectors_connection.h | 17 ++ ...onnectors_connection_idempotency_policy.cc | 26 +++ ...connectors_connection_idempotency_policy.h | 17 ++ .../v1/internal/connectors_auth_decorator.cc | 42 +++++ .../v1/internal/connectors_auth_decorator.h | 20 ++ .../v1/internal/connectors_connection_impl.cc | 88 +++++++++ .../v1/internal/connectors_connection_impl.h | 15 ++ .../internal/connectors_logging_decorator.cc | 57 ++++++ .../internal/connectors_logging_decorator.h | 20 ++ .../internal/connectors_metadata_decorator.cc | 45 +++++ .../internal/connectors_metadata_decorator.h | 20 ++ .../connectors/v1/internal/connectors_stub.cc | 58 ++++++ .../connectors/v1/internal/connectors_stub.h | 57 +++++- .../v1/internal/connectors_stub_factory.cc | 8 +- .../internal/connectors_tracing_connection.cc | 45 +++++ .../internal/connectors_tracing_connection.h | 15 ++ .../v1/internal/connectors_tracing_stub.cc | 57 ++++++ .../v1/internal/connectors_tracing_stub.h | 20 ++ .../v1/mocks/mock_connectors_connection.h | 21 +++ google/cloud/datacatalog/BUILD.bazel | 2 + .../datacatalog/v1/data_catalog_connection.h | 1 + .../v1/internal/data_catalog_stub.h | 1 + .../policy_tag_manager_serialization_stub.h | 1 + .../v1/internal/policy_tag_manager_stub.h | 1 + .../v1/policy_tag_manager_connection.h | 1 + ...icy_tag_manager_serialization_connection.h | 1 + google/cloud/dataplex/BUILD.bazel | 2 + google/cloud/dataplex/v1/catalog_client.cc | 32 ++++ google/cloud/dataplex/v1/catalog_client.h | 172 +++++++++++++++++ .../cloud/dataplex/v1/catalog_connection.cc | 30 +++ google/cloud/dataplex/v1/catalog_connection.h | 17 ++ .../catalog_connection_idempotency_policy.cc | 26 +++ .../catalog_connection_idempotency_policy.h | 17 ++ google/cloud/dataplex/v1/content_client.cc | 13 ++ google/cloud/dataplex/v1/content_client.h | 70 +++++++ .../cloud/dataplex/v1/content_connection.cc | 14 ++ google/cloud/dataplex/v1/content_connection.h | 8 + .../content_connection_idempotency_policy.cc | 10 + .../content_connection_idempotency_policy.h | 7 + google/cloud/dataplex/v1/data_scan_client.cc | 32 ++++ google/cloud/dataplex/v1/data_scan_client.h | 172 +++++++++++++++++ .../cloud/dataplex/v1/data_scan_connection.cc | 30 +++ .../cloud/dataplex/v1/data_scan_connection.h | 17 ++ ...data_scan_connection_idempotency_policy.cc | 26 +++ .../data_scan_connection_idempotency_policy.h | 17 ++ .../cloud/dataplex/v1/data_taxonomy_client.cc | 33 ++++ .../cloud/dataplex/v1/data_taxonomy_client.h | 172 +++++++++++++++++ .../dataplex/v1/data_taxonomy_connection.cc | 30 +++ .../dataplex/v1/data_taxonomy_connection.h | 17 ++ ..._taxonomy_connection_idempotency_policy.cc | 26 +++ ...a_taxonomy_connection_idempotency_policy.h | 17 ++ google/cloud/dataplex/v1/dataplex_client.cc | 32 ++++ google/cloud/dataplex/v1/dataplex_client.h | 172 +++++++++++++++++ .../cloud/dataplex/v1/dataplex_connection.cc | 30 +++ .../cloud/dataplex/v1/dataplex_connection.h | 17 ++ .../dataplex_connection_idempotency_policy.cc | 26 +++ .../dataplex_connection_idempotency_policy.h | 17 ++ .../v1/internal/catalog_auth_decorator.cc | 42 +++++ .../v1/internal/catalog_auth_decorator.h | 20 ++ .../v1/internal/catalog_connection_impl.cc | 88 +++++++++ .../v1/internal/catalog_connection_impl.h | 15 ++ .../v1/internal/catalog_logging_decorator.cc | 57 ++++++ .../v1/internal/catalog_logging_decorator.h | 20 ++ .../v1/internal/catalog_metadata_decorator.cc | 45 +++++ .../v1/internal/catalog_metadata_decorator.h | 20 ++ .../dataplex/v1/internal/catalog_stub.cc | 59 ++++++ .../cloud/dataplex/v1/internal/catalog_stub.h | 57 +++++- .../v1/internal/catalog_stub_factory.cc | 8 +- .../v1/internal/catalog_tracing_connection.cc | 45 +++++ .../v1/internal/catalog_tracing_connection.h | 15 ++ .../v1/internal/catalog_tracing_stub.cc | 58 ++++++ .../v1/internal/catalog_tracing_stub.h | 20 ++ .../v1/internal/content_auth_decorator.cc | 17 ++ .../v1/internal/content_auth_decorator.h | 8 + .../v1/internal/content_connection_impl.cc | 48 +++++ .../v1/internal/content_connection_impl.h | 6 + .../v1/internal/content_logging_decorator.cc | 23 +++ .../v1/internal/content_logging_decorator.h | 8 + .../v1/internal/content_metadata_decorator.cc | 17 ++ .../v1/internal/content_metadata_decorator.h | 8 + .../dataplex/v1/internal/content_stub.cc | 24 +++ .../cloud/dataplex/v1/internal/content_stub.h | 29 ++- .../v1/internal/content_stub_factory.cc | 6 +- .../v1/internal/content_tracing_connection.cc | 20 ++ .../v1/internal/content_tracing_connection.h | 6 + .../v1/internal/content_tracing_stub.cc | 24 +++ .../v1/internal/content_tracing_stub.h | 8 + .../v1/internal/data_scan_auth_decorator.cc | 42 +++++ .../v1/internal/data_scan_auth_decorator.h | 20 ++ .../v1/internal/data_scan_connection_impl.cc | 88 +++++++++ .../v1/internal/data_scan_connection_impl.h | 15 ++ .../internal/data_scan_logging_decorator.cc | 57 ++++++ .../v1/internal/data_scan_logging_decorator.h | 20 ++ .../internal/data_scan_metadata_decorator.cc | 46 +++++ .../internal/data_scan_metadata_decorator.h | 20 ++ .../dataplex/v1/internal/data_scan_stub.cc | 59 ++++++ .../dataplex/v1/internal/data_scan_stub.h | 57 +++++- .../v1/internal/data_scan_stub_factory.cc | 8 +- .../internal/data_scan_tracing_connection.cc | 47 +++++ .../internal/data_scan_tracing_connection.h | 15 ++ .../v1/internal/data_scan_tracing_stub.cc | 58 ++++++ .../v1/internal/data_scan_tracing_stub.h | 20 ++ .../internal/data_taxonomy_auth_decorator.cc | 43 +++++ .../internal/data_taxonomy_auth_decorator.h | 20 ++ .../internal/data_taxonomy_connection_impl.cc | 90 +++++++++ .../internal/data_taxonomy_connection_impl.h | 15 ++ .../data_taxonomy_logging_decorator.cc | 58 ++++++ .../data_taxonomy_logging_decorator.h | 20 ++ .../data_taxonomy_metadata_decorator.cc | 46 +++++ .../data_taxonomy_metadata_decorator.h | 20 ++ .../v1/internal/data_taxonomy_stub.cc | 59 ++++++ .../dataplex/v1/internal/data_taxonomy_stub.h | 57 +++++- .../v1/internal/data_taxonomy_stub_factory.cc | 8 +- .../data_taxonomy_tracing_connection.cc | 47 +++++ .../data_taxonomy_tracing_connection.h | 15 ++ .../v1/internal/data_taxonomy_tracing_stub.cc | 58 ++++++ .../v1/internal/data_taxonomy_tracing_stub.h | 20 ++ .../v1/internal/dataplex_auth_decorator.cc | 42 +++++ .../v1/internal/dataplex_auth_decorator.h | 20 ++ .../v1/internal/dataplex_connection_impl.cc | 88 +++++++++ .../v1/internal/dataplex_connection_impl.h | 15 ++ .../v1/internal/dataplex_logging_decorator.cc | 57 ++++++ .../v1/internal/dataplex_logging_decorator.h | 20 ++ .../internal/dataplex_metadata_decorator.cc | 46 +++++ .../v1/internal/dataplex_metadata_decorator.h | 20 ++ .../dataplex/v1/internal/dataplex_stub.cc | 59 ++++++ .../dataplex/v1/internal/dataplex_stub.h | 57 +++++- .../v1/internal/dataplex_stub_factory.cc | 8 +- .../internal/dataplex_tracing_connection.cc | 47 +++++ .../v1/internal/dataplex_tracing_connection.h | 15 ++ .../v1/internal/dataplex_tracing_stub.cc | 58 ++++++ .../v1/internal/dataplex_tracing_stub.h | 20 ++ .../v1/internal/metadata_auth_decorator.cc | 42 +++++ .../v1/internal/metadata_auth_decorator.h | 20 ++ .../v1/internal/metadata_connection_impl.cc | 88 +++++++++ .../v1/internal/metadata_connection_impl.h | 15 ++ .../v1/internal/metadata_logging_decorator.cc | 57 ++++++ .../v1/internal/metadata_logging_decorator.h | 20 ++ .../internal/metadata_metadata_decorator.cc | 46 +++++ .../v1/internal/metadata_metadata_decorator.h | 20 ++ .../dataplex/v1/internal/metadata_stub.cc | 59 ++++++ .../dataplex/v1/internal/metadata_stub.h | 58 +++++- .../v1/internal/metadata_stub_factory.cc | 8 +- .../internal/metadata_tracing_connection.cc | 47 +++++ .../v1/internal/metadata_tracing_connection.h | 15 ++ .../v1/internal/metadata_tracing_stub.cc | 58 ++++++ .../v1/internal/metadata_tracing_stub.h | 20 ++ google/cloud/dataplex/v1/metadata_client.cc | 32 ++++ google/cloud/dataplex/v1/metadata_client.h | 173 ++++++++++++++++++ .../cloud/dataplex/v1/metadata_connection.cc | 30 +++ .../cloud/dataplex/v1/metadata_connection.h | 17 ++ .../metadata_connection_idempotency_policy.cc | 26 +++ .../metadata_connection_idempotency_policy.h | 17 ++ .../v1/mocks/mock_catalog_connection.h | 21 +++ .../v1/mocks/mock_content_connection.h | 8 + .../v1/mocks/mock_data_scan_connection.h | 21 +++ .../v1/mocks/mock_data_taxonomy_connection.h | 21 +++ .../v1/mocks/mock_dataplex_connection.h | 21 +++ .../v1/mocks/mock_metadata_connection.h | 21 +++ google/cloud/dataproc/BUILD.bazel | 2 + .../dataproc/v1/autoscaling_policy_client.cc | 19 ++ .../dataproc/v1/autoscaling_policy_client.h | 102 +++++++++++ .../v1/autoscaling_policy_connection.cc | 18 ++ .../v1/autoscaling_policy_connection.h | 10 + ...ng_policy_connection_idempotency_policy.cc | 17 ++ ...ing_policy_connection_idempotency_policy.h | 10 + .../dataproc/v1/batch_controller_client.cc | 19 ++ .../dataproc/v1/batch_controller_client.h | 102 +++++++++++ .../v1/batch_controller_connection.cc | 16 ++ .../dataproc/v1/batch_controller_connection.h | 10 + ...ontroller_connection_idempotency_policy.cc | 16 ++ ...controller_connection_idempotency_policy.h | 10 + .../dataproc/v1/cluster_controller_client.cc | 19 ++ .../dataproc/v1/cluster_controller_client.h | 102 +++++++++++ .../v1/cluster_controller_connection.cc | 16 ++ .../v1/cluster_controller_connection.h | 10 + ...ontroller_connection_idempotency_policy.cc | 16 ++ ...controller_connection_idempotency_policy.h | 10 + .../autoscaling_policy_auth_decorator.cc | 25 +++ .../autoscaling_policy_auth_decorator.h | 12 ++ .../autoscaling_policy_connection_impl.cc | 42 +++++ .../autoscaling_policy_connection_impl.h | 9 + .../autoscaling_policy_logging_decorator.cc | 34 ++++ .../autoscaling_policy_logging_decorator.h | 12 ++ .../autoscaling_policy_metadata_decorator.cc | 30 +++ .../autoscaling_policy_metadata_decorator.h | 12 ++ .../v1/internal/autoscaling_policy_stub.cc | 37 ++++ .../v1/internal/autoscaling_policy_stub.h | 34 +++- .../autoscaling_policy_stub_factory.cc | 4 +- .../autoscaling_policy_tracing_connection.cc | 27 +++ .../autoscaling_policy_tracing_connection.h | 9 + .../autoscaling_policy_tracing_stub.cc | 37 ++++ .../autoscaling_policy_tracing_stub.h | 12 ++ .../batch_controller_auth_decorator.cc | 25 +++ .../batch_controller_auth_decorator.h | 12 ++ .../batch_controller_connection_impl.cc | 40 ++++ .../batch_controller_connection_impl.h | 9 + .../batch_controller_logging_decorator.cc | 34 ++++ .../batch_controller_logging_decorator.h | 12 ++ .../batch_controller_metadata_decorator.cc | 28 +++ .../batch_controller_metadata_decorator.h | 12 ++ .../v1/internal/batch_controller_stub.cc | 35 ++++ .../v1/internal/batch_controller_stub.h | 33 +++- .../internal/batch_controller_stub_factory.cc | 4 +- .../batch_controller_tracing_connection.cc | 27 +++ .../batch_controller_tracing_connection.h | 9 + .../internal/batch_controller_tracing_stub.cc | 34 ++++ .../internal/batch_controller_tracing_stub.h | 12 ++ .../cluster_controller_auth_decorator.cc | 25 +++ .../cluster_controller_auth_decorator.h | 12 ++ .../cluster_controller_connection_impl.cc | 40 ++++ .../cluster_controller_connection_impl.h | 9 + .../cluster_controller_logging_decorator.cc | 34 ++++ .../cluster_controller_logging_decorator.h | 12 ++ .../cluster_controller_metadata_decorator.cc | 28 +++ .../cluster_controller_metadata_decorator.h | 12 ++ .../v1/internal/cluster_controller_stub.cc | 35 ++++ .../v1/internal/cluster_controller_stub.h | 33 +++- .../cluster_controller_stub_factory.cc | 4 +- .../cluster_controller_tracing_connection.cc | 27 +++ .../cluster_controller_tracing_connection.h | 9 + .../cluster_controller_tracing_stub.cc | 34 ++++ .../cluster_controller_tracing_stub.h | 12 ++ .../internal/job_controller_auth_decorator.cc | 25 +++ .../internal/job_controller_auth_decorator.h | 12 ++ .../job_controller_connection_impl.cc | 40 ++++ .../internal/job_controller_connection_impl.h | 9 + .../job_controller_logging_decorator.cc | 34 ++++ .../job_controller_logging_decorator.h | 12 ++ .../job_controller_metadata_decorator.cc | 28 +++ .../job_controller_metadata_decorator.h | 12 ++ .../v1/internal/job_controller_stub.cc | 35 ++++ .../v1/internal/job_controller_stub.h | 33 +++- .../internal/job_controller_stub_factory.cc | 4 +- .../job_controller_tracing_connection.cc | 25 +++ .../job_controller_tracing_connection.h | 9 + .../internal/job_controller_tracing_stub.cc | 34 ++++ .../v1/internal/job_controller_tracing_stub.h | 12 ++ .../node_group_controller_auth_decorator.cc | 25 +++ .../node_group_controller_auth_decorator.h | 12 ++ .../node_group_controller_connection_impl.cc | 42 +++++ .../node_group_controller_connection_impl.h | 9 + ...node_group_controller_logging_decorator.cc | 34 ++++ .../node_group_controller_logging_decorator.h | 12 ++ ...ode_group_controller_metadata_decorator.cc | 28 +++ ...node_group_controller_metadata_decorator.h | 12 ++ .../v1/internal/node_group_controller_stub.cc | 35 ++++ .../v1/internal/node_group_controller_stub.h | 33 +++- .../node_group_controller_stub_factory.cc | 4 +- ...ode_group_controller_tracing_connection.cc | 27 +++ ...node_group_controller_tracing_connection.h | 9 + .../node_group_controller_tracing_stub.cc | 34 ++++ .../node_group_controller_tracing_stub.h | 12 ++ .../session_controller_auth_decorator.cc | 25 +++ .../session_controller_auth_decorator.h | 12 ++ .../session_controller_connection_impl.cc | 40 ++++ .../session_controller_connection_impl.h | 9 + .../session_controller_logging_decorator.cc | 34 ++++ .../session_controller_logging_decorator.h | 12 ++ .../session_controller_metadata_decorator.cc | 28 +++ .../session_controller_metadata_decorator.h | 12 ++ .../v1/internal/session_controller_stub.cc | 35 ++++ .../v1/internal/session_controller_stub.h | 33 +++- .../session_controller_stub_factory.cc | 4 +- .../session_controller_tracing_connection.cc | 27 +++ .../session_controller_tracing_connection.h | 9 + .../session_controller_tracing_stub.cc | 34 ++++ .../session_controller_tracing_stub.h | 12 ++ ...sion_template_controller_auth_decorator.cc | 25 +++ ...ssion_template_controller_auth_decorator.h | 12 ++ ...ion_template_controller_connection_impl.cc | 42 +++++ ...sion_template_controller_connection_impl.h | 9 + ...n_template_controller_logging_decorator.cc | 36 ++++ ...on_template_controller_logging_decorator.h | 12 ++ ..._template_controller_metadata_decorator.cc | 30 +++ ...n_template_controller_metadata_decorator.h | 12 ++ .../session_template_controller_stub.cc | 37 ++++ .../session_template_controller_stub.h | 34 +++- ...ession_template_controller_stub_factory.cc | 4 +- ..._template_controller_tracing_connection.cc | 27 +++ ...n_template_controller_tracing_connection.h | 9 + ...ession_template_controller_tracing_stub.cc | 37 ++++ ...session_template_controller_tracing_stub.h | 12 ++ .../workflow_template_auth_decorator.cc | 25 +++ .../workflow_template_auth_decorator.h | 12 ++ .../workflow_template_connection_impl.cc | 42 +++++ .../workflow_template_connection_impl.h | 9 + .../workflow_template_logging_decorator.cc | 34 ++++ .../workflow_template_logging_decorator.h | 12 ++ .../workflow_template_metadata_decorator.cc | 28 +++ .../workflow_template_metadata_decorator.h | 12 ++ .../v1/internal/workflow_template_stub.cc | 37 ++++ .../v1/internal/workflow_template_stub.h | 33 +++- .../workflow_template_stub_factory.cc | 4 +- .../workflow_template_tracing_connection.cc | 27 +++ .../workflow_template_tracing_connection.h | 9 + .../workflow_template_tracing_stub.cc | 36 ++++ .../internal/workflow_template_tracing_stub.h | 12 ++ .../dataproc/v1/job_controller_client.cc | 19 ++ .../cloud/dataproc/v1/job_controller_client.h | 102 +++++++++++ .../dataproc/v1/job_controller_connection.cc | 16 ++ .../dataproc/v1/job_controller_connection.h | 10 + ...ontroller_connection_idempotency_policy.cc | 16 ++ ...controller_connection_idempotency_policy.h | 10 + .../mock_autoscaling_policy_connection.h | 13 ++ .../mocks/mock_batch_controller_connection.h | 13 ++ .../mock_cluster_controller_connection.h | 13 ++ .../v1/mocks/mock_job_controller_connection.h | 13 ++ .../mock_node_group_controller_connection.h | 13 ++ .../mock_session_controller_connection.h | 13 ++ ...k_session_template_controller_connection.h | 13 ++ .../mocks/mock_workflow_template_connection.h | 13 ++ .../v1/node_group_controller_client.cc | 19 ++ .../v1/node_group_controller_client.h | 102 +++++++++++ .../v1/node_group_controller_connection.cc | 16 ++ .../v1/node_group_controller_connection.h | 10 + ...ontroller_connection_idempotency_policy.cc | 16 ++ ...controller_connection_idempotency_policy.h | 10 + .../dataproc/v1/session_controller_client.cc | 19 ++ .../dataproc/v1/session_controller_client.h | 102 +++++++++++ .../v1/session_controller_connection.cc | 16 ++ .../v1/session_controller_connection.h | 10 + ...ontroller_connection_idempotency_policy.cc | 16 ++ ...controller_connection_idempotency_policy.h | 10 + .../v1/session_template_controller_client.cc | 19 ++ .../v1/session_template_controller_client.h | 102 +++++++++++ .../session_template_controller_connection.cc | 18 ++ .../session_template_controller_connection.h | 10 + ...ontroller_connection_idempotency_policy.cc | 17 ++ ...controller_connection_idempotency_policy.h | 10 + .../dataproc/v1/workflow_template_client.cc | 19 ++ .../dataproc/v1/workflow_template_client.h | 102 +++++++++++ .../v1/workflow_template_connection.cc | 18 ++ .../v1/workflow_template_connection.h | 10 + ..._template_connection_idempotency_policy.cc | 17 ++ ...w_template_connection_idempotency_policy.h | 10 + google/cloud/datastream/BUILD.bazel | 2 + .../cloud/datastream/v1/datastream_client.cc | 12 ++ .../cloud/datastream/v1/datastream_client.h | 70 +++++++ .../datastream/v1/datastream_connection.cc | 13 ++ .../datastream/v1/datastream_connection.h | 8 + ...atastream_connection_idempotency_policy.cc | 10 + ...datastream_connection_idempotency_policy.h | 7 + .../v1/internal/datastream_auth_decorator.cc | 17 ++ .../v1/internal/datastream_auth_decorator.h | 8 + .../v1/internal/datastream_connection_impl.cc | 48 +++++ .../v1/internal/datastream_connection_impl.h | 6 + .../internal/datastream_logging_decorator.cc | 23 +++ .../internal/datastream_logging_decorator.h | 8 + .../internal/datastream_metadata_decorator.cc | 17 ++ .../internal/datastream_metadata_decorator.h | 8 + .../datastream/v1/internal/datastream_stub.cc | 23 +++ .../datastream/v1/internal/datastream_stub.h | 28 ++- .../v1/internal/datastream_stub_factory.cc | 5 +- .../internal/datastream_tracing_connection.cc | 20 ++ .../internal/datastream_tracing_connection.h | 6 + .../v1/internal/datastream_tracing_stub.cc | 23 +++ .../v1/internal/datastream_tracing_stub.h | 8 + .../v1/mocks/mock_datastream_connection.h | 8 + google/cloud/deploy/BUILD.bazel | 2 + google/cloud/deploy/v1/cloud_deploy_client.cc | 31 ++++ google/cloud/deploy/v1/cloud_deploy_client.h | 172 +++++++++++++++++ .../deploy/v1/cloud_deploy_connection.cc | 29 +++ .../cloud/deploy/v1/cloud_deploy_connection.h | 17 ++ ...ud_deploy_connection_idempotency_policy.cc | 26 +++ ...oud_deploy_connection_idempotency_policy.h | 17 ++ .../internal/cloud_deploy_auth_decorator.cc | 42 +++++ .../v1/internal/cloud_deploy_auth_decorator.h | 20 ++ .../internal/cloud_deploy_connection_impl.cc | 88 +++++++++ .../internal/cloud_deploy_connection_impl.h | 15 ++ .../cloud_deploy_logging_decorator.cc | 57 ++++++ .../internal/cloud_deploy_logging_decorator.h | 20 ++ .../cloud_deploy_metadata_decorator.cc | 45 +++++ .../cloud_deploy_metadata_decorator.h | 20 ++ .../deploy/v1/internal/cloud_deploy_stub.cc | 58 ++++++ .../deploy/v1/internal/cloud_deploy_stub.h | 57 +++++- .../v1/internal/cloud_deploy_stub_factory.cc | 8 +- .../cloud_deploy_tracing_connection.cc | 45 +++++ .../cloud_deploy_tracing_connection.h | 15 ++ .../v1/internal/cloud_deploy_tracing_stub.cc | 57 ++++++ .../v1/internal/cloud_deploy_tracing_stub.h | 20 ++ .../v1/mocks/mock_cloud_deploy_connection.h | 21 +++ google/cloud/developerconnect/BUILD.bazel | 2 + .../v1/developer_connect_client.cc | 13 ++ .../v1/developer_connect_client.h | 70 +++++++ .../v1/developer_connect_connection.cc | 14 ++ .../v1/developer_connect_connection.h | 7 + ...r_connect_connection_idempotency_policy.cc | 10 + ...er_connect_connection_idempotency_policy.h | 7 + .../developer_connect_auth_decorator.cc | 17 ++ .../developer_connect_auth_decorator.h | 8 + .../developer_connect_connection_impl.cc | 49 +++++ .../developer_connect_connection_impl.h | 6 + .../developer_connect_logging_decorator.cc | 24 +++ .../developer_connect_logging_decorator.h | 8 + .../developer_connect_metadata_decorator.cc | 18 ++ .../developer_connect_metadata_decorator.h | 8 + .../v1/internal/developer_connect_stub.cc | 24 +++ .../v1/internal/developer_connect_stub.h | 27 ++- .../developer_connect_stub_factory.cc | 5 +- .../developer_connect_tracing_connection.cc | 20 ++ .../developer_connect_tracing_connection.h | 6 + .../developer_connect_tracing_stub.cc | 24 +++ .../internal/developer_connect_tracing_stub.h | 8 + .../mocks/mock_developer_connect_connection.h | 8 + google/cloud/dialogflow_cx/BUILD.bazel | 2 + google/cloud/dialogflow_cx/agents_client.cc | 12 ++ google/cloud/dialogflow_cx/agents_client.h | 71 +++++++ .../cloud/dialogflow_cx/agents_connection.cc | 12 ++ .../cloud/dialogflow_cx/agents_connection.h | 7 + .../agents_connection_idempotency_policy.cc | 10 + .../agents_connection_idempotency_policy.h | 7 + .../cloud/dialogflow_cx/changelogs_client.cc | 12 ++ .../cloud/dialogflow_cx/changelogs_client.h | 71 +++++++ .../dialogflow_cx/changelogs_connection.cc | 13 ++ .../dialogflow_cx/changelogs_connection.h | 7 + ...hangelogs_connection_idempotency_policy.cc | 10 + ...changelogs_connection_idempotency_policy.h | 7 + .../cloud/dialogflow_cx/deployments_client.cc | 12 ++ .../cloud/dialogflow_cx/deployments_client.h | 71 +++++++ .../dialogflow_cx/deployments_connection.cc | 13 ++ .../dialogflow_cx/deployments_connection.h | 7 + ...ployments_connection_idempotency_policy.cc | 10 + ...eployments_connection_idempotency_policy.h | 7 + .../dialogflow_cx/entity_types_client.cc | 12 ++ .../cloud/dialogflow_cx/entity_types_client.h | 71 +++++++ .../dialogflow_cx/entity_types_connection.cc | 13 ++ .../dialogflow_cx/entity_types_connection.h | 7 + ...ity_types_connection_idempotency_policy.cc | 10 + ...tity_types_connection_idempotency_policy.h | 7 + .../dialogflow_cx/environments_client.cc | 13 ++ .../cloud/dialogflow_cx/environments_client.h | 71 +++++++ .../dialogflow_cx/environments_connection.cc | 13 ++ .../dialogflow_cx/environments_connection.h | 7 + ...ironments_connection_idempotency_policy.cc | 10 + ...vironments_connection_idempotency_policy.h | 7 + .../cloud/dialogflow_cx/experiments_client.cc | 12 ++ .../cloud/dialogflow_cx/experiments_client.h | 71 +++++++ .../dialogflow_cx/experiments_connection.cc | 13 ++ .../dialogflow_cx/experiments_connection.h | 7 + ...periments_connection_idempotency_policy.cc | 10 + ...xperiments_connection_idempotency_policy.h | 7 + google/cloud/dialogflow_cx/flows_client.cc | 12 ++ google/cloud/dialogflow_cx/flows_client.h | 71 +++++++ .../cloud/dialogflow_cx/flows_connection.cc | 12 ++ google/cloud/dialogflow_cx/flows_connection.h | 7 + .../flows_connection_idempotency_policy.cc | 10 + .../flows_connection_idempotency_policy.h | 7 + .../cloud/dialogflow_cx/generators_client.cc | 12 ++ .../cloud/dialogflow_cx/generators_client.h | 71 +++++++ .../dialogflow_cx/generators_connection.cc | 13 ++ .../dialogflow_cx/generators_connection.h | 7 + ...enerators_connection_idempotency_policy.cc | 10 + ...generators_connection_idempotency_policy.h | 7 + google/cloud/dialogflow_cx/intents_client.cc | 12 ++ google/cloud/dialogflow_cx/intents_client.h | 70 +++++++ .../cloud/dialogflow_cx/intents_connection.cc | 12 ++ .../cloud/dialogflow_cx/intents_connection.h | 7 + .../intents_connection_idempotency_policy.cc | 10 + .../intents_connection_idempotency_policy.h | 7 + .../internal/agents_auth_decorator.cc | 17 ++ .../internal/agents_auth_decorator.h | 8 + .../internal/agents_connection_impl.cc | 47 +++++ .../internal/agents_connection_impl.h | 6 + .../internal/agents_logging_decorator.cc | 23 +++ .../internal/agents_logging_decorator.h | 8 + .../internal/agents_metadata_decorator.cc | 17 ++ .../internal/agents_metadata_decorator.h | 8 + .../dialogflow_cx/internal/agents_stub.cc | 23 +++ .../dialogflow_cx/internal/agents_stub.h | 27 ++- .../internal/agents_stub_factory.cc | 5 +- .../internal/agents_tracing_connection.cc | 20 ++ .../internal/agents_tracing_connection.h | 6 + .../internal/agents_tracing_stub.cc | 23 +++ .../internal/agents_tracing_stub.h | 8 + .../internal/changelogs_auth_decorator.cc | 17 ++ .../internal/changelogs_auth_decorator.h | 8 + .../internal/changelogs_connection_impl.cc | 48 +++++ .../internal/changelogs_connection_impl.h | 6 + .../internal/changelogs_logging_decorator.cc | 23 +++ .../internal/changelogs_logging_decorator.h | 8 + .../internal/changelogs_metadata_decorator.cc | 17 ++ .../internal/changelogs_metadata_decorator.h | 8 + .../dialogflow_cx/internal/changelogs_stub.cc | 23 +++ .../dialogflow_cx/internal/changelogs_stub.h | 28 ++- .../internal/changelogs_stub_factory.cc | 6 +- .../internal/changelogs_tracing_connection.cc | 20 ++ .../internal/changelogs_tracing_connection.h | 6 + .../internal/changelogs_tracing_stub.cc | 23 +++ .../internal/changelogs_tracing_stub.h | 8 + .../internal/deployments_auth_decorator.cc | 17 ++ .../internal/deployments_auth_decorator.h | 8 + .../internal/deployments_connection_impl.cc | 48 +++++ .../internal/deployments_connection_impl.h | 6 + .../internal/deployments_logging_decorator.cc | 23 +++ .../internal/deployments_logging_decorator.h | 8 + .../deployments_metadata_decorator.cc | 17 ++ .../internal/deployments_metadata_decorator.h | 8 + .../internal/deployments_stub.cc | 23 +++ .../dialogflow_cx/internal/deployments_stub.h | 28 ++- .../internal/deployments_stub_factory.cc | 6 +- .../deployments_tracing_connection.cc | 20 ++ .../internal/deployments_tracing_connection.h | 6 + .../internal/deployments_tracing_stub.cc | 23 +++ .../internal/deployments_tracing_stub.h | 8 + .../internal/entity_types_auth_decorator.cc | 17 ++ .../internal/entity_types_auth_decorator.h | 8 + .../internal/entity_types_connection_impl.cc | 48 +++++ .../internal/entity_types_connection_impl.h | 6 + .../entity_types_logging_decorator.cc | 23 +++ .../internal/entity_types_logging_decorator.h | 8 + .../entity_types_metadata_decorator.cc | 17 ++ .../entity_types_metadata_decorator.h | 8 + .../internal/entity_types_stub.cc | 23 +++ .../internal/entity_types_stub.h | 27 ++- .../internal/entity_types_stub_factory.cc | 5 +- .../entity_types_tracing_connection.cc | 20 ++ .../entity_types_tracing_connection.h | 6 + .../internal/entity_types_tracing_stub.cc | 23 +++ .../internal/entity_types_tracing_stub.h | 8 + .../internal/environments_auth_decorator.cc | 17 ++ .../internal/environments_auth_decorator.h | 8 + .../internal/environments_connection_impl.cc | 48 +++++ .../internal/environments_connection_impl.h | 6 + .../environments_logging_decorator.cc | 23 +++ .../internal/environments_logging_decorator.h | 8 + .../environments_metadata_decorator.cc | 17 ++ .../environments_metadata_decorator.h | 8 + .../internal/environments_stub.cc | 24 +++ .../internal/environments_stub.h | 27 ++- .../internal/environments_stub_factory.cc | 5 +- .../environments_tracing_connection.cc | 20 ++ .../environments_tracing_connection.h | 6 + .../internal/environments_tracing_stub.cc | 24 +++ .../internal/environments_tracing_stub.h | 8 + .../internal/experiments_auth_decorator.cc | 17 ++ .../internal/experiments_auth_decorator.h | 8 + .../internal/experiments_connection_impl.cc | 48 +++++ .../internal/experiments_connection_impl.h | 6 + .../internal/experiments_logging_decorator.cc | 23 +++ .../internal/experiments_logging_decorator.h | 8 + .../experiments_metadata_decorator.cc | 17 ++ .../internal/experiments_metadata_decorator.h | 8 + .../internal/experiments_stub.cc | 23 +++ .../dialogflow_cx/internal/experiments_stub.h | 28 ++- .../internal/experiments_stub_factory.cc | 6 +- .../experiments_tracing_connection.cc | 20 ++ .../internal/experiments_tracing_connection.h | 6 + .../internal/experiments_tracing_stub.cc | 23 +++ .../internal/experiments_tracing_stub.h | 8 + .../internal/flows_auth_decorator.cc | 17 ++ .../internal/flows_auth_decorator.h | 8 + .../internal/flows_connection_impl.cc | 47 +++++ .../internal/flows_connection_impl.h | 6 + .../internal/flows_logging_decorator.cc | 23 +++ .../internal/flows_logging_decorator.h | 8 + .../internal/flows_metadata_decorator.cc | 17 ++ .../internal/flows_metadata_decorator.h | 8 + .../dialogflow_cx/internal/flows_stub.cc | 23 +++ .../cloud/dialogflow_cx/internal/flows_stub.h | 27 ++- .../internal/flows_stub_factory.cc | 5 +- .../internal/flows_tracing_connection.cc | 18 ++ .../internal/flows_tracing_connection.h | 6 + .../internal/flows_tracing_stub.cc | 23 +++ .../internal/flows_tracing_stub.h | 8 + .../internal/generators_auth_decorator.cc | 17 ++ .../internal/generators_auth_decorator.h | 8 + .../internal/generators_connection_impl.cc | 48 +++++ .../internal/generators_connection_impl.h | 6 + .../internal/generators_logging_decorator.cc | 23 +++ .../internal/generators_logging_decorator.h | 8 + .../internal/generators_metadata_decorator.cc | 17 ++ .../internal/generators_metadata_decorator.h | 8 + .../dialogflow_cx/internal/generators_stub.cc | 23 +++ .../dialogflow_cx/internal/generators_stub.h | 28 ++- .../internal/generators_stub_factory.cc | 6 +- .../internal/generators_tracing_connection.cc | 20 ++ .../internal/generators_tracing_connection.h | 6 + .../internal/generators_tracing_stub.cc | 23 +++ .../internal/generators_tracing_stub.h | 8 + .../internal/intents_auth_decorator.cc | 17 ++ .../internal/intents_auth_decorator.h | 8 + .../internal/intents_connection_impl.cc | 47 +++++ .../internal/intents_connection_impl.h | 6 + .../internal/intents_logging_decorator.cc | 23 +++ .../internal/intents_logging_decorator.h | 8 + .../internal/intents_metadata_decorator.cc | 17 ++ .../internal/intents_metadata_decorator.h | 8 + .../dialogflow_cx/internal/intents_stub.cc | 23 +++ .../dialogflow_cx/internal/intents_stub.h | 27 ++- .../internal/intents_stub_factory.cc | 5 +- .../internal/intents_tracing_connection.cc | 20 ++ .../internal/intents_tracing_connection.h | 6 + .../internal/intents_tracing_stub.cc | 23 +++ .../internal/intents_tracing_stub.h | 8 + .../internal/pages_auth_decorator.cc | 17 ++ .../internal/pages_auth_decorator.h | 8 + .../internal/pages_connection_impl.cc | 47 +++++ .../internal/pages_connection_impl.h | 6 + .../internal/pages_logging_decorator.cc | 23 +++ .../internal/pages_logging_decorator.h | 8 + .../internal/pages_metadata_decorator.cc | 17 ++ .../internal/pages_metadata_decorator.h | 8 + .../dialogflow_cx/internal/pages_stub.cc | 23 +++ .../cloud/dialogflow_cx/internal/pages_stub.h | 28 ++- .../internal/pages_stub_factory.cc | 7 +- .../internal/pages_tracing_connection.cc | 18 ++ .../internal/pages_tracing_connection.h | 6 + .../internal/pages_tracing_stub.cc | 23 +++ .../internal/pages_tracing_stub.h | 8 + .../security_settings_auth_decorator.cc | 18 ++ .../security_settings_auth_decorator.h | 8 + .../security_settings_connection_impl.cc | 49 +++++ .../security_settings_connection_impl.h | 6 + .../security_settings_logging_decorator.cc | 24 +++ .../security_settings_logging_decorator.h | 8 + .../security_settings_metadata_decorator.cc | 18 ++ .../security_settings_metadata_decorator.h | 8 + .../internal/security_settings_stub.cc | 24 +++ .../internal/security_settings_stub.h | 28 ++- .../security_settings_stub_factory.cc | 5 +- .../security_settings_tracing_connection.cc | 20 ++ .../security_settings_tracing_connection.h | 6 + .../security_settings_tracing_stub.cc | 24 +++ .../internal/security_settings_tracing_stub.h | 8 + .../session_entity_types_auth_decorator.cc | 17 ++ .../session_entity_types_auth_decorator.h | 8 + .../session_entity_types_connection_impl.cc | 48 +++++ .../session_entity_types_connection_impl.h | 6 + .../session_entity_types_logging_decorator.cc | 24 +++ .../session_entity_types_logging_decorator.h | 8 + ...session_entity_types_metadata_decorator.cc | 18 ++ .../session_entity_types_metadata_decorator.h | 8 + .../internal/session_entity_types_stub.cc | 24 +++ .../internal/session_entity_types_stub.h | 28 ++- .../session_entity_types_stub_factory.cc | 5 +- ...session_entity_types_tracing_connection.cc | 20 ++ .../session_entity_types_tracing_connection.h | 6 + .../session_entity_types_tracing_stub.cc | 24 +++ .../session_entity_types_tracing_stub.h | 8 + .../internal/sessions_auth_decorator.cc | 17 ++ .../internal/sessions_auth_decorator.h | 8 + .../internal/sessions_connection_impl.cc | 48 +++++ .../internal/sessions_connection_impl.h | 6 + .../internal/sessions_logging_decorator.cc | 23 +++ .../internal/sessions_logging_decorator.h | 8 + .../internal/sessions_metadata_decorator.cc | 17 ++ .../internal/sessions_metadata_decorator.h | 8 + .../dialogflow_cx/internal/sessions_stub.cc | 23 +++ .../dialogflow_cx/internal/sessions_stub.h | 28 ++- .../internal/sessions_stub_factory.cc | 7 +- .../internal/sessions_tracing_connection.cc | 20 ++ .../internal/sessions_tracing_connection.h | 6 + .../internal/sessions_tracing_stub.cc | 23 +++ .../internal/sessions_tracing_stub.h | 8 + .../internal/test_cases_auth_decorator.cc | 17 ++ .../internal/test_cases_auth_decorator.h | 8 + .../internal/test_cases_connection_impl.cc | 48 +++++ .../internal/test_cases_connection_impl.h | 6 + .../internal/test_cases_logging_decorator.cc | 23 +++ .../internal/test_cases_logging_decorator.h | 8 + .../internal/test_cases_metadata_decorator.cc | 17 ++ .../internal/test_cases_metadata_decorator.h | 8 + .../dialogflow_cx/internal/test_cases_stub.cc | 23 +++ .../dialogflow_cx/internal/test_cases_stub.h | 27 ++- .../internal/test_cases_stub_factory.cc | 5 +- .../internal/test_cases_tracing_connection.cc | 20 ++ .../internal/test_cases_tracing_connection.h | 6 + .../internal/test_cases_tracing_stub.cc | 23 +++ .../internal/test_cases_tracing_stub.h | 8 + .../transition_route_groups_auth_decorator.cc | 18 ++ .../transition_route_groups_auth_decorator.h | 8 + ...transition_route_groups_connection_impl.cc | 48 +++++ .../transition_route_groups_connection_impl.h | 6 + ...ansition_route_groups_logging_decorator.cc | 24 +++ ...ransition_route_groups_logging_decorator.h | 8 + ...nsition_route_groups_metadata_decorator.cc | 18 ++ ...ansition_route_groups_metadata_decorator.h | 8 + .../internal/transition_route_groups_stub.cc | 24 +++ .../internal/transition_route_groups_stub.h | 28 ++- .../transition_route_groups_stub_factory.cc | 5 +- ...nsition_route_groups_tracing_connection.cc | 20 ++ ...ansition_route_groups_tracing_connection.h | 6 + .../transition_route_groups_tracing_stub.cc | 24 +++ .../transition_route_groups_tracing_stub.h | 8 + .../internal/versions_auth_decorator.cc | 17 ++ .../internal/versions_auth_decorator.h | 8 + .../internal/versions_connection_impl.cc | 47 +++++ .../internal/versions_connection_impl.h | 6 + .../internal/versions_logging_decorator.cc | 23 +++ .../internal/versions_logging_decorator.h | 8 + .../internal/versions_metadata_decorator.cc | 17 ++ .../internal/versions_metadata_decorator.h | 8 + .../dialogflow_cx/internal/versions_stub.cc | 23 +++ .../dialogflow_cx/internal/versions_stub.h | 27 ++- .../internal/versions_stub_factory.cc | 5 +- .../internal/versions_tracing_connection.cc | 20 ++ .../internal/versions_tracing_connection.h | 6 + .../internal/versions_tracing_stub.cc | 23 +++ .../internal/versions_tracing_stub.h | 8 + .../internal/webhooks_auth_decorator.cc | 17 ++ .../internal/webhooks_auth_decorator.h | 8 + .../internal/webhooks_connection_impl.cc | 47 +++++ .../internal/webhooks_connection_impl.h | 6 + .../internal/webhooks_logging_decorator.cc | 23 +++ .../internal/webhooks_logging_decorator.h | 8 + .../internal/webhooks_metadata_decorator.cc | 17 ++ .../internal/webhooks_metadata_decorator.h | 8 + .../dialogflow_cx/internal/webhooks_stub.cc | 23 +++ .../dialogflow_cx/internal/webhooks_stub.h | 28 ++- .../internal/webhooks_stub_factory.cc | 7 +- .../internal/webhooks_tracing_connection.cc | 20 ++ .../internal/webhooks_tracing_connection.h | 6 + .../internal/webhooks_tracing_stub.cc | 23 +++ .../internal/webhooks_tracing_stub.h | 8 + .../mocks/mock_agents_connection.h | 8 + .../mocks/mock_changelogs_connection.h | 8 + .../mocks/mock_deployments_connection.h | 8 + .../mocks/mock_entity_types_connection.h | 8 + .../mocks/mock_environments_connection.h | 8 + .../mocks/mock_experiments_connection.h | 8 + .../mocks/mock_flows_connection.h | 8 + .../mocks/mock_generators_connection.h | 8 + .../mocks/mock_intents_connection.h | 8 + .../mocks/mock_pages_connection.h | 8 + .../mocks/mock_security_settings_connection.h | 8 + .../mock_session_entity_types_connection.h | 8 + .../mocks/mock_sessions_connection.h | 8 + .../mocks/mock_test_cases_connection.h | 8 + .../mock_transition_route_groups_connection.h | 8 + .../mocks/mock_versions_connection.h | 8 + .../mocks/mock_webhooks_connection.h | 8 + google/cloud/dialogflow_cx/pages_client.cc | 12 ++ google/cloud/dialogflow_cx/pages_client.h | 71 +++++++ .../cloud/dialogflow_cx/pages_connection.cc | 12 ++ google/cloud/dialogflow_cx/pages_connection.h | 7 + .../pages_connection_idempotency_policy.cc | 10 + .../pages_connection_idempotency_policy.h | 7 + .../dialogflow_cx/security_settings_client.cc | 14 ++ .../dialogflow_cx/security_settings_client.h | 71 +++++++ .../security_settings_connection.cc | 14 ++ .../security_settings_connection.h | 7 + ..._settings_connection_idempotency_policy.cc | 10 + ...y_settings_connection_idempotency_policy.h | 7 + .../session_entity_types_client.cc | 14 ++ .../session_entity_types_client.h | 71 +++++++ .../session_entity_types_connection.cc | 14 ++ .../session_entity_types_connection.h | 7 + ...ity_types_connection_idempotency_policy.cc | 10 + ...tity_types_connection_idempotency_policy.h | 7 + google/cloud/dialogflow_cx/sessions_client.cc | 12 ++ google/cloud/dialogflow_cx/sessions_client.h | 71 +++++++ .../dialogflow_cx/sessions_connection.cc | 14 ++ .../cloud/dialogflow_cx/sessions_connection.h | 7 + .../sessions_connection_idempotency_policy.cc | 10 + .../sessions_connection_idempotency_policy.h | 7 + .../cloud/dialogflow_cx/test_cases_client.cc | 12 ++ .../cloud/dialogflow_cx/test_cases_client.h | 71 +++++++ .../dialogflow_cx/test_cases_connection.cc | 13 ++ .../dialogflow_cx/test_cases_connection.h | 7 + ...est_cases_connection_idempotency_policy.cc | 10 + ...test_cases_connection_idempotency_policy.h | 7 + .../transition_route_groups_client.cc | 14 ++ .../transition_route_groups_client.h | 71 +++++++ .../transition_route_groups_connection.cc | 14 ++ .../transition_route_groups_connection.h | 7 + ...te_groups_connection_idempotency_policy.cc | 10 + ...ute_groups_connection_idempotency_policy.h | 7 + google/cloud/dialogflow_cx/versions_client.cc | 12 ++ google/cloud/dialogflow_cx/versions_client.h | 71 +++++++ .../dialogflow_cx/versions_connection.cc | 13 ++ .../cloud/dialogflow_cx/versions_connection.h | 7 + .../versions_connection_idempotency_policy.cc | 10 + .../versions_connection_idempotency_policy.h | 7 + google/cloud/dialogflow_cx/webhooks_client.cc | 12 ++ google/cloud/dialogflow_cx/webhooks_client.h | 71 +++++++ .../dialogflow_cx/webhooks_connection.cc | 13 ++ .../cloud/dialogflow_cx/webhooks_connection.h | 7 + .../webhooks_connection_idempotency_policy.cc | 10 + .../webhooks_connection_idempotency_policy.h | 7 + google/cloud/dialogflow_es/BUILD.bazel | 2 + google/cloud/dialogflow_es/agents_client.cc | 12 ++ google/cloud/dialogflow_es/agents_client.h | 71 +++++++ .../cloud/dialogflow_es/agents_connection.cc | 12 ++ .../cloud/dialogflow_es/agents_connection.h | 7 + .../agents_connection_idempotency_policy.cc | 10 + .../agents_connection_idempotency_policy.h | 7 + .../dialogflow_es/answer_records_client.cc | 13 ++ .../dialogflow_es/answer_records_client.h | 71 +++++++ .../answer_records_connection.cc | 14 ++ .../dialogflow_es/answer_records_connection.h | 7 + ...r_records_connection_idempotency_policy.cc | 10 + ...er_records_connection_idempotency_policy.h | 7 + google/cloud/dialogflow_es/contexts_client.cc | 12 ++ google/cloud/dialogflow_es/contexts_client.h | 71 +++++++ .../dialogflow_es/contexts_connection.cc | 13 ++ .../cloud/dialogflow_es/contexts_connection.h | 7 + .../contexts_connection_idempotency_policy.cc | 10 + .../contexts_connection_idempotency_policy.h | 7 + .../conversation_datasets_client.cc | 14 ++ .../conversation_datasets_client.h | 71 +++++++ .../conversation_datasets_connection.cc | 14 ++ .../conversation_datasets_connection.h | 7 + ..._datasets_connection_idempotency_policy.cc | 10 + ...n_datasets_connection_idempotency_policy.h | 7 + .../conversation_models_client.cc | 14 ++ .../conversation_models_client.h | 71 +++++++ .../conversation_models_connection.cc | 14 ++ .../conversation_models_connection.h | 7 + ...on_models_connection_idempotency_policy.cc | 10 + ...ion_models_connection_idempotency_policy.h | 7 + .../conversation_profiles_client.cc | 14 ++ .../conversation_profiles_client.h | 71 +++++++ .../conversation_profiles_connection.cc | 14 ++ .../conversation_profiles_connection.h | 7 + ..._profiles_connection_idempotency_policy.cc | 10 + ...n_profiles_connection_idempotency_policy.h | 7 + .../dialogflow_es/conversations_client.cc | 13 ++ .../dialogflow_es/conversations_client.h | 71 +++++++ .../dialogflow_es/conversations_connection.cc | 14 ++ .../dialogflow_es/conversations_connection.h | 7 + ...ersations_connection_idempotency_policy.cc | 10 + ...versations_connection_idempotency_policy.h | 7 + .../cloud/dialogflow_es/documents_client.cc | 12 ++ google/cloud/dialogflow_es/documents_client.h | 70 +++++++ .../dialogflow_es/documents_connection.cc | 13 ++ .../dialogflow_es/documents_connection.h | 7 + ...documents_connection_idempotency_policy.cc | 10 + .../documents_connection_idempotency_policy.h | 7 + .../dialogflow_es/entity_types_client.cc | 12 ++ .../cloud/dialogflow_es/entity_types_client.h | 71 +++++++ .../dialogflow_es/entity_types_connection.cc | 13 ++ .../dialogflow_es/entity_types_connection.h | 7 + ...ity_types_connection_idempotency_policy.cc | 10 + ...tity_types_connection_idempotency_policy.h | 7 + .../dialogflow_es/environments_client.cc | 13 ++ .../cloud/dialogflow_es/environments_client.h | 71 +++++++ .../dialogflow_es/environments_connection.cc | 13 ++ .../dialogflow_es/environments_connection.h | 7 + ...ironments_connection_idempotency_policy.cc | 10 + ...vironments_connection_idempotency_policy.h | 7 + .../dialogflow_es/fulfillments_client.cc | 13 ++ .../cloud/dialogflow_es/fulfillments_client.h | 71 +++++++ .../dialogflow_es/fulfillments_connection.cc | 14 ++ .../dialogflow_es/fulfillments_connection.h | 8 + ...fillments_connection_idempotency_policy.cc | 10 + ...lfillments_connection_idempotency_policy.h | 7 + google/cloud/dialogflow_es/intents_client.cc | 12 ++ google/cloud/dialogflow_es/intents_client.h | 71 +++++++ .../cloud/dialogflow_es/intents_connection.cc | 12 ++ .../cloud/dialogflow_es/intents_connection.h | 7 + .../intents_connection_idempotency_policy.cc | 10 + .../intents_connection_idempotency_policy.h | 7 + .../internal/agents_auth_decorator.cc | 17 ++ .../internal/agents_auth_decorator.h | 8 + .../internal/agents_connection_impl.cc | 47 +++++ .../internal/agents_connection_impl.h | 6 + .../internal/agents_logging_decorator.cc | 23 +++ .../internal/agents_logging_decorator.h | 8 + .../internal/agents_metadata_decorator.cc | 17 ++ .../internal/agents_metadata_decorator.h | 8 + .../dialogflow_es/internal/agents_stub.cc | 23 +++ .../dialogflow_es/internal/agents_stub.h | 27 ++- .../internal/agents_stub_factory.cc | 5 +- .../internal/agents_tracing_connection.cc | 20 ++ .../internal/agents_tracing_connection.h | 6 + .../internal/agents_tracing_stub.cc | 23 +++ .../internal/agents_tracing_stub.h | 8 + .../internal/answer_records_auth_decorator.cc | 17 ++ .../internal/answer_records_auth_decorator.h | 8 + .../answer_records_connection_impl.cc | 48 +++++ .../internal/answer_records_connection_impl.h | 6 + .../answer_records_logging_decorator.cc | 23 +++ .../answer_records_logging_decorator.h | 8 + .../answer_records_metadata_decorator.cc | 17 ++ .../answer_records_metadata_decorator.h | 8 + .../internal/answer_records_stub.cc | 24 +++ .../internal/answer_records_stub.h | 28 ++- .../internal/answer_records_stub_factory.cc | 6 +- .../answer_records_tracing_connection.cc | 20 ++ .../answer_records_tracing_connection.h | 6 + .../internal/answer_records_tracing_stub.cc | 24 +++ .../internal/answer_records_tracing_stub.h | 8 + .../internal/contexts_auth_decorator.cc | 17 ++ .../internal/contexts_auth_decorator.h | 8 + .../internal/contexts_connection_impl.cc | 47 +++++ .../internal/contexts_connection_impl.h | 6 + .../internal/contexts_logging_decorator.cc | 23 +++ .../internal/contexts_logging_decorator.h | 8 + .../internal/contexts_metadata_decorator.cc | 17 ++ .../internal/contexts_metadata_decorator.h | 8 + .../dialogflow_es/internal/contexts_stub.cc | 23 +++ .../dialogflow_es/internal/contexts_stub.h | 28 ++- .../internal/contexts_stub_factory.cc | 7 +- .../internal/contexts_tracing_connection.cc | 20 ++ .../internal/contexts_tracing_connection.h | 6 + .../internal/contexts_tracing_stub.cc | 23 +++ .../internal/contexts_tracing_stub.h | 8 + .../conversation_datasets_auth_decorator.cc | 18 ++ .../conversation_datasets_auth_decorator.h | 8 + .../conversation_datasets_connection_impl.cc | 48 +++++ .../conversation_datasets_connection_impl.h | 6 + ...conversation_datasets_logging_decorator.cc | 24 +++ .../conversation_datasets_logging_decorator.h | 8 + ...onversation_datasets_metadata_decorator.cc | 18 ++ ...conversation_datasets_metadata_decorator.h | 8 + .../internal/conversation_datasets_stub.cc | 24 +++ .../internal/conversation_datasets_stub.h | 27 ++- .../conversation_datasets_stub_factory.cc | 5 +- ...onversation_datasets_tracing_connection.cc | 20 ++ ...conversation_datasets_tracing_connection.h | 6 + .../conversation_datasets_tracing_stub.cc | 24 +++ .../conversation_datasets_tracing_stub.h | 8 + .../conversation_models_auth_decorator.cc | 17 ++ .../conversation_models_auth_decorator.h | 8 + .../conversation_models_connection_impl.cc | 48 +++++ .../conversation_models_connection_impl.h | 6 + .../conversation_models_logging_decorator.cc | 24 +++ .../conversation_models_logging_decorator.h | 8 + .../conversation_models_metadata_decorator.cc | 18 ++ .../conversation_models_metadata_decorator.h | 8 + .../internal/conversation_models_stub.cc | 24 +++ .../internal/conversation_models_stub.h | 27 ++- .../conversation_models_stub_factory.cc | 5 +- .../conversation_models_tracing_connection.cc | 20 ++ .../conversation_models_tracing_connection.h | 6 + .../conversation_models_tracing_stub.cc | 24 +++ .../conversation_models_tracing_stub.h | 8 + .../conversation_profiles_auth_decorator.cc | 18 ++ .../conversation_profiles_auth_decorator.h | 8 + .../conversation_profiles_connection_impl.cc | 48 +++++ .../conversation_profiles_connection_impl.h | 6 + ...conversation_profiles_logging_decorator.cc | 24 +++ .../conversation_profiles_logging_decorator.h | 8 + ...onversation_profiles_metadata_decorator.cc | 18 ++ ...conversation_profiles_metadata_decorator.h | 8 + .../internal/conversation_profiles_stub.cc | 24 +++ .../internal/conversation_profiles_stub.h | 27 ++- .../conversation_profiles_stub_factory.cc | 5 +- ...onversation_profiles_tracing_connection.cc | 20 ++ ...conversation_profiles_tracing_connection.h | 6 + .../conversation_profiles_tracing_stub.cc | 24 +++ .../conversation_profiles_tracing_stub.h | 8 + .../internal/conversations_auth_decorator.cc | 17 ++ .../internal/conversations_auth_decorator.h | 8 + .../internal/conversations_connection_impl.cc | 48 +++++ .../internal/conversations_connection_impl.h | 6 + .../conversations_logging_decorator.cc | 23 +++ .../conversations_logging_decorator.h | 8 + .../conversations_metadata_decorator.cc | 17 ++ .../conversations_metadata_decorator.h | 8 + .../internal/conversations_stub.cc | 24 +++ .../internal/conversations_stub.h | 28 ++- .../internal/conversations_stub_factory.cc | 6 +- .../conversations_tracing_connection.cc | 20 ++ .../conversations_tracing_connection.h | 6 + .../internal/conversations_tracing_stub.cc | 24 +++ .../internal/conversations_tracing_stub.h | 8 + .../internal/documents_auth_decorator.cc | 17 ++ .../internal/documents_auth_decorator.h | 8 + .../internal/documents_connection_impl.cc | 48 +++++ .../internal/documents_connection_impl.h | 6 + .../internal/documents_logging_decorator.cc | 23 +++ .../internal/documents_logging_decorator.h | 8 + .../internal/documents_metadata_decorator.cc | 17 ++ .../internal/documents_metadata_decorator.h | 8 + .../dialogflow_es/internal/documents_stub.cc | 23 +++ .../dialogflow_es/internal/documents_stub.h | 27 ++- .../internal/documents_stub_factory.cc | 5 +- .../internal/documents_tracing_connection.cc | 20 ++ .../internal/documents_tracing_connection.h | 6 + .../internal/documents_tracing_stub.cc | 23 +++ .../internal/documents_tracing_stub.h | 8 + .../internal/entity_types_auth_decorator.cc | 17 ++ .../internal/entity_types_auth_decorator.h | 8 + .../internal/entity_types_connection_impl.cc | 48 +++++ .../internal/entity_types_connection_impl.h | 6 + .../entity_types_logging_decorator.cc | 23 +++ .../internal/entity_types_logging_decorator.h | 8 + .../entity_types_metadata_decorator.cc | 17 ++ .../entity_types_metadata_decorator.h | 8 + .../internal/entity_types_stub.cc | 23 +++ .../internal/entity_types_stub.h | 27 ++- .../internal/entity_types_stub_factory.cc | 5 +- .../entity_types_tracing_connection.cc | 20 ++ .../entity_types_tracing_connection.h | 6 + .../internal/entity_types_tracing_stub.cc | 23 +++ .../internal/entity_types_tracing_stub.h | 8 + .../internal/environments_auth_decorator.cc | 17 ++ .../internal/environments_auth_decorator.h | 8 + .../internal/environments_connection_impl.cc | 48 +++++ .../internal/environments_connection_impl.h | 6 + .../environments_logging_decorator.cc | 23 +++ .../internal/environments_logging_decorator.h | 8 + .../environments_metadata_decorator.cc | 17 ++ .../environments_metadata_decorator.h | 8 + .../internal/environments_stub.cc | 24 +++ .../internal/environments_stub.h | 28 ++- .../internal/environments_stub_factory.cc | 6 +- .../environments_tracing_connection.cc | 20 ++ .../environments_tracing_connection.h | 6 + .../internal/environments_tracing_stub.cc | 24 +++ .../internal/environments_tracing_stub.h | 8 + .../internal/fulfillments_auth_decorator.cc | 17 ++ .../internal/fulfillments_auth_decorator.h | 8 + .../internal/fulfillments_connection_impl.cc | 49 +++++ .../internal/fulfillments_connection_impl.h | 7 + .../fulfillments_logging_decorator.cc | 23 +++ .../internal/fulfillments_logging_decorator.h | 8 + .../fulfillments_metadata_decorator.cc | 17 ++ .../fulfillments_metadata_decorator.h | 8 + .../internal/fulfillments_stub.cc | 24 +++ .../internal/fulfillments_stub.h | 28 ++- .../internal/fulfillments_stub_factory.cc | 6 +- .../fulfillments_tracing_connection.cc | 21 +++ .../fulfillments_tracing_connection.h | 6 + .../internal/fulfillments_tracing_stub.cc | 24 +++ .../internal/fulfillments_tracing_stub.h | 8 + .../internal/intents_auth_decorator.cc | 17 ++ .../internal/intents_auth_decorator.h | 8 + .../internal/intents_connection_impl.cc | 47 +++++ .../internal/intents_connection_impl.h | 6 + .../internal/intents_logging_decorator.cc | 23 +++ .../internal/intents_logging_decorator.h | 8 + .../internal/intents_metadata_decorator.cc | 17 ++ .../internal/intents_metadata_decorator.h | 8 + .../dialogflow_es/internal/intents_stub.cc | 23 +++ .../dialogflow_es/internal/intents_stub.h | 27 ++- .../internal/intents_stub_factory.cc | 5 +- .../internal/intents_tracing_connection.cc | 20 ++ .../internal/intents_tracing_connection.h | 6 + .../internal/intents_tracing_stub.cc | 23 +++ .../internal/intents_tracing_stub.h | 8 + .../knowledge_bases_auth_decorator.cc | 17 ++ .../internal/knowledge_bases_auth_decorator.h | 8 + .../knowledge_bases_connection_impl.cc | 48 +++++ .../knowledge_bases_connection_impl.h | 6 + .../knowledge_bases_logging_decorator.cc | 23 +++ .../knowledge_bases_logging_decorator.h | 8 + .../knowledge_bases_metadata_decorator.cc | 17 ++ .../knowledge_bases_metadata_decorator.h | 8 + .../internal/knowledge_bases_stub.cc | 24 +++ .../internal/knowledge_bases_stub.h | 28 ++- .../internal/knowledge_bases_stub_factory.cc | 6 +- .../knowledge_bases_tracing_connection.cc | 20 ++ .../knowledge_bases_tracing_connection.h | 6 + .../internal/knowledge_bases_tracing_stub.cc | 24 +++ .../internal/knowledge_bases_tracing_stub.h | 8 + .../internal/participants_auth_decorator.cc | 17 ++ .../internal/participants_auth_decorator.h | 8 + .../internal/participants_connection_impl.cc | 48 +++++ .../internal/participants_connection_impl.h | 6 + .../participants_logging_decorator.cc | 23 +++ .../internal/participants_logging_decorator.h | 8 + .../participants_metadata_decorator.cc | 17 ++ .../participants_metadata_decorator.h | 8 + .../internal/participants_stub.cc | 24 +++ .../internal/participants_stub.h | 28 ++- .../internal/participants_stub_factory.cc | 6 +- .../participants_tracing_connection.cc | 20 ++ .../participants_tracing_connection.h | 6 + .../internal/participants_tracing_stub.cc | 24 +++ .../internal/participants_tracing_stub.h | 8 + .../session_entity_types_auth_decorator.cc | 17 ++ .../session_entity_types_auth_decorator.h | 8 + .../session_entity_types_connection_impl.cc | 48 +++++ .../session_entity_types_connection_impl.h | 6 + .../session_entity_types_logging_decorator.cc | 24 +++ .../session_entity_types_logging_decorator.h | 8 + ...session_entity_types_metadata_decorator.cc | 18 ++ .../session_entity_types_metadata_decorator.h | 8 + .../internal/session_entity_types_stub.cc | 24 +++ .../internal/session_entity_types_stub.h | 28 ++- .../session_entity_types_stub_factory.cc | 5 +- ...session_entity_types_tracing_connection.cc | 20 ++ .../session_entity_types_tracing_connection.h | 6 + .../session_entity_types_tracing_stub.cc | 24 +++ .../session_entity_types_tracing_stub.h | 8 + .../internal/sessions_auth_decorator.cc | 17 ++ .../internal/sessions_auth_decorator.h | 8 + .../internal/sessions_connection_impl.cc | 48 +++++ .../internal/sessions_connection_impl.h | 7 + .../internal/sessions_logging_decorator.cc | 23 +++ .../internal/sessions_logging_decorator.h | 8 + .../internal/sessions_metadata_decorator.cc | 17 ++ .../internal/sessions_metadata_decorator.h | 8 + .../dialogflow_es/internal/sessions_stub.cc | 23 +++ .../dialogflow_es/internal/sessions_stub.h | 28 ++- .../internal/sessions_stub_factory.cc | 7 +- .../internal/sessions_tracing_connection.cc | 21 +++ .../internal/sessions_tracing_connection.h | 6 + .../internal/sessions_tracing_stub.cc | 23 +++ .../internal/sessions_tracing_stub.h | 8 + .../internal/versions_auth_decorator.cc | 17 ++ .../internal/versions_auth_decorator.h | 8 + .../internal/versions_connection_impl.cc | 47 +++++ .../internal/versions_connection_impl.h | 6 + .../internal/versions_logging_decorator.cc | 23 +++ .../internal/versions_logging_decorator.h | 8 + .../internal/versions_metadata_decorator.cc | 17 ++ .../internal/versions_metadata_decorator.h | 8 + .../dialogflow_es/internal/versions_stub.cc | 23 +++ .../dialogflow_es/internal/versions_stub.h | 28 ++- .../internal/versions_stub_factory.cc | 7 +- .../internal/versions_tracing_connection.cc | 20 ++ .../internal/versions_tracing_connection.h | 6 + .../internal/versions_tracing_stub.cc | 23 +++ .../internal/versions_tracing_stub.h | 8 + .../dialogflow_es/knowledge_bases_client.cc | 13 ++ .../dialogflow_es/knowledge_bases_client.h | 71 +++++++ .../knowledge_bases_connection.cc | 14 ++ .../knowledge_bases_connection.h | 7 + ...dge_bases_connection_idempotency_policy.cc | 10 + ...edge_bases_connection_idempotency_policy.h | 7 + .../mocks/mock_agents_connection.h | 8 + .../mocks/mock_answer_records_connection.h | 8 + .../mocks/mock_contexts_connection.h | 8 + .../mock_conversation_datasets_connection.h | 8 + .../mock_conversation_models_connection.h | 8 + .../mock_conversation_profiles_connection.h | 8 + .../mocks/mock_conversations_connection.h | 8 + .../mocks/mock_documents_connection.h | 8 + .../mocks/mock_entity_types_connection.h | 8 + .../mocks/mock_environments_connection.h | 8 + .../mocks/mock_fulfillments_connection.h | 8 + .../mocks/mock_intents_connection.h | 8 + .../mocks/mock_knowledge_bases_connection.h | 8 + .../mocks/mock_participants_connection.h | 8 + .../mock_session_entity_types_connection.h | 8 + .../mocks/mock_sessions_connection.h | 8 + .../mocks/mock_versions_connection.h | 8 + .../dialogflow_es/participants_client.cc | 13 ++ .../cloud/dialogflow_es/participants_client.h | 70 +++++++ .../dialogflow_es/participants_connection.cc | 13 ++ .../dialogflow_es/participants_connection.h | 7 + ...ticipants_connection_idempotency_policy.cc | 10 + ...rticipants_connection_idempotency_policy.h | 7 + .../session_entity_types_client.cc | 14 ++ .../session_entity_types_client.h | 71 +++++++ .../session_entity_types_connection.cc | 14 ++ .../session_entity_types_connection.h | 7 + ...ity_types_connection_idempotency_policy.cc | 10 + ...tity_types_connection_idempotency_policy.h | 7 + google/cloud/dialogflow_es/sessions_client.cc | 12 ++ google/cloud/dialogflow_es/sessions_client.h | 71 +++++++ .../dialogflow_es/sessions_connection.cc | 14 ++ .../cloud/dialogflow_es/sessions_connection.h | 8 + .../sessions_connection_idempotency_policy.cc | 10 + .../sessions_connection_idempotency_policy.h | 7 + google/cloud/dialogflow_es/versions_client.cc | 12 ++ google/cloud/dialogflow_es/versions_client.h | 71 +++++++ .../dialogflow_es/versions_connection.cc | 13 ++ .../cloud/dialogflow_es/versions_connection.h | 7 + .../versions_connection_idempotency_policy.cc | 10 + .../versions_connection_idempotency_policy.h | 7 + google/cloud/discoveryengine/BUILD.bazel | 2 + .../v1/completion_connection.h | 1 + .../discoveryengine/v1/control_connection.h | 1 + .../v1/conversational_search_connection.h | 1 + .../v1/data_store_connection.h | 1 + .../discoveryengine/v1/document_connection.h | 1 + .../discoveryengine/v1/engine_connection.h | 1 + .../v1/grounded_generation_connection.h | 1 + .../v1/internal/completion_stub.h | 1 + .../v1/internal/control_stub.h | 1 + .../v1/internal/conversational_search_stub.h | 1 + .../v1/internal/data_store_stub.h | 1 + .../v1/internal/document_stub.h | 1 + .../discoveryengine/v1/internal/engine_stub.h | 1 + .../v1/internal/grounded_generation_stub.h | 1 + .../v1/internal/project_stub.h | 1 + .../discoveryengine/v1/internal/rank_stub.h | 1 + .../v1/internal/recommendation_stub.h | 1 + .../discoveryengine/v1/internal/schema_stub.h | 1 + .../discoveryengine/v1/internal/search_stub.h | 1 + .../v1/internal/site_search_engine_stub.h | 1 + .../v1/internal/user_event_stub.h | 1 + .../discoveryengine/v1/project_connection.h | 1 + .../discoveryengine/v1/rank_connection.h | 1 + .../v1/recommendation_connection.h | 1 + .../discoveryengine/v1/schema_connection.h | 1 + .../discoveryengine/v1/search_connection.h | 1 + .../v1/site_search_engine_connection.h | 1 + .../v1/user_event_connection.h | 1 + google/cloud/dlp/BUILD.bazel | 2 + google/cloud/dlp/v2/dlp_connection.h | 1 + google/cloud/dlp/v2/internal/dlp_stub.h | 1 + google/cloud/documentai/BUILD.bazel | 2 + .../v1/document_processor_client.cc | 14 ++ .../documentai/v1/document_processor_client.h | 70 +++++++ .../v1/document_processor_connection.cc | 14 ++ .../v1/document_processor_connection.h | 7 + ...processor_connection_idempotency_policy.cc | 10 + ..._processor_connection_idempotency_policy.h | 7 + .../document_processor_auth_decorator.cc | 18 ++ .../document_processor_auth_decorator.h | 8 + .../document_processor_connection_impl.cc | 49 +++++ .../document_processor_connection_impl.h | 6 + .../document_processor_logging_decorator.cc | 24 +++ .../document_processor_logging_decorator.h | 8 + .../document_processor_metadata_decorator.cc | 18 ++ .../document_processor_metadata_decorator.h | 8 + .../v1/internal/document_processor_stub.cc | 24 +++ .../v1/internal/document_processor_stub.h | 27 ++- .../document_processor_stub_factory.cc | 5 +- .../document_processor_tracing_connection.cc | 20 ++ .../document_processor_tracing_connection.h | 6 + .../document_processor_tracing_stub.cc | 24 +++ .../document_processor_tracing_stub.h | 8 + .../mock_document_processor_connection.h | 8 + google/cloud/edgecontainer/BUILD.bazel | 2 + .../edgecontainer/v1/edge_container_client.cc | 13 ++ .../edgecontainer/v1/edge_container_client.h | 70 +++++++ .../v1/edge_container_connection.cc | 14 ++ .../v1/edge_container_connection.h | 7 + ...container_connection_idempotency_policy.cc | 10 + ..._container_connection_idempotency_policy.h | 7 + .../internal/edge_container_auth_decorator.cc | 17 ++ .../internal/edge_container_auth_decorator.h | 8 + .../edge_container_connection_impl.cc | 48 +++++ .../internal/edge_container_connection_impl.h | 6 + .../edge_container_logging_decorator.cc | 23 +++ .../edge_container_logging_decorator.h | 8 + .../edge_container_metadata_decorator.cc | 17 ++ .../edge_container_metadata_decorator.h | 8 + .../v1/internal/edge_container_stub.cc | 24 +++ .../v1/internal/edge_container_stub.h | 27 ++- .../internal/edge_container_stub_factory.cc | 5 +- .../edge_container_tracing_connection.cc | 20 ++ .../edge_container_tracing_connection.h | 6 + .../internal/edge_container_tracing_stub.cc | 24 +++ .../v1/internal/edge_container_tracing_stub.h | 8 + .../v1/mocks/mock_edge_container_connection.h | 8 + google/cloud/edgenetwork/BUILD.bazel | 2 + .../edgenetwork/v1/edge_network_client.cc | 12 ++ .../edgenetwork/v1/edge_network_client.h | 70 +++++++ .../edgenetwork/v1/edge_network_connection.cc | 13 ++ .../edgenetwork/v1/edge_network_connection.h | 7 + ...e_network_connection_idempotency_policy.cc | 10 + ...ge_network_connection_idempotency_policy.h | 7 + .../internal/edge_network_auth_decorator.cc | 17 ++ .../v1/internal/edge_network_auth_decorator.h | 8 + .../internal/edge_network_connection_impl.cc | 48 +++++ .../internal/edge_network_connection_impl.h | 6 + .../edge_network_logging_decorator.cc | 23 +++ .../internal/edge_network_logging_decorator.h | 8 + .../edge_network_metadata_decorator.cc | 17 ++ .../edge_network_metadata_decorator.h | 8 + .../v1/internal/edge_network_stub.cc | 23 +++ .../v1/internal/edge_network_stub.h | 27 ++- .../v1/internal/edge_network_stub_factory.cc | 5 +- .../edge_network_tracing_connection.cc | 20 ++ .../edge_network_tracing_connection.h | 6 + .../v1/internal/edge_network_tracing_stub.cc | 23 +++ .../v1/internal/edge_network_tracing_stub.h | 8 + .../v1/mocks/mock_edge_network_connection.h | 8 + google/cloud/eventarc/BUILD.bazel | 2 + google/cloud/eventarc/v1/eventarc_client.cc | 31 ++++ google/cloud/eventarc/v1/eventarc_client.h | 172 +++++++++++++++++ .../cloud/eventarc/v1/eventarc_connection.cc | 29 +++ .../cloud/eventarc/v1/eventarc_connection.h | 17 ++ .../eventarc_connection_idempotency_policy.cc | 26 +++ .../eventarc_connection_idempotency_policy.h | 17 ++ .../v1/internal/eventarc_auth_decorator.cc | 42 +++++ .../v1/internal/eventarc_auth_decorator.h | 20 ++ .../v1/internal/eventarc_connection_impl.cc | 87 +++++++++ .../v1/internal/eventarc_connection_impl.h | 15 ++ .../v1/internal/eventarc_logging_decorator.cc | 57 ++++++ .../v1/internal/eventarc_logging_decorator.h | 20 ++ .../internal/eventarc_metadata_decorator.cc | 45 +++++ .../v1/internal/eventarc_metadata_decorator.h | 20 ++ .../eventarc/v1/internal/eventarc_stub.cc | 58 ++++++ .../eventarc/v1/internal/eventarc_stub.h | 57 +++++- .../v1/internal/eventarc_stub_factory.cc | 8 +- .../internal/eventarc_tracing_connection.cc | 45 +++++ .../v1/internal/eventarc_tracing_connection.h | 15 ++ .../v1/internal/eventarc_tracing_stub.cc | 57 ++++++ .../v1/internal/eventarc_tracing_stub.h | 20 ++ .../v1/mocks/mock_eventarc_connection.h | 21 +++ google/cloud/filestore/BUILD.bazel | 2 + .../v1/cloud_filestore_manager_client.cc | 14 ++ .../v1/cloud_filestore_manager_client.h | 70 +++++++ .../v1/cloud_filestore_manager_connection.cc | 14 ++ .../v1/cloud_filestore_manager_connection.h | 7 + ...e_manager_connection_idempotency_policy.cc | 10 + ...re_manager_connection_idempotency_policy.h | 7 + .../cloud_filestore_manager_auth_decorator.cc | 18 ++ .../cloud_filestore_manager_auth_decorator.h | 8 + ...cloud_filestore_manager_connection_impl.cc | 48 +++++ .../cloud_filestore_manager_connection_impl.h | 6 + ...oud_filestore_manager_logging_decorator.cc | 24 +++ ...loud_filestore_manager_logging_decorator.h | 8 + ...ud_filestore_manager_metadata_decorator.cc | 18 ++ ...oud_filestore_manager_metadata_decorator.h | 8 + .../internal/cloud_filestore_manager_stub.cc | 24 +++ .../internal/cloud_filestore_manager_stub.h | 27 ++- .../cloud_filestore_manager_stub_factory.cc | 5 +- ...ud_filestore_manager_tracing_connection.cc | 20 ++ ...oud_filestore_manager_tracing_connection.h | 6 + .../cloud_filestore_manager_tracing_stub.cc | 24 +++ .../cloud_filestore_manager_tracing_stub.h | 8 + .../mock_cloud_filestore_manager_connection.h | 8 + google/cloud/functions/BUILD.bazel | 2 + .../functions/v1/cloud_functions_client.cc | 7 + .../functions/v1/cloud_functions_client.h | 39 ++++ .../v1/cloud_functions_connection.cc | 8 + .../functions/v1/cloud_functions_connection.h | 5 + ...functions_connection_idempotency_policy.cc | 5 + ..._functions_connection_idempotency_policy.h | 4 + .../cloud_functions_auth_decorator.cc | 9 + .../internal/cloud_functions_auth_decorator.h | 4 + .../cloud_functions_connection_impl.cc | 34 ++++ .../cloud_functions_connection_impl.h | 3 + .../cloud_functions_logging_decorator.cc | 12 ++ .../cloud_functions_logging_decorator.h | 4 + .../cloud_functions_metadata_decorator.cc | 9 + .../cloud_functions_metadata_decorator.h | 4 + .../v1/internal/cloud_functions_stub.cc | 12 ++ .../v1/internal/cloud_functions_stub.h | 20 +- .../internal/cloud_functions_stub_factory.cc | 5 +- .../cloud_functions_tracing_connection.cc | 11 ++ .../cloud_functions_tracing_connection.h | 3 + .../internal/cloud_functions_tracing_stub.cc | 12 ++ .../internal/cloud_functions_tracing_stub.h | 4 + .../mocks/mock_cloud_functions_connection.h | 4 + google/cloud/functions/v2/function_client.cc | 26 +++ google/cloud/functions/v2/function_client.h | 141 ++++++++++++++ .../cloud/functions/v2/function_connection.cc | 24 +++ .../cloud/functions/v2/function_connection.h | 14 ++ .../function_connection_idempotency_policy.cc | 21 +++ .../function_connection_idempotency_policy.h | 14 ++ .../v2/internal/function_auth_decorator.cc | 34 ++++ .../v2/internal/function_auth_decorator.h | 16 ++ .../v2/internal/function_connection_impl.cc | 74 ++++++++ .../v2/internal/function_connection_impl.h | 12 ++ .../v2/internal/function_logging_decorator.cc | 46 +++++ .../v2/internal/function_logging_decorator.h | 16 ++ .../internal/function_metadata_decorator.cc | 37 ++++ .../v2/internal/function_metadata_decorator.h | 16 ++ .../functions/v2/internal/function_stub.cc | 47 +++++ .../functions/v2/internal/function_stub.h | 49 ++++- .../v2/internal/function_stub_factory.cc | 8 +- .../internal/function_tracing_connection.cc | 38 ++++ .../v2/internal/function_tracing_connection.h | 12 ++ .../v2/internal/function_tracing_stub.cc | 46 +++++ .../v2/internal/function_tracing_stub.h | 16 ++ .../v2/mocks/mock_function_connection.h | 17 ++ google/cloud/gkebackup/BUILD.bazel | 2 + .../gkebackup/v1/backup_for_gke_client.cc | 32 ++++ .../gkebackup/v1/backup_for_gke_client.h | 172 +++++++++++++++++ .../gkebackup/v1/backup_for_gke_connection.cc | 29 +++ .../gkebackup/v1/backup_for_gke_connection.h | 17 ++ ...p_for_gke_connection_idempotency_policy.cc | 26 +++ ...up_for_gke_connection_idempotency_policy.h | 17 ++ .../internal/backup_for_gke_auth_decorator.cc | 42 +++++ .../internal/backup_for_gke_auth_decorator.h | 20 ++ .../backup_for_gke_connection_impl.cc | 88 +++++++++ .../internal/backup_for_gke_connection_impl.h | 15 ++ .../backup_for_gke_logging_decorator.cc | 57 ++++++ .../backup_for_gke_logging_decorator.h | 20 ++ .../backup_for_gke_metadata_decorator.cc | 45 +++++ .../backup_for_gke_metadata_decorator.h | 20 ++ .../v1/internal/backup_for_gke_stub.cc | 59 ++++++ .../v1/internal/backup_for_gke_stub.h | 57 +++++- .../internal/backup_for_gke_stub_factory.cc | 8 +- .../backup_for_gke_tracing_connection.cc | 45 +++++ .../backup_for_gke_tracing_connection.h | 15 ++ .../internal/backup_for_gke_tracing_stub.cc | 58 ++++++ .../v1/internal/backup_for_gke_tracing_stub.h | 20 ++ .../v1/mocks/mock_backup_for_gke_connection.h | 21 +++ .../cloud/iam/v1/internal/iam_policy_stub.h | 1 + google/cloud/kms/BUILD.bazel | 2 + google/cloud/kms/v1/autokey_admin_client.cc | 32 ++++ google/cloud/kms/v1/autokey_admin_client.h | 173 ++++++++++++++++++ .../cloud/kms/v1/autokey_admin_connection.cc | 30 +++ .../cloud/kms/v1/autokey_admin_connection.h | 18 ++ ...key_admin_connection_idempotency_policy.cc | 26 +++ ...okey_admin_connection_idempotency_policy.h | 17 ++ google/cloud/kms/v1/autokey_client.cc | 31 ++++ google/cloud/kms/v1/autokey_client.h | 173 ++++++++++++++++++ google/cloud/kms/v1/autokey_connection.cc | 29 +++ google/cloud/kms/v1/autokey_connection.h | 18 ++ .../autokey_connection_idempotency_policy.cc | 26 +++ .../autokey_connection_idempotency_policy.h | 17 ++ google/cloud/kms/v1/ekm_client.cc | 31 ++++ google/cloud/kms/v1/ekm_client.h | 173 ++++++++++++++++++ google/cloud/kms/v1/ekm_connection.cc | 29 +++ google/cloud/kms/v1/ekm_connection.h | 17 ++ .../v1/ekm_connection_idempotency_policy.cc | 26 +++ .../v1/ekm_connection_idempotency_policy.h | 17 ++ .../internal/autokey_admin_auth_decorator.cc | 42 +++++ .../internal/autokey_admin_auth_decorator.h | 20 ++ .../internal/autokey_admin_connection_impl.cc | 89 +++++++++ .../internal/autokey_admin_connection_impl.h | 16 ++ .../autokey_admin_logging_decorator.cc | 57 ++++++ .../autokey_admin_logging_decorator.h | 20 ++ .../autokey_admin_metadata_decorator.cc | 45 +++++ .../autokey_admin_metadata_decorator.h | 20 ++ .../kms/v1/internal/autokey_admin_stub.cc | 59 ++++++ .../kms/v1/internal/autokey_admin_stub.h | 58 +++++- .../v1/internal/autokey_admin_stub_factory.cc | 9 +- .../autokey_admin_tracing_connection.cc | 45 +++++ .../autokey_admin_tracing_connection.h | 15 ++ .../v1/internal/autokey_admin_tracing_stub.cc | 58 ++++++ .../v1/internal/autokey_admin_tracing_stub.h | 20 ++ .../kms/v1/internal/autokey_auth_decorator.cc | 42 +++++ .../kms/v1/internal/autokey_auth_decorator.h | 20 ++ .../v1/internal/autokey_connection_impl.cc | 88 +++++++++ .../kms/v1/internal/autokey_connection_impl.h | 16 ++ .../v1/internal/autokey_logging_decorator.cc | 57 ++++++ .../v1/internal/autokey_logging_decorator.h | 20 ++ .../v1/internal/autokey_metadata_decorator.cc | 45 +++++ .../v1/internal/autokey_metadata_decorator.h | 20 ++ google/cloud/kms/v1/internal/autokey_stub.cc | 58 ++++++ google/cloud/kms/v1/internal/autokey_stub.h | 57 +++++- .../kms/v1/internal/autokey_stub_factory.cc | 8 +- .../v1/internal/autokey_tracing_connection.cc | 42 +++++ .../v1/internal/autokey_tracing_connection.h | 15 ++ .../kms/v1/internal/autokey_tracing_stub.cc | 57 ++++++ .../kms/v1/internal/autokey_tracing_stub.h | 20 ++ .../kms/v1/internal/ekm_auth_decorator.cc | 42 +++++ .../kms/v1/internal/ekm_auth_decorator.h | 20 ++ .../kms/v1/internal/ekm_connection_impl.cc | 88 +++++++++ .../kms/v1/internal/ekm_connection_impl.h | 15 ++ .../kms/v1/internal/ekm_logging_decorator.cc | 57 ++++++ .../kms/v1/internal/ekm_logging_decorator.h | 20 ++ .../kms/v1/internal/ekm_metadata_decorator.cc | 45 +++++ .../kms/v1/internal/ekm_metadata_decorator.h | 20 ++ google/cloud/kms/v1/internal/ekm_stub.cc | 58 ++++++ google/cloud/kms/v1/internal/ekm_stub.h | 58 +++++- .../cloud/kms/v1/internal/ekm_stub_factory.cc | 9 +- .../kms/v1/internal/ekm_tracing_connection.cc | 41 +++++ .../kms/v1/internal/ekm_tracing_connection.h | 15 ++ .../cloud/kms/v1/internal/ekm_tracing_stub.cc | 57 ++++++ .../cloud/kms/v1/internal/ekm_tracing_stub.h | 20 ++ .../internal/key_management_auth_decorator.cc | 43 +++++ .../internal/key_management_auth_decorator.h | 20 ++ .../key_management_connection_impl.cc | 90 +++++++++ .../internal/key_management_connection_impl.h | 15 ++ .../key_management_logging_decorator.cc | 58 ++++++ .../key_management_logging_decorator.h | 20 ++ .../key_management_metadata_decorator.cc | 46 +++++ .../key_management_metadata_decorator.h | 20 ++ .../kms/v1/internal/key_management_stub.cc | 59 ++++++ .../kms/v1/internal/key_management_stub.h | 58 +++++- .../internal/key_management_stub_factory.cc | 8 +- .../key_management_tracing_connection.cc | 47 +++++ .../key_management_tracing_connection.h | 15 ++ .../internal/key_management_tracing_stub.cc | 58 ++++++ .../v1/internal/key_management_tracing_stub.h | 20 ++ google/cloud/kms/v1/key_management_client.cc | 33 ++++ google/cloud/kms/v1/key_management_client.h | 172 +++++++++++++++++ .../cloud/kms/v1/key_management_connection.cc | 30 +++ .../cloud/kms/v1/key_management_connection.h | 17 ++ ...anagement_connection_idempotency_policy.cc | 26 +++ ...management_connection_idempotency_policy.h | 17 ++ .../v1/mocks/mock_autokey_admin_connection.h | 21 +++ .../kms/v1/mocks/mock_autokey_connection.h | 21 +++ .../cloud/kms/v1/mocks/mock_ekm_connection.h | 21 +++ .../v1/mocks/mock_key_management_connection.h | 21 +++ google/cloud/managedkafka/BUILD.bazel | 2 + .../internal/managed_kafka_auth_decorator.cc | 17 ++ .../internal/managed_kafka_auth_decorator.h | 8 + .../internal/managed_kafka_connection_impl.cc | 48 +++++ .../internal/managed_kafka_connection_impl.h | 6 + .../managed_kafka_logging_decorator.cc | 23 +++ .../managed_kafka_logging_decorator.h | 8 + .../managed_kafka_metadata_decorator.cc | 17 ++ .../managed_kafka_metadata_decorator.h | 8 + .../v1/internal/managed_kafka_stub.cc | 24 +++ .../v1/internal/managed_kafka_stub.h | 27 ++- .../v1/internal/managed_kafka_stub_factory.cc | 5 +- .../managed_kafka_tracing_connection.cc | 20 ++ .../managed_kafka_tracing_connection.h | 6 + .../v1/internal/managed_kafka_tracing_stub.cc | 24 +++ .../v1/internal/managed_kafka_tracing_stub.h | 8 + .../managedkafka/v1/managed_kafka_client.cc | 13 ++ .../managedkafka/v1/managed_kafka_client.h | 70 +++++++ .../v1/managed_kafka_connection.cc | 13 ++ .../v1/managed_kafka_connection.h | 7 + ...ged_kafka_connection_idempotency_policy.cc | 10 + ...aged_kafka_connection_idempotency_policy.h | 7 + .../v1/mocks/mock_managed_kafka_connection.h | 8 + google/cloud/memcache/BUILD.bazel | 2 + .../memcache/v1/cloud_memcache_client.cc | 13 ++ .../cloud/memcache/v1/cloud_memcache_client.h | 70 +++++++ .../memcache/v1/cloud_memcache_connection.cc | 14 ++ .../memcache/v1/cloud_memcache_connection.h | 7 + ..._memcache_connection_idempotency_policy.cc | 10 + ...d_memcache_connection_idempotency_policy.h | 7 + .../internal/cloud_memcache_auth_decorator.cc | 17 ++ .../internal/cloud_memcache_auth_decorator.h | 8 + .../cloud_memcache_connection_impl.cc | 48 +++++ .../internal/cloud_memcache_connection_impl.h | 6 + .../cloud_memcache_logging_decorator.cc | 23 +++ .../cloud_memcache_logging_decorator.h | 8 + .../cloud_memcache_metadata_decorator.cc | 17 ++ .../cloud_memcache_metadata_decorator.h | 8 + .../v1/internal/cloud_memcache_stub.cc | 24 +++ .../v1/internal/cloud_memcache_stub.h | 27 ++- .../internal/cloud_memcache_stub_factory.cc | 5 +- .../cloud_memcache_tracing_connection.cc | 20 ++ .../cloud_memcache_tracing_connection.h | 6 + .../internal/cloud_memcache_tracing_stub.cc | 24 +++ .../v1/internal/cloud_memcache_tracing_stub.h | 8 + .../v1/mocks/mock_cloud_memcache_connection.h | 8 + google/cloud/metastore/BUILD.bazel | 2 + .../metastore/v1/dataproc_metastore_client.cc | 33 ++++ .../metastore/v1/dataproc_metastore_client.h | 172 +++++++++++++++++ .../v1/dataproc_metastore_connection.cc | 30 +++ .../v1/dataproc_metastore_connection.h | 17 ++ ...metastore_connection_idempotency_policy.cc | 26 +++ ..._metastore_connection_idempotency_policy.h | 17 ++ .../dataproc_metastore_federation_client.cc | 35 ++++ .../v1/dataproc_metastore_federation_client.h | 172 +++++++++++++++++ ...ataproc_metastore_federation_connection.cc | 32 ++++ ...dataproc_metastore_federation_connection.h | 17 ++ ...ederation_connection_idempotency_policy.cc | 30 +++ ...federation_connection_idempotency_policy.h | 17 ++ .../dataproc_metastore_auth_decorator.cc | 42 +++++ .../dataproc_metastore_auth_decorator.h | 20 ++ .../dataproc_metastore_connection_impl.cc | 88 +++++++++ .../dataproc_metastore_connection_impl.h | 15 ++ ...roc_metastore_federation_auth_decorator.cc | 43 +++++ ...proc_metastore_federation_auth_decorator.h | 20 ++ ...oc_metastore_federation_connection_impl.cc | 91 +++++++++ ...roc_metastore_federation_connection_impl.h | 15 ++ ..._metastore_federation_logging_decorator.cc | 60 ++++++ ...c_metastore_federation_logging_decorator.h | 20 ++ ...metastore_federation_metadata_decorator.cc | 48 +++++ ..._metastore_federation_metadata_decorator.h | 20 ++ .../dataproc_metastore_federation_stub.cc | 61 ++++++ .../dataproc_metastore_federation_stub.h | 57 +++++- ...aproc_metastore_federation_stub_factory.cc | 8 +- ...metastore_federation_tracing_connection.cc | 48 +++++ ..._metastore_federation_tracing_connection.h | 15 ++ ...aproc_metastore_federation_tracing_stub.cc | 61 ++++++ ...taproc_metastore_federation_tracing_stub.h | 20 ++ .../dataproc_metastore_logging_decorator.cc | 58 ++++++ .../dataproc_metastore_logging_decorator.h | 20 ++ .../dataproc_metastore_metadata_decorator.cc | 46 +++++ .../dataproc_metastore_metadata_decorator.h | 20 ++ .../v1/internal/dataproc_metastore_stub.cc | 59 ++++++ .../v1/internal/dataproc_metastore_stub.h | 57 +++++- .../dataproc_metastore_stub_factory.cc | 8 +- .../dataproc_metastore_tracing_connection.cc | 47 +++++ .../dataproc_metastore_tracing_connection.h | 15 ++ .../dataproc_metastore_tracing_stub.cc | 58 ++++++ .../dataproc_metastore_tracing_stub.h | 20 ++ .../mock_dataproc_metastore_connection.h | 21 +++ ...dataproc_metastore_federation_connection.h | 21 +++ google/cloud/migrationcenter/BUILD.bazel | 2 + .../migration_center_auth_decorator.cc | 17 ++ .../migration_center_auth_decorator.h | 8 + .../migration_center_connection_impl.cc | 48 +++++ .../migration_center_connection_impl.h | 6 + .../migration_center_logging_decorator.cc | 23 +++ .../migration_center_logging_decorator.h | 8 + .../migration_center_metadata_decorator.cc | 18 ++ .../migration_center_metadata_decorator.h | 8 + .../v1/internal/migration_center_stub.cc | 24 +++ .../v1/internal/migration_center_stub.h | 27 ++- .../internal/migration_center_stub_factory.cc | 5 +- .../migration_center_tracing_connection.cc | 20 ++ .../migration_center_tracing_connection.h | 6 + .../internal/migration_center_tracing_stub.cc | 24 +++ .../internal/migration_center_tracing_stub.h | 8 + .../v1/migration_center_client.cc | 13 ++ .../v1/migration_center_client.h | 70 +++++++ .../v1/migration_center_connection.cc | 14 ++ .../v1/migration_center_connection.h | 7 + ...on_center_connection_idempotency_policy.cc | 10 + ...ion_center_connection_idempotency_policy.h | 7 + .../mocks/mock_migration_center_connection.h | 8 + google/cloud/netapp/BUILD.bazel | 2 + .../v1/internal/net_app_auth_decorator.cc | 17 ++ .../v1/internal/net_app_auth_decorator.h | 8 + .../v1/internal/net_app_connection_impl.cc | 47 +++++ .../v1/internal/net_app_connection_impl.h | 6 + .../v1/internal/net_app_logging_decorator.cc | 23 +++ .../v1/internal/net_app_logging_decorator.h | 8 + .../v1/internal/net_app_metadata_decorator.cc | 17 ++ .../v1/internal/net_app_metadata_decorator.h | 8 + .../cloud/netapp/v1/internal/net_app_stub.cc | 23 +++ .../cloud/netapp/v1/internal/net_app_stub.h | 27 ++- .../v1/internal/net_app_stub_factory.cc | 5 +- .../v1/internal/net_app_tracing_connection.cc | 18 ++ .../v1/internal/net_app_tracing_connection.h | 6 + .../v1/internal/net_app_tracing_stub.cc | 23 +++ .../netapp/v1/internal/net_app_tracing_stub.h | 8 + .../netapp/v1/mocks/mock_net_app_connection.h | 8 + google/cloud/netapp/v1/net_app_client.cc | 12 ++ google/cloud/netapp/v1/net_app_client.h | 70 +++++++ google/cloud/netapp/v1/net_app_connection.cc | 12 ++ google/cloud/netapp/v1/net_app_connection.h | 7 + .../net_app_connection_idempotency_policy.cc | 10 + .../net_app_connection_idempotency_policy.h | 7 + google/cloud/networkconnectivity/BUILD.bazel | 2 + .../networkconnectivity/v1/hub_client.cc | 31 ++++ .../cloud/networkconnectivity/v1/hub_client.h | 172 +++++++++++++++++ .../networkconnectivity/v1/hub_connection.cc | 29 +++ .../networkconnectivity/v1/hub_connection.h | 17 ++ .../v1/hub_connection_idempotency_policy.cc | 26 +++ .../v1/hub_connection_idempotency_policy.h | 17 ++ .../v1/internal/hub_auth_decorator.cc | 42 +++++ .../v1/internal/hub_auth_decorator.h | 20 ++ .../v1/internal/hub_connection_impl.cc | 88 +++++++++ .../v1/internal/hub_connection_impl.h | 15 ++ .../v1/internal/hub_logging_decorator.cc | 57 ++++++ .../v1/internal/hub_logging_decorator.h | 20 ++ .../v1/internal/hub_metadata_decorator.cc | 45 +++++ .../v1/internal/hub_metadata_decorator.h | 20 ++ .../v1/internal/hub_stub.cc | 58 ++++++ .../v1/internal/hub_stub.h | 57 +++++- .../v1/internal/hub_stub_factory.cc | 8 +- .../v1/internal/hub_tracing_connection.cc | 45 +++++ .../v1/internal/hub_tracing_connection.h | 15 ++ .../v1/internal/hub_tracing_stub.cc | 57 ++++++ .../v1/internal/hub_tracing_stub.h | 20 ++ .../policy_based_routing_auth_decorator.cc | 43 +++++ .../policy_based_routing_auth_decorator.h | 20 ++ .../policy_based_routing_connection_impl.cc | 91 +++++++++ .../policy_based_routing_connection_impl.h | 15 ++ .../policy_based_routing_logging_decorator.cc | 60 ++++++ .../policy_based_routing_logging_decorator.h | 20 ++ ...policy_based_routing_metadata_decorator.cc | 48 +++++ .../policy_based_routing_metadata_decorator.h | 20 ++ .../v1/internal/policy_based_routing_stub.cc | 61 ++++++ .../v1/internal/policy_based_routing_stub.h | 57 +++++- .../policy_based_routing_stub_factory.cc | 8 +- ...policy_based_routing_tracing_connection.cc | 52 ++++++ .../policy_based_routing_tracing_connection.h | 15 ++ .../policy_based_routing_tracing_stub.cc | 65 +++++++ .../policy_based_routing_tracing_stub.h | 20 ++ .../v1/mocks/mock_hub_connection.h | 21 +++ .../mock_policy_based_routing_connection.h | 21 +++ .../v1/policy_based_routing_client.cc | 33 ++++ .../v1/policy_based_routing_client.h | 172 +++++++++++++++++ .../v1/policy_based_routing_connection.cc | 32 ++++ .../v1/policy_based_routing_connection.h | 17 ++ ...d_routing_connection_idempotency_policy.cc | 27 +++ ...ed_routing_connection_idempotency_policy.h | 17 ++ google/cloud/networkmanagement/BUILD.bazel | 2 + .../internal/reachability_auth_decorator.cc | 43 +++++ .../v1/internal/reachability_auth_decorator.h | 20 ++ .../internal/reachability_connection_impl.cc | 91 +++++++++ .../internal/reachability_connection_impl.h | 15 ++ .../reachability_logging_decorator.cc | 58 ++++++ .../internal/reachability_logging_decorator.h | 20 ++ .../reachability_metadata_decorator.cc | 46 +++++ .../reachability_metadata_decorator.h | 20 ++ .../v1/internal/reachability_stub.cc | 59 ++++++ .../v1/internal/reachability_stub.h | 57 +++++- .../v1/internal/reachability_stub_factory.cc | 8 +- .../reachability_tracing_connection.cc | 48 +++++ .../reachability_tracing_connection.h | 15 ++ .../v1/internal/reachability_tracing_stub.cc | 59 ++++++ .../v1/internal/reachability_tracing_stub.h | 20 ++ .../v1/mocks/mock_reachability_connection.h | 21 +++ .../v1/reachability_client.cc | 33 ++++ .../v1/reachability_client.h | 172 +++++++++++++++++ .../v1/reachability_connection.cc | 30 +++ .../v1/reachability_connection.h | 17 ++ ...chability_connection_idempotency_policy.cc | 26 +++ ...achability_connection_idempotency_policy.h | 17 ++ google/cloud/networksecurity/BUILD.bazel | 2 + .../network_security_auth_decorator.cc | 42 +++++ .../network_security_auth_decorator.h | 20 ++ .../network_security_connection_impl.cc | 88 +++++++++ .../network_security_connection_impl.h | 15 ++ .../network_security_logging_decorator.cc | 57 ++++++ .../network_security_logging_decorator.h | 20 ++ .../network_security_metadata_decorator.cc | 46 +++++ .../network_security_metadata_decorator.h | 20 ++ .../v1/internal/network_security_stub.cc | 59 ++++++ .../v1/internal/network_security_stub.h | 57 +++++- .../internal/network_security_stub_factory.cc | 8 +- .../network_security_tracing_connection.cc | 47 +++++ .../network_security_tracing_connection.h | 15 ++ .../internal/network_security_tracing_stub.cc | 58 ++++++ .../internal/network_security_tracing_stub.h | 20 ++ .../mocks/mock_network_security_connection.h | 21 +++ .../v1/network_security_client.cc | 32 ++++ .../v1/network_security_client.h | 172 +++++++++++++++++ .../v1/network_security_connection.cc | 30 +++ .../v1/network_security_connection.h | 17 ++ ..._security_connection_idempotency_policy.cc | 26 +++ ...k_security_connection_idempotency_policy.h | 17 ++ google/cloud/networkservices/BUILD.bazel | 2 + google/cloud/networkservices/v1/dep_client.cc | 31 ++++ google/cloud/networkservices/v1/dep_client.h | 172 +++++++++++++++++ .../networkservices/v1/dep_connection.cc | 29 +++ .../cloud/networkservices/v1/dep_connection.h | 17 ++ .../v1/dep_connection_idempotency_policy.cc | 26 +++ .../v1/dep_connection_idempotency_policy.h | 17 ++ .../v1/internal/dep_auth_decorator.cc | 42 +++++ .../v1/internal/dep_auth_decorator.h | 20 ++ .../v1/internal/dep_connection_impl.cc | 88 +++++++++ .../v1/internal/dep_connection_impl.h | 15 ++ .../v1/internal/dep_logging_decorator.cc | 57 ++++++ .../v1/internal/dep_logging_decorator.h | 20 ++ .../v1/internal/dep_metadata_decorator.cc | 45 +++++ .../v1/internal/dep_metadata_decorator.h | 20 ++ .../networkservices/v1/internal/dep_stub.cc | 58 ++++++ .../networkservices/v1/internal/dep_stub.h | 57 +++++- .../v1/internal/dep_stub_factory.cc | 8 +- .../v1/internal/dep_tracing_connection.cc | 45 +++++ .../v1/internal/dep_tracing_connection.h | 15 ++ .../v1/internal/dep_tracing_stub.cc | 57 ++++++ .../v1/internal/dep_tracing_stub.h | 20 ++ .../network_services_auth_decorator.cc | 42 +++++ .../network_services_auth_decorator.h | 20 ++ .../network_services_connection_impl.cc | 88 +++++++++ .../network_services_connection_impl.h | 15 ++ .../network_services_logging_decorator.cc | 57 ++++++ .../network_services_logging_decorator.h | 20 ++ .../network_services_metadata_decorator.cc | 46 +++++ .../network_services_metadata_decorator.h | 20 ++ .../v1/internal/network_services_stub.cc | 59 ++++++ .../v1/internal/network_services_stub.h | 57 +++++- .../internal/network_services_stub_factory.cc | 8 +- .../network_services_tracing_connection.cc | 47 +++++ .../network_services_tracing_connection.h | 15 ++ .../internal/network_services_tracing_stub.cc | 58 ++++++ .../internal/network_services_tracing_stub.h | 20 ++ .../v1/mocks/mock_dep_connection.h | 21 +++ .../mocks/mock_network_services_connection.h | 21 +++ .../v1/network_services_client.cc | 32 ++++ .../v1/network_services_client.h | 172 +++++++++++++++++ .../v1/network_services_connection.cc | 30 +++ .../v1/network_services_connection.h | 17 ++ ..._services_connection_idempotency_policy.cc | 26 +++ ...k_services_connection_idempotency_policy.h | 17 ++ google/cloud/notebooks/BUILD.bazel | 2 + .../managed_notebook_auth_decorator.cc | 43 +++++ .../managed_notebook_auth_decorator.h | 20 ++ .../managed_notebook_connection_impl.cc | 90 +++++++++ .../managed_notebook_connection_impl.h | 15 ++ .../managed_notebook_logging_decorator.cc | 58 ++++++ .../managed_notebook_logging_decorator.h | 20 ++ .../managed_notebook_metadata_decorator.cc | 46 +++++ .../managed_notebook_metadata_decorator.h | 20 ++ .../v1/internal/managed_notebook_stub.cc | 61 ++++++ .../v1/internal/managed_notebook_stub.h | 57 +++++- .../internal/managed_notebook_stub_factory.cc | 8 +- .../managed_notebook_tracing_connection.cc | 47 +++++ .../managed_notebook_tracing_connection.h | 15 ++ .../internal/managed_notebook_tracing_stub.cc | 60 ++++++ .../internal/managed_notebook_tracing_stub.h | 20 ++ .../v1/internal/notebook_auth_decorator.cc | 42 +++++ .../v1/internal/notebook_auth_decorator.h | 20 ++ .../v1/internal/notebook_connection_impl.cc | 88 +++++++++ .../v1/internal/notebook_connection_impl.h | 15 ++ .../v1/internal/notebook_logging_decorator.cc | 57 ++++++ .../v1/internal/notebook_logging_decorator.h | 20 ++ .../internal/notebook_metadata_decorator.cc | 46 +++++ .../v1/internal/notebook_metadata_decorator.h | 20 ++ .../notebooks/v1/internal/notebook_stub.cc | 59 ++++++ .../notebooks/v1/internal/notebook_stub.h | 57 +++++- .../v1/internal/notebook_stub_factory.cc | 8 +- .../internal/notebook_tracing_connection.cc | 47 +++++ .../v1/internal/notebook_tracing_connection.h | 15 ++ .../v1/internal/notebook_tracing_stub.cc | 58 ++++++ .../v1/internal/notebook_tracing_stub.h | 20 ++ .../notebooks/v1/managed_notebook_client.cc | 33 ++++ .../notebooks/v1/managed_notebook_client.h | 173 ++++++++++++++++++ .../v1/managed_notebook_connection.cc | 32 ++++ .../v1/managed_notebook_connection.h | 17 ++ ..._notebook_connection_idempotency_policy.cc | 27 +++ ...d_notebook_connection_idempotency_policy.h | 17 ++ .../mocks/mock_managed_notebook_connection.h | 21 +++ .../v1/mocks/mock_notebook_connection.h | 21 +++ google/cloud/notebooks/v1/notebook_client.cc | 32 ++++ google/cloud/notebooks/v1/notebook_client.h | 172 +++++++++++++++++ .../cloud/notebooks/v1/notebook_connection.cc | 30 +++ .../cloud/notebooks/v1/notebook_connection.h | 17 ++ .../notebook_connection_idempotency_policy.cc | 26 +++ .../notebook_connection_idempotency_policy.h | 17 ++ .../v2/internal/notebook_auth_decorator.cc | 42 +++++ .../v2/internal/notebook_auth_decorator.h | 20 ++ .../v2/internal/notebook_connection_impl.cc | 88 +++++++++ .../v2/internal/notebook_connection_impl.h | 15 ++ .../v2/internal/notebook_logging_decorator.cc | 57 ++++++ .../v2/internal/notebook_logging_decorator.h | 20 ++ .../internal/notebook_metadata_decorator.cc | 46 +++++ .../v2/internal/notebook_metadata_decorator.h | 20 ++ .../notebooks/v2/internal/notebook_stub.cc | 59 ++++++ .../notebooks/v2/internal/notebook_stub.h | 57 +++++- .../v2/internal/notebook_stub_factory.cc | 8 +- .../internal/notebook_tracing_connection.cc | 47 +++++ .../v2/internal/notebook_tracing_connection.h | 15 ++ .../v2/internal/notebook_tracing_stub.cc | 58 ++++++ .../v2/internal/notebook_tracing_stub.h | 20 ++ .../v2/mocks/mock_notebook_connection.h | 21 +++ google/cloud/notebooks/v2/notebook_client.cc | 32 ++++ google/cloud/notebooks/v2/notebook_client.h | 172 +++++++++++++++++ .../cloud/notebooks/v2/notebook_connection.cc | 30 +++ .../cloud/notebooks/v2/notebook_connection.h | 17 ++ .../notebook_connection_idempotency_policy.cc | 26 +++ .../notebook_connection_idempotency_policy.h | 17 ++ google/cloud/privateca/BUILD.bazel | 2 + .../v1/certificate_authority_client.cc | 35 ++++ .../v1/certificate_authority_client.h | 172 +++++++++++++++++ .../v1/certificate_authority_connection.cc | 32 ++++ .../v1/certificate_authority_connection.h | 17 ++ ...authority_connection_idempotency_policy.cc | 30 +++ ..._authority_connection_idempotency_policy.h | 17 ++ .../certificate_authority_auth_decorator.cc | 43 +++++ .../certificate_authority_auth_decorator.h | 20 ++ .../certificate_authority_connection_impl.cc | 91 +++++++++ .../certificate_authority_connection_impl.h | 15 ++ ...certificate_authority_logging_decorator.cc | 60 ++++++ .../certificate_authority_logging_decorator.h | 20 ++ ...ertificate_authority_metadata_decorator.cc | 48 +++++ ...certificate_authority_metadata_decorator.h | 20 ++ .../v1/internal/certificate_authority_stub.cc | 61 ++++++ .../v1/internal/certificate_authority_stub.h | 57 +++++- .../certificate_authority_stub_factory.cc | 8 +- ...ertificate_authority_tracing_connection.cc | 48 +++++ ...certificate_authority_tracing_connection.h | 15 ++ .../certificate_authority_tracing_stub.cc | 65 +++++++ .../certificate_authority_tracing_stub.h | 20 ++ .../mock_certificate_authority_connection.h | 21 +++ .../cloud/privilegedaccessmanager/BUILD.bazel | 2 + ...rivileged_access_manager_auth_decorator.cc | 18 ++ ...privileged_access_manager_auth_decorator.h | 8 + ...ivileged_access_manager_connection_impl.cc | 49 +++++ ...rivileged_access_manager_connection_impl.h | 6 + ...ileged_access_manager_logging_decorator.cc | 24 +++ ...vileged_access_manager_logging_decorator.h | 8 + ...leged_access_manager_metadata_decorator.cc | 18 ++ ...ileged_access_manager_metadata_decorator.h | 8 + .../privileged_access_manager_stub.cc | 24 +++ .../internal/privileged_access_manager_stub.h | 27 ++- .../privileged_access_manager_stub_factory.cc | 5 +- ...leged_access_manager_tracing_connection.cc | 22 +++ ...ileged_access_manager_tracing_connection.h | 6 + .../privileged_access_manager_tracing_stub.cc | 26 +++ .../privileged_access_manager_tracing_stub.h | 8 + ...ock_privileged_access_manager_connection.h | 8 + .../v1/privileged_access_manager_client.cc | 14 ++ .../v1/privileged_access_manager_client.h | 71 +++++++ .../privileged_access_manager_connection.cc | 14 ++ .../v1/privileged_access_manager_connection.h | 7 + ...s_manager_connection_idempotency_policy.cc | 10 + ...ss_manager_connection_idempotency_policy.h | 7 + google/cloud/pubsub/BUILD.bazel | 2 + .../admin/internal/subscription_admin_stub.h | 1 + .../pubsub/admin/internal/topic_admin_stub.h | 1 + .../admin/subscription_admin_connection.h | 1 + .../pubsub/admin/topic_admin_connection.h | 1 + google/cloud/pubsub/internal/publisher_stub.h | 1 + google/cloud/pubsub/internal/schema_stub.h | 1 + .../cloud/pubsub/internal/subscriber_stub.h | 1 + google/cloud/pubsub/quickstart/MODULE.bazel | 6 + google/cloud/pubsub/schema_connection.h | 1 + .../rapidmigrationassessment/BUILD.bazel | 2 + ...pid_migration_assessment_auth_decorator.cc | 18 ++ ...apid_migration_assessment_auth_decorator.h | 8 + ...id_migration_assessment_connection_impl.cc | 49 +++++ ...pid_migration_assessment_connection_impl.h | 6 + ..._migration_assessment_logging_decorator.cc | 24 +++ ...d_migration_assessment_logging_decorator.h | 8 + ...migration_assessment_metadata_decorator.cc | 18 ++ ..._migration_assessment_metadata_decorator.h | 8 + .../rapid_migration_assessment_stub.cc | 24 +++ .../rapid_migration_assessment_stub.h | 27 ++- ...rapid_migration_assessment_stub_factory.cc | 5 +- ...migration_assessment_tracing_connection.cc | 22 +++ ..._migration_assessment_tracing_connection.h | 6 + ...rapid_migration_assessment_tracing_stub.cc | 26 +++ .../rapid_migration_assessment_tracing_stub.h | 8 + ...ck_rapid_migration_assessment_connection.h | 8 + .../v1/rapid_migration_assessment_client.cc | 14 ++ .../v1/rapid_migration_assessment_client.h | 70 +++++++ .../rapid_migration_assessment_connection.cc | 14 ++ .../rapid_migration_assessment_connection.h | 7 + ...ssessment_connection_idempotency_policy.cc | 10 + ...assessment_connection_idempotency_policy.h | 7 + google/cloud/redis/BUILD.bazel | 2 + .../cluster/v1/cloud_redis_cluster_client.cc | 14 ++ .../cluster/v1/cloud_redis_cluster_client.h | 70 +++++++ .../v1/cloud_redis_cluster_connection.cc | 14 ++ .../v1/cloud_redis_cluster_connection.h | 7 + ...s_cluster_connection_idempotency_policy.cc | 10 + ...is_cluster_connection_idempotency_policy.h | 7 + .../cloud_redis_cluster_auth_decorator.cc | 17 ++ .../cloud_redis_cluster_auth_decorator.h | 8 + .../cloud_redis_cluster_connection_impl.cc | 48 +++++ .../cloud_redis_cluster_connection_impl.h | 6 + .../cloud_redis_cluster_logging_decorator.cc | 24 +++ .../cloud_redis_cluster_logging_decorator.h | 8 + .../cloud_redis_cluster_metadata_decorator.cc | 18 ++ .../cloud_redis_cluster_metadata_decorator.h | 8 + .../v1/internal/cloud_redis_cluster_stub.cc | 24 +++ .../v1/internal/cloud_redis_cluster_stub.h | 27 ++- .../cloud_redis_cluster_stub_factory.cc | 5 +- .../cloud_redis_cluster_tracing_connection.cc | 20 ++ .../cloud_redis_cluster_tracing_connection.h | 6 + .../cloud_redis_cluster_tracing_stub.cc | 24 +++ .../cloud_redis_cluster_tracing_stub.h | 8 + .../mock_cloud_redis_cluster_connection.h | 8 + google/cloud/redis/v1/cloud_redis_client.cc | 12 ++ google/cloud/redis/v1/cloud_redis_client.h | 70 +++++++ .../cloud/redis/v1/cloud_redis_connection.cc | 13 ++ .../cloud/redis/v1/cloud_redis_connection.h | 7 + ...oud_redis_connection_idempotency_policy.cc | 10 + ...loud_redis_connection_idempotency_policy.h | 7 + .../v1/internal/cloud_redis_auth_decorator.cc | 17 ++ .../v1/internal/cloud_redis_auth_decorator.h | 8 + .../internal/cloud_redis_connection_impl.cc | 48 +++++ .../v1/internal/cloud_redis_connection_impl.h | 6 + .../internal/cloud_redis_logging_decorator.cc | 23 +++ .../internal/cloud_redis_logging_decorator.h | 8 + .../cloud_redis_metadata_decorator.cc | 17 ++ .../internal/cloud_redis_metadata_decorator.h | 8 + .../redis/v1/internal/cloud_redis_stub.cc | 23 +++ .../redis/v1/internal/cloud_redis_stub.h | 27 ++- .../v1/internal/cloud_redis_stub_factory.cc | 5 +- .../cloud_redis_tracing_connection.cc | 19 ++ .../internal/cloud_redis_tracing_connection.h | 6 + .../v1/internal/cloud_redis_tracing_stub.cc | 23 +++ .../v1/internal/cloud_redis_tracing_stub.h | 8 + .../v1/mocks/mock_cloud_redis_connection.h | 8 + google/cloud/retail/BUILD.bazel | 2 + google/cloud/retail/v2/analytics_connection.h | 1 + google/cloud/retail/v2/catalog_connection.h | 1 + .../cloud/retail/v2/completion_connection.h | 1 + google/cloud/retail/v2/control_connection.h | 1 + .../cloud/retail/v2/internal/analytics_stub.h | 1 + .../cloud/retail/v2/internal/catalog_stub.h | 1 + .../retail/v2/internal/completion_stub.h | 1 + .../cloud/retail/v2/internal/control_stub.h | 1 + google/cloud/retail/v2/internal/model_stub.h | 1 + .../retail/v2/internal/prediction_stub.h | 1 + .../cloud/retail/v2/internal/product_stub.h | 1 + google/cloud/retail/v2/internal/search_stub.h | 1 + .../retail/v2/internal/serving_config_stub.h | 1 + .../retail/v2/internal/user_event_stub.h | 1 + google/cloud/retail/v2/model_connection.h | 1 + .../cloud/retail/v2/prediction_connection.h | 1 + google/cloud/retail/v2/product_connection.h | 1 + google/cloud/retail/v2/search_connection.h | 1 + .../retail/v2/serving_config_connection.h | 1 + .../cloud/retail/v2/user_event_connection.h | 1 + google/cloud/run/BUILD.bazel | 2 + google/cloud/run/v2/executions_connection.h | 1 + .../cloud/run/v2/internal/executions_stub.h | 1 + google/cloud/run/v2/internal/jobs_stub.h | 1 + google/cloud/run/v2/internal/revisions_stub.h | 1 + google/cloud/run/v2/internal/services_stub.h | 1 + google/cloud/run/v2/internal/tasks_stub.h | 1 + google/cloud/run/v2/jobs_connection.h | 1 + google/cloud/run/v2/revisions_connection.h | 1 + google/cloud/run/v2/services_connection.h | 1 + google/cloud/run/v2/tasks_connection.h | 1 + google/cloud/scheduler/BUILD.bazel | 2 + .../scheduler/v1/cloud_scheduler_client.cc | 13 ++ .../scheduler/v1/cloud_scheduler_client.h | 71 +++++++ .../v1/cloud_scheduler_connection.cc | 14 ++ .../scheduler/v1/cloud_scheduler_connection.h | 7 + ...scheduler_connection_idempotency_policy.cc | 10 + ..._scheduler_connection_idempotency_policy.h | 7 + .../cloud_scheduler_auth_decorator.cc | 17 ++ .../internal/cloud_scheduler_auth_decorator.h | 8 + .../cloud_scheduler_connection_impl.cc | 48 +++++ .../cloud_scheduler_connection_impl.h | 6 + .../cloud_scheduler_logging_decorator.cc | 23 +++ .../cloud_scheduler_logging_decorator.h | 8 + .../cloud_scheduler_metadata_decorator.cc | 17 ++ .../cloud_scheduler_metadata_decorator.h | 8 + .../v1/internal/cloud_scheduler_stub.cc | 24 +++ .../v1/internal/cloud_scheduler_stub.h | 28 ++- .../internal/cloud_scheduler_stub_factory.cc | 6 +- .../cloud_scheduler_tracing_connection.cc | 20 ++ .../cloud_scheduler_tracing_connection.h | 6 + .../internal/cloud_scheduler_tracing_stub.cc | 24 +++ .../internal/cloud_scheduler_tracing_stub.h | 8 + .../mocks/mock_cloud_scheduler_connection.h | 8 + google/cloud/secretmanager/BUILD.bazel | 2 + .../internal/secret_manager_auth_decorator.cc | 18 ++ .../internal/secret_manager_auth_decorator.h | 8 + .../secret_manager_connection_impl.cc | 49 +++++ .../internal/secret_manager_connection_impl.h | 6 + .../secret_manager_logging_decorator.cc | 24 +++ .../secret_manager_logging_decorator.h | 8 + .../secret_manager_metadata_decorator.cc | 18 ++ .../secret_manager_metadata_decorator.h | 8 + .../v1/internal/secret_manager_stub.cc | 24 +++ .../v1/internal/secret_manager_stub.h | 28 ++- .../internal/secret_manager_stub_factory.cc | 5 +- .../secret_manager_tracing_connection.cc | 20 ++ .../secret_manager_tracing_connection.h | 6 + .../internal/secret_manager_tracing_stub.cc | 24 +++ .../v1/internal/secret_manager_tracing_stub.h | 8 + .../v1/mocks/mock_secret_manager_connection.h | 8 + .../secretmanager/v1/secret_manager_client.cc | 14 ++ .../secretmanager/v1/secret_manager_client.h | 70 +++++++ .../v1/secret_manager_connection.cc | 14 ++ .../v1/secret_manager_connection.h | 7 + ...t_manager_connection_idempotency_policy.cc | 10 + ...et_manager_connection_idempotency_policy.h | 7 + google/cloud/securesourcemanager/BUILD.bazel | 2 + .../secure_source_manager_auth_decorator.cc | 43 +++++ .../secure_source_manager_auth_decorator.h | 20 ++ .../secure_source_manager_connection_impl.cc | 91 +++++++++ .../secure_source_manager_connection_impl.h | 15 ++ ...secure_source_manager_logging_decorator.cc | 58 ++++++ .../secure_source_manager_logging_decorator.h | 20 ++ ...ecure_source_manager_metadata_decorator.cc | 46 +++++ ...secure_source_manager_metadata_decorator.h | 20 ++ .../v1/internal/secure_source_manager_stub.cc | 59 ++++++ .../v1/internal/secure_source_manager_stub.h | 57 +++++- .../secure_source_manager_stub_factory.cc | 8 +- ...ecure_source_manager_tracing_connection.cc | 48 +++++ ...secure_source_manager_tracing_connection.h | 15 ++ .../secure_source_manager_tracing_stub.cc | 62 +++++++ .../secure_source_manager_tracing_stub.h | 20 ++ .../mock_secure_source_manager_connection.h | 21 +++ .../v1/secure_source_manager_client.cc | 33 ++++ .../v1/secure_source_manager_client.h | 172 +++++++++++++++++ .../v1/secure_source_manager_connection.cc | 30 +++ .../v1/secure_source_manager_connection.h | 17 ++ ...e_manager_connection_idempotency_policy.cc | 26 +++ ...ce_manager_connection_idempotency_policy.h | 17 ++ .../securitycentermanagement/BUILD.bazel | 2 + ...curity_center_management_auth_decorator.cc | 18 ++ ...ecurity_center_management_auth_decorator.h | 8 + ...urity_center_management_connection_impl.cc | 49 +++++ ...curity_center_management_connection_impl.h | 6 + ...ity_center_management_logging_decorator.cc | 24 +++ ...rity_center_management_logging_decorator.h | 8 + ...ty_center_management_metadata_decorator.cc | 18 ++ ...ity_center_management_metadata_decorator.h | 8 + .../security_center_management_stub.cc | 24 +++ .../security_center_management_stub.h | 28 ++- ...security_center_management_stub_factory.cc | 5 +- ...ty_center_management_tracing_connection.cc | 22 +++ ...ity_center_management_tracing_connection.h | 6 + ...security_center_management_tracing_stub.cc | 26 +++ .../security_center_management_tracing_stub.h | 8 + ...ck_security_center_management_connection.h | 8 + .../v1/security_center_management_client.cc | 14 ++ .../v1/security_center_management_client.h | 70 +++++++ .../security_center_management_connection.cc | 14 ++ .../security_center_management_connection.h | 7 + ...anagement_connection_idempotency_policy.cc | 10 + ...management_connection_idempotency_policy.h | 7 + google/cloud/servicedirectory/BUILD.bazel | 2 + .../v1/internal/lookup_auth_decorator.cc | 17 ++ .../v1/internal/lookup_auth_decorator.h | 8 + .../v1/internal/lookup_connection_impl.cc | 49 +++++ .../v1/internal/lookup_connection_impl.h | 7 + .../v1/internal/lookup_logging_decorator.cc | 23 +++ .../v1/internal/lookup_logging_decorator.h | 8 + .../v1/internal/lookup_metadata_decorator.cc | 17 ++ .../v1/internal/lookup_metadata_decorator.h | 8 + .../v1/internal/lookup_stub.cc | 24 +++ .../v1/internal/lookup_stub.h | 28 ++- .../v1/internal/lookup_stub_factory.cc | 6 +- .../v1/internal/lookup_tracing_connection.cc | 21 +++ .../v1/internal/lookup_tracing_connection.h | 6 + .../v1/internal/lookup_tracing_stub.cc | 24 +++ .../v1/internal/lookup_tracing_stub.h | 8 + .../internal/registration_auth_decorator.cc | 18 ++ .../v1/internal/registration_auth_decorator.h | 8 + .../internal/registration_connection_impl.cc | 49 +++++ .../internal/registration_connection_impl.h | 6 + .../registration_logging_decorator.cc | 24 +++ .../internal/registration_logging_decorator.h | 8 + .../registration_metadata_decorator.cc | 18 ++ .../registration_metadata_decorator.h | 8 + .../v1/internal/registration_stub.cc | 24 +++ .../v1/internal/registration_stub.h | 28 ++- .../v1/internal/registration_stub_factory.cc | 5 +- .../registration_tracing_connection.cc | 20 ++ .../registration_tracing_connection.h | 6 + .../v1/internal/registration_tracing_stub.cc | 24 +++ .../v1/internal/registration_tracing_stub.h | 8 + .../servicedirectory/v1/lookup_client.cc | 13 ++ .../cloud/servicedirectory/v1/lookup_client.h | 71 +++++++ .../servicedirectory/v1/lookup_connection.cc | 15 ++ .../servicedirectory/v1/lookup_connection.h | 8 + .../lookup_connection_idempotency_policy.cc | 10 + .../v1/lookup_connection_idempotency_policy.h | 7 + .../v1/mocks/mock_lookup_connection.h | 8 + .../v1/mocks/mock_registration_connection.h | 8 + .../v1/registration_client.cc | 14 ++ .../servicedirectory/v1/registration_client.h | 70 +++++++ .../v1/registration_connection.cc | 14 ++ .../v1/registration_connection.h | 7 + ...istration_connection_idempotency_policy.cc | 10 + ...gistration_connection_idempotency_policy.h | 7 + google/cloud/servicehealth/BUILD.bazel | 2 + .../internal/service_health_auth_decorator.cc | 17 ++ .../internal/service_health_auth_decorator.h | 8 + .../service_health_connection_impl.cc | 48 +++++ .../internal/service_health_connection_impl.h | 6 + .../service_health_logging_decorator.cc | 23 +++ .../service_health_logging_decorator.h | 8 + .../service_health_metadata_decorator.cc | 17 ++ .../service_health_metadata_decorator.h | 8 + .../v1/internal/service_health_stub.cc | 24 +++ .../v1/internal/service_health_stub.h | 28 ++- .../internal/service_health_stub_factory.cc | 6 +- .../service_health_tracing_connection.cc | 20 ++ .../service_health_tracing_connection.h | 6 + .../internal/service_health_tracing_stub.cc | 24 +++ .../v1/internal/service_health_tracing_stub.h | 8 + .../v1/mocks/mock_service_health_connection.h | 8 + .../servicehealth/v1/service_health_client.cc | 13 ++ .../servicehealth/v1/service_health_client.h | 71 +++++++ .../v1/service_health_connection.cc | 14 ++ .../v1/service_health_connection.h | 7 + ...ce_health_connection_idempotency_policy.cc | 10 + ...ice_health_connection_idempotency_policy.h | 7 + google/cloud/servicemanagement/BUILD.bazel | 2 + .../service_manager_auth_decorator.cc | 25 +++ .../internal/service_manager_auth_decorator.h | 12 ++ .../service_manager_connection_impl.cc | 40 ++++ .../service_manager_connection_impl.h | 9 + .../service_manager_logging_decorator.cc | 34 ++++ .../service_manager_logging_decorator.h | 12 ++ .../service_manager_metadata_decorator.cc | 28 +++ .../service_manager_metadata_decorator.h | 12 ++ .../v1/internal/service_manager_stub.cc | 35 ++++ .../v1/internal/service_manager_stub.h | 33 +++- .../internal/service_manager_stub_factory.cc | 4 +- .../service_manager_tracing_connection.cc | 25 +++ .../service_manager_tracing_connection.h | 9 + .../internal/service_manager_tracing_stub.cc | 34 ++++ .../internal/service_manager_tracing_stub.h | 12 ++ .../mocks/mock_service_manager_connection.h | 13 ++ .../v1/service_manager_client.cc | 19 ++ .../v1/service_manager_client.h | 102 +++++++++++ .../v1/service_manager_connection.cc | 16 ++ .../v1/service_manager_connection.h | 10 + ...e_manager_connection_idempotency_policy.cc | 16 ++ ...ce_manager_connection_idempotency_policy.h | 10 + google/cloud/speech/BUILD.bazel | 2 + .../v2/internal/speech_auth_decorator.cc | 17 ++ .../v2/internal/speech_auth_decorator.h | 8 + .../v2/internal/speech_connection_impl.cc | 47 +++++ .../v2/internal/speech_connection_impl.h | 6 + .../v2/internal/speech_logging_decorator.cc | 23 +++ .../v2/internal/speech_logging_decorator.h | 8 + .../v2/internal/speech_metadata_decorator.cc | 17 ++ .../v2/internal/speech_metadata_decorator.h | 8 + .../cloud/speech/v2/internal/speech_stub.cc | 23 +++ google/cloud/speech/v2/internal/speech_stub.h | 27 ++- .../speech/v2/internal/speech_stub_factory.cc | 5 +- .../v2/internal/speech_tracing_connection.cc | 18 ++ .../v2/internal/speech_tracing_connection.h | 6 + .../speech/v2/internal/speech_tracing_stub.cc | 23 +++ .../speech/v2/internal/speech_tracing_stub.h | 8 + .../speech/v2/mocks/mock_speech_connection.h | 8 + google/cloud/speech/v2/speech_client.cc | 12 ++ google/cloud/speech/v2/speech_client.h | 70 +++++++ google/cloud/speech/v2/speech_connection.cc | 12 ++ google/cloud/speech/v2/speech_connection.h | 7 + .../speech_connection_idempotency_policy.cc | 10 + .../v2/speech_connection_idempotency_policy.h | 7 + google/cloud/sql/BUILD.bazel | 2 + ...ql_available_database_versions_rest_stub.h | 1 + .../v1/internal/sql_backup_runs_rest_stub.h | 1 + .../sql/v1/internal/sql_connect_rest_stub.h | 1 + .../sql/v1/internal/sql_databases_rest_stub.h | 1 + .../sql/v1/internal/sql_events_rest_stub.h | 1 + .../sql/v1/internal/sql_flags_rest_stub.h | 1 + .../v1/internal/sql_iam_policies_rest_stub.h | 1 + .../internal/sql_instance_names_rest_stub.h | 1 + .../sql/v1/internal/sql_instances_rest_stub.h | 1 + .../v1/internal/sql_operations_rest_stub.h | 1 + .../sql/v1/internal/sql_regions_rest_stub.h | 1 + .../sql/v1/internal/sql_ssl_certs_rest_stub.h | 1 + .../sql/v1/internal/sql_tiers_rest_stub.h | 1 + .../sql/v1/internal/sql_users_rest_stub.h | 1 + ...l_available_database_versions_connection.h | 1 + .../cloud/sql/v1/sql_backup_runs_connection.h | 1 + google/cloud/sql/v1/sql_connect_connection.h | 1 + .../cloud/sql/v1/sql_databases_connection.h | 1 + google/cloud/sql/v1/sql_events_connection.h | 1 + google/cloud/sql/v1/sql_flags_connection.h | 1 + .../sql/v1/sql_iam_policies_connection.h | 1 + .../sql/v1/sql_instance_names_connection.h | 1 + .../cloud/sql/v1/sql_instances_connection.h | 1 + .../cloud/sql/v1/sql_operations_connection.h | 1 + google/cloud/sql/v1/sql_regions_connection.h | 1 + .../cloud/sql/v1/sql_ssl_certs_connection.h | 1 + google/cloud/sql/v1/sql_tiers_connection.h | 1 + google/cloud/sql/v1/sql_users_connection.h | 1 + google/cloud/storageinsights/BUILD.bazel | 2 + .../storage_insights_auth_decorator.cc | 17 ++ .../storage_insights_auth_decorator.h | 8 + .../storage_insights_connection_impl.cc | 48 +++++ .../storage_insights_connection_impl.h | 6 + .../storage_insights_logging_decorator.cc | 23 +++ .../storage_insights_logging_decorator.h | 8 + .../storage_insights_metadata_decorator.cc | 18 ++ .../storage_insights_metadata_decorator.h | 8 + .../v1/internal/storage_insights_stub.cc | 24 +++ .../v1/internal/storage_insights_stub.h | 28 ++- .../internal/storage_insights_stub_factory.cc | 5 +- .../storage_insights_tracing_connection.cc | 20 ++ .../storage_insights_tracing_connection.h | 6 + .../internal/storage_insights_tracing_stub.cc | 24 +++ .../internal/storage_insights_tracing_stub.h | 8 + .../mocks/mock_storage_insights_connection.h | 8 + .../v1/storage_insights_client.cc | 13 ++ .../v1/storage_insights_client.h | 70 +++++++ .../v1/storage_insights_connection.cc | 14 ++ .../v1/storage_insights_connection.h | 7 + ..._insights_connection_idempotency_policy.cc | 10 + ...e_insights_connection_idempotency_policy.h | 7 + google/cloud/tasks/BUILD.bazel | 2 + google/cloud/tasks/v2/cloud_tasks_client.cc | 12 ++ google/cloud/tasks/v2/cloud_tasks_client.h | 72 ++++++++ .../cloud/tasks/v2/cloud_tasks_connection.cc | 13 ++ .../cloud/tasks/v2/cloud_tasks_connection.h | 7 + ...oud_tasks_connection_idempotency_policy.cc | 10 + ...loud_tasks_connection_idempotency_policy.h | 7 + .../v2/internal/cloud_tasks_auth_decorator.cc | 17 ++ .../v2/internal/cloud_tasks_auth_decorator.h | 8 + .../internal/cloud_tasks_connection_impl.cc | 48 +++++ .../v2/internal/cloud_tasks_connection_impl.h | 6 + .../internal/cloud_tasks_logging_decorator.cc | 23 +++ .../internal/cloud_tasks_logging_decorator.h | 8 + .../cloud_tasks_metadata_decorator.cc | 17 ++ .../internal/cloud_tasks_metadata_decorator.h | 8 + .../tasks/v2/internal/cloud_tasks_stub.cc | 23 +++ .../tasks/v2/internal/cloud_tasks_stub.h | 28 ++- .../v2/internal/cloud_tasks_stub_factory.cc | 6 +- .../cloud_tasks_tracing_connection.cc | 19 ++ .../internal/cloud_tasks_tracing_connection.h | 6 + .../v2/internal/cloud_tasks_tracing_stub.cc | 23 +++ .../v2/internal/cloud_tasks_tracing_stub.h | 8 + .../v2/mocks/mock_cloud_tasks_connection.h | 8 + google/cloud/telcoautomation/BUILD.bazel | 2 + .../telco_automation_auth_decorator.cc | 17 ++ .../telco_automation_auth_decorator.h | 8 + .../telco_automation_connection_impl.cc | 48 +++++ .../telco_automation_connection_impl.h | 6 + .../telco_automation_logging_decorator.cc | 23 +++ .../telco_automation_logging_decorator.h | 8 + .../telco_automation_metadata_decorator.cc | 18 ++ .../telco_automation_metadata_decorator.h | 8 + .../v1/internal/telco_automation_stub.cc | 24 +++ .../v1/internal/telco_automation_stub.h | 27 ++- .../internal/telco_automation_stub_factory.cc | 5 +- .../telco_automation_tracing_connection.cc | 20 ++ .../telco_automation_tracing_connection.h | 6 + .../internal/telco_automation_tracing_stub.cc | 24 +++ .../internal/telco_automation_tracing_stub.h | 8 + .../mocks/mock_telco_automation_connection.h | 8 + .../v1/telco_automation_client.cc | 13 ++ .../v1/telco_automation_client.h | 70 +++++++ .../v1/telco_automation_connection.cc | 14 ++ .../v1/telco_automation_connection.h | 7 + ...utomation_connection_idempotency_policy.cc | 10 + ...automation_connection_idempotency_policy.h | 7 + google/cloud/timeseriesinsights/BUILD.bazel | 2 + .../timeseries_insights_controller_stub.h | 1 + ...imeseries_insights_controller_connection.h | 1 + google/cloud/tpu/BUILD.bazel | 2 + .../tpu/v1/internal/tpu_auth_decorator.cc | 16 ++ .../tpu/v1/internal/tpu_auth_decorator.h | 8 + .../tpu/v1/internal/tpu_connection_impl.cc | 45 +++++ .../tpu/v1/internal/tpu_connection_impl.h | 6 + .../tpu/v1/internal/tpu_logging_decorator.cc | 23 +++ .../tpu/v1/internal/tpu_logging_decorator.h | 8 + .../tpu/v1/internal/tpu_metadata_decorator.cc | 17 ++ .../tpu/v1/internal/tpu_metadata_decorator.h | 8 + google/cloud/tpu/v1/internal/tpu_stub.cc | 23 +++ google/cloud/tpu/v1/internal/tpu_stub.h | 27 ++- .../cloud/tpu/v1/internal/tpu_stub_factory.cc | 5 +- .../tpu/v1/internal/tpu_tracing_connection.cc | 17 ++ .../tpu/v1/internal/tpu_tracing_connection.h | 6 + .../cloud/tpu/v1/internal/tpu_tracing_stub.cc | 22 +++ .../cloud/tpu/v1/internal/tpu_tracing_stub.h | 8 + .../cloud/tpu/v1/mocks/mock_tpu_connection.h | 8 + google/cloud/tpu/v1/tpu_client.cc | 12 ++ google/cloud/tpu/v1/tpu_client.h | 70 +++++++ google/cloud/tpu/v1/tpu_connection.cc | 12 ++ google/cloud/tpu/v1/tpu_connection.h | 7 + .../v1/tpu_connection_idempotency_policy.cc | 10 + .../v1/tpu_connection_idempotency_policy.h | 7 + .../tpu/v2/internal/tpu_auth_decorator.cc | 16 ++ .../tpu/v2/internal/tpu_auth_decorator.h | 8 + .../tpu/v2/internal/tpu_connection_impl.cc | 45 +++++ .../tpu/v2/internal/tpu_connection_impl.h | 6 + .../tpu/v2/internal/tpu_logging_decorator.cc | 23 +++ .../tpu/v2/internal/tpu_logging_decorator.h | 8 + .../tpu/v2/internal/tpu_metadata_decorator.cc | 17 ++ .../tpu/v2/internal/tpu_metadata_decorator.h | 8 + google/cloud/tpu/v2/internal/tpu_stub.cc | 23 +++ google/cloud/tpu/v2/internal/tpu_stub.h | 27 ++- .../cloud/tpu/v2/internal/tpu_stub_factory.cc | 5 +- .../tpu/v2/internal/tpu_tracing_connection.cc | 17 ++ .../tpu/v2/internal/tpu_tracing_connection.h | 6 + .../cloud/tpu/v2/internal/tpu_tracing_stub.cc | 22 +++ .../cloud/tpu/v2/internal/tpu_tracing_stub.h | 8 + .../cloud/tpu/v2/mocks/mock_tpu_connection.h | 8 + google/cloud/tpu/v2/tpu_client.cc | 12 ++ google/cloud/tpu/v2/tpu_client.h | 70 +++++++ google/cloud/tpu/v2/tpu_connection.cc | 12 ++ google/cloud/tpu/v2/tpu_connection.h | 7 + .../v2/tpu_connection_idempotency_policy.cc | 10 + .../v2/tpu_connection_idempotency_policy.h | 7 + google/cloud/translate/BUILD.bazel | 2 + .../v3/internal/translation_auth_decorator.cc | 17 ++ .../v3/internal/translation_auth_decorator.h | 8 + .../internal/translation_connection_impl.cc | 48 +++++ .../v3/internal/translation_connection_impl.h | 6 + .../internal/translation_logging_decorator.cc | 24 +++ .../internal/translation_logging_decorator.h | 8 + .../translation_metadata_decorator.cc | 18 ++ .../internal/translation_metadata_decorator.h | 8 + .../translate/v3/internal/translation_stub.cc | 24 +++ .../translate/v3/internal/translation_stub.h | 28 ++- .../v3/internal/translation_stub_factory.cc | 5 +- .../translation_tracing_connection.cc | 20 ++ .../internal/translation_tracing_connection.h | 6 + .../v3/internal/translation_tracing_stub.cc | 24 +++ .../v3/internal/translation_tracing_stub.h | 8 + .../v3/mocks/mock_translation_connection.h | 8 + .../cloud/translate/v3/translation_client.cc | 14 ++ .../cloud/translate/v3/translation_client.h | 70 +++++++ .../translate/v3/translation_connection.cc | 14 ++ .../translate/v3/translation_connection.h | 8 + ...anslation_connection_idempotency_policy.cc | 10 + ...ranslation_connection_idempotency_policy.h | 7 + google/cloud/video/BUILD.bazel | 2 + .../v1/internal/livestream_auth_decorator.cc | 17 ++ .../v1/internal/livestream_auth_decorator.h | 8 + .../v1/internal/livestream_connection_impl.cc | 49 +++++ .../v1/internal/livestream_connection_impl.h | 6 + .../internal/livestream_logging_decorator.cc | 24 +++ .../internal/livestream_logging_decorator.h | 8 + .../internal/livestream_metadata_decorator.cc | 18 ++ .../internal/livestream_metadata_decorator.h | 8 + .../livestream/v1/internal/livestream_stub.cc | 24 +++ .../livestream/v1/internal/livestream_stub.h | 27 ++- .../v1/internal/livestream_stub_factory.cc | 5 +- .../internal/livestream_tracing_connection.cc | 20 ++ .../internal/livestream_tracing_connection.h | 6 + .../v1/internal/livestream_tracing_stub.cc | 24 +++ .../v1/internal/livestream_tracing_stub.h | 8 + .../video/livestream/v1/livestream_client.cc | 14 ++ .../video/livestream/v1/livestream_client.h | 70 +++++++ .../livestream/v1/livestream_connection.cc | 14 ++ .../livestream/v1/livestream_connection.h | 7 + ...ivestream_connection_idempotency_policy.cc | 10 + ...livestream_connection_idempotency_policy.h | 7 + .../v1/mocks/mock_livestream_connection.h | 8 + google/cloud/vmmigration/BUILD.bazel | 2 + .../internal/vm_migration_auth_decorator.cc | 17 ++ .../v1/internal/vm_migration_auth_decorator.h | 8 + .../internal/vm_migration_connection_impl.cc | 48 +++++ .../internal/vm_migration_connection_impl.h | 6 + .../vm_migration_logging_decorator.cc | 23 +++ .../internal/vm_migration_logging_decorator.h | 8 + .../vm_migration_metadata_decorator.cc | 17 ++ .../vm_migration_metadata_decorator.h | 8 + .../v1/internal/vm_migration_stub.cc | 23 +++ .../v1/internal/vm_migration_stub.h | 28 ++- .../v1/internal/vm_migration_stub_factory.cc | 5 +- .../vm_migration_tracing_connection.cc | 20 ++ .../vm_migration_tracing_connection.h | 6 + .../v1/internal/vm_migration_tracing_stub.cc | 23 +++ .../v1/internal/vm_migration_tracing_stub.h | 8 + .../v1/mocks/mock_vm_migration_connection.h | 8 + .../vmmigration/v1/vm_migration_client.cc | 12 ++ .../vmmigration/v1/vm_migration_client.h | 70 +++++++ .../vmmigration/v1/vm_migration_connection.cc | 13 ++ .../vmmigration/v1/vm_migration_connection.h | 8 + ...migration_connection_idempotency_policy.cc | 10 + ..._migration_connection_idempotency_policy.h | 7 + google/cloud/vmwareengine/BUILD.bazel | 2 + .../internal/vmware_engine_auth_decorator.cc | 42 +++++ .../internal/vmware_engine_auth_decorator.h | 20 ++ .../internal/vmware_engine_connection_impl.cc | 88 +++++++++ .../internal/vmware_engine_connection_impl.h | 15 ++ .../vmware_engine_logging_decorator.cc | 57 ++++++ .../vmware_engine_logging_decorator.h | 20 ++ .../vmware_engine_metadata_decorator.cc | 45 +++++ .../vmware_engine_metadata_decorator.h | 20 ++ .../v1/internal/vmware_engine_stub.cc | 59 ++++++ .../v1/internal/vmware_engine_stub.h | 57 +++++- .../v1/internal/vmware_engine_stub_factory.cc | 8 +- .../vmware_engine_tracing_connection.cc | 45 +++++ .../vmware_engine_tracing_connection.h | 15 ++ .../v1/internal/vmware_engine_tracing_stub.cc | 58 ++++++ .../v1/internal/vmware_engine_tracing_stub.h | 20 ++ .../v1/mocks/mock_vmware_engine_connection.h | 21 +++ .../vmwareengine/v1/vmware_engine_client.cc | 32 ++++ .../vmwareengine/v1/vmware_engine_client.h | 172 +++++++++++++++++ .../v1/vmware_engine_connection.cc | 29 +++ .../v1/vmware_engine_connection.h | 17 ++ ...re_engine_connection_idempotency_policy.cc | 26 +++ ...are_engine_connection_idempotency_policy.h | 17 ++ google/cloud/vpcaccess/BUILD.bazel | 2 + .../v1/internal/vpc_access_auth_decorator.cc | 9 + .../v1/internal/vpc_access_auth_decorator.h | 4 + .../v1/internal/vpc_access_connection_impl.cc | 34 ++++ .../v1/internal/vpc_access_connection_impl.h | 3 + .../internal/vpc_access_logging_decorator.cc | 12 ++ .../internal/vpc_access_logging_decorator.h | 4 + .../internal/vpc_access_metadata_decorator.cc | 9 + .../internal/vpc_access_metadata_decorator.h | 4 + .../vpcaccess/v1/internal/vpc_access_stub.cc | 12 ++ .../vpcaccess/v1/internal/vpc_access_stub.h | 19 +- .../v1/internal/vpc_access_stub_factory.cc | 5 +- .../internal/vpc_access_tracing_connection.cc | 11 ++ .../internal/vpc_access_tracing_connection.h | 3 + .../v1/internal/vpc_access_tracing_stub.cc | 12 ++ .../v1/internal/vpc_access_tracing_stub.h | 4 + .../v1/mocks/mock_vpc_access_connection.h | 4 + .../cloud/vpcaccess/v1/vpc_access_client.cc | 7 + google/cloud/vpcaccess/v1/vpc_access_client.h | 39 ++++ .../vpcaccess/v1/vpc_access_connection.cc | 8 + .../vpcaccess/v1/vpc_access_connection.h | 4 + ...pc_access_connection_idempotency_policy.cc | 5 + ...vpc_access_connection_idempotency_policy.h | 4 + google/cloud/workflows/BUILD.bazel | 2 + .../v1/internal/workflows_auth_decorator.cc | 17 ++ .../v1/internal/workflows_auth_decorator.h | 8 + .../v1/internal/workflows_connection_impl.cc | 48 +++++ .../v1/internal/workflows_connection_impl.h | 6 + .../internal/workflows_logging_decorator.cc | 23 +++ .../v1/internal/workflows_logging_decorator.h | 8 + .../internal/workflows_metadata_decorator.cc | 17 ++ .../internal/workflows_metadata_decorator.h | 8 + .../workflows/v1/internal/workflows_stub.cc | 23 +++ .../workflows/v1/internal/workflows_stub.h | 27 ++- .../v1/internal/workflows_stub_factory.cc | 5 +- .../internal/workflows_tracing_connection.cc | 20 ++ .../internal/workflows_tracing_connection.h | 6 + .../v1/internal/workflows_tracing_stub.cc | 23 +++ .../v1/internal/workflows_tracing_stub.h | 8 + .../v1/mocks/mock_workflows_connection.h | 8 + google/cloud/workflows/v1/workflows_client.cc | 12 ++ google/cloud/workflows/v1/workflows_client.h | 70 +++++++ .../workflows/v1/workflows_connection.cc | 13 ++ .../cloud/workflows/v1/workflows_connection.h | 7 + ...workflows_connection_idempotency_policy.cc | 10 + .../workflows_connection_idempotency_policy.h | 7 + google/cloud/workstations/BUILD.bazel | 2 + .../internal/workstations_auth_decorator.cc | 25 +++ .../v1/internal/workstations_auth_decorator.h | 12 ++ .../internal/workstations_connection_impl.cc | 40 ++++ .../internal/workstations_connection_impl.h | 9 + .../workstations_logging_decorator.cc | 34 ++++ .../internal/workstations_logging_decorator.h | 12 ++ .../workstations_metadata_decorator.cc | 28 +++ .../workstations_metadata_decorator.h | 12 ++ .../v1/internal/workstations_stub.cc | 35 ++++ .../v1/internal/workstations_stub.h | 34 +++- .../v1/internal/workstations_stub_factory.cc | 4 +- .../workstations_tracing_connection.cc | 25 +++ .../workstations_tracing_connection.h | 9 + .../v1/internal/workstations_tracing_stub.cc | 34 ++++ .../v1/internal/workstations_tracing_stub.h | 12 ++ .../v1/mocks/mock_workstations_connection.h | 13 ++ .../workstations/v1/workstations_client.cc | 19 ++ .../workstations/v1/workstations_client.h | 102 +++++++++++ .../v1/workstations_connection.cc | 16 ++ .../workstations/v1/workstations_connection.h | 11 ++ ...kstations_connection_idempotency_policy.cc | 16 ++ ...rkstations_connection_idempotency_policy.h | 10 + 3377 files changed, 86717 insertions(+), 419 deletions(-) create mode 100644 google/cloud/pubsub/quickstart/MODULE.bazel diff --git a/generator/integration_tests/golden/v1/internal/golden_kitchen_sink_stub.h b/generator/integration_tests/golden/v1/internal/golden_kitchen_sink_stub.h index 2e91575dd600f..2fd0493f9f17f 100644 --- a/generator/integration_tests/golden/v1/internal/golden_kitchen_sink_stub.h +++ b/generator/integration_tests/golden/v1/internal/golden_kitchen_sink_stub.h @@ -129,7 +129,7 @@ class DefaultGoldenKitchenSinkStub : public GoldenKitchenSinkStub { public: explicit DefaultGoldenKitchenSinkStub( std::unique_ptr grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + : grpc_stub_(std::move(grpc_stub)){} StatusOr GenerateAccessToken( grpc::ClientContext& context, diff --git a/generator/integration_tests/golden/v1/internal/golden_thing_admin_stub.h b/generator/integration_tests/golden/v1/internal/golden_thing_admin_stub.h index 2a2818cf1a80e..84b82bcd9e4a9 100644 --- a/generator/integration_tests/golden/v1/internal/golden_thing_admin_stub.h +++ b/generator/integration_tests/golden/v1/internal/golden_thing_admin_stub.h @@ -189,10 +189,10 @@ class GoldenThingAdminStub { class DefaultGoldenThingAdminStub : public GoldenThingAdminStub { public: DefaultGoldenThingAdminStub( - std::unique_ptr grpc_stub, - std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), - operations_(std::move(operations)) {} + std::unique_ptr grpc_stub + ,std::unique_ptr operations) + : grpc_stub_(std::move(grpc_stub)) + , operations_(std::move(operations)) {} StatusOr ListDatabases( grpc::ClientContext& context, diff --git a/generator/integration_tests/golden/v1/internal/request_id_stub.h b/generator/integration_tests/golden/v1/internal/request_id_stub.h index 752b58dae516c..98bdcce9bf48d 100644 --- a/generator/integration_tests/golden/v1/internal/request_id_stub.h +++ b/generator/integration_tests/golden/v1/internal/request_id_stub.h @@ -82,10 +82,10 @@ class RequestIdServiceStub { class DefaultRequestIdServiceStub : public RequestIdServiceStub { public: DefaultRequestIdServiceStub( - std::unique_ptr grpc_stub, - std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), - operations_(std::move(operations)) {} + std::unique_ptr grpc_stub + ,std::unique_ptr operations) + : grpc_stub_(std::move(grpc_stub)) + , operations_(std::move(operations)) {} StatusOr CreateFoo( grpc::ClientContext& context, diff --git a/generator/internal/descriptor_utils.cc b/generator/internal/descriptor_utils.cc index 31cf5d884b0da..8f3b7d36e95a6 100644 --- a/generator/internal/descriptor_utils.cc +++ b/generator/internal/descriptor_utils.cc @@ -889,8 +889,7 @@ std::map CreateMethodVars( SetLongrunningOperationMethodVars(method, method_vars); AssignPaginationMethodVars(method, method_vars); SetMethodSignatureMethodVars(service, method, omitted_rpcs, method_vars); - auto parsed_http_info = - ParseHttpExtension(method, mixin_method.method_override); + auto parsed_http_info = ParseHttpExtension(method, mixin_method.method_override); method_vars["request_resource"] = FormatRequestResource(*method.input_type(), parsed_http_info); SetHttpDerivedMethodVars(parsed_http_info, method, method_vars); diff --git a/generator/internal/http_option_utils.cc b/generator/internal/http_option_utils.cc index 2104d2c0ddde2..6760ced6caed0 100644 --- a/generator/internal/http_option_utils.cc +++ b/generator/internal/http_option_utils.cc @@ -328,8 +328,8 @@ HttpExtensionInfo ParseHttpExtension( out->append(absl::visit(SegmentAsStringVisitor{}, s->value)); }; - auto api_version = - FormatApiVersionFromUrlPattern(url_pattern, method.file()->name()); + auto api_version_opt = FormatApiVersionFromUrlPattern(url_pattern); + auto api_version = api_version_opt.has_value() ? *api_version_opt : FormatApiVersionFromPackageName(method); auto rest_path_visitor = RestPathVisitor(api_version, info.rest_path); for (auto const& s : parsed_http_rule->segments) { @@ -403,8 +403,7 @@ std::string FormatApiVersionFromPackageName( // Generate api version by extracting the version from the url pattern. // In some cases(i.e. location), there is no version in the package name. -std::string FormatApiVersionFromUrlPattern(std::string const& url_pattern, - std::string const& file_name) { +absl::optional FormatApiVersionFromUrlPattern(std::string const& url_pattern) { std::vector parts = absl::StrSplit(url_pattern, '/'); static auto const* const kVersion = new std::regex{R"(v\d+)"}; for (auto const& part : parts) { @@ -412,9 +411,7 @@ std::string FormatApiVersionFromUrlPattern(std::string const& url_pattern, return part; } } - GCP_LOG(FATAL) << "Unrecognized API version in file: " << file_name - << ", url pattern: " << url_pattern; - return {}; // Suppress clang-tidy warnings + return absl::nullopt; // Suppress clang-tidy warnings } } // namespace generator_internal diff --git a/generator/internal/http_option_utils.h b/generator/internal/http_option_utils.h index 5117d7152a893..f345283ac21b1 100644 --- a/generator/internal/http_option_utils.h +++ b/generator/internal/http_option_utils.h @@ -118,8 +118,7 @@ std::string FormatApiVersionFromPackageName( /** * Parses the url pattern of the method and returns its API version. */ -std::string FormatApiVersionFromUrlPattern(std::string const& url_pattern, - std::string const& file_name); +absl::optional FormatApiVersionFromUrlPattern(std::string const& url_pattern); } // namespace generator_internal } // namespace cloud diff --git a/generator/internal/http_option_utils_test.cc b/generator/internal/http_option_utils_test.cc index 59edf6d8da9cc..100ccfacf3629 100644 --- a/generator/internal/http_option_utils_test.cc +++ b/generator/internal/http_option_utils_test.cc @@ -37,6 +37,7 @@ using ::testing::Eq; using ::testing::HasSubstr; using ::testing::IsEmpty; using ::testing::Pair; +using ::testing::Optional; char const* const kHttpProto = "syntax = \"proto3\";\n" @@ -773,22 +774,18 @@ TEST_F(HttpOptionUtilsTest, FormatApiVersionFromPackageNameError) { } TEST_F(HttpOptionUtilsTest, FormatApiVersionFromUrlPattern) { - std::string file_name = "google/foo/v1/service.proto"; std::string url_pattern_v1 = "/v1/foo/bar"; - EXPECT_THAT(FormatApiVersionFromUrlPattern(url_pattern_v1, file_name), - Eq("v1")); + EXPECT_THAT(FormatApiVersionFromUrlPattern(url_pattern_v1), + Optional(Eq("v1"))); std::string url_pattern_v2 = "/foo/v2/bar"; - EXPECT_THAT(FormatApiVersionFromUrlPattern(url_pattern_v2, file_name), - Eq("v2")); + EXPECT_THAT(FormatApiVersionFromUrlPattern(url_pattern_v2), + Optional(Eq("v2"))); } -TEST_F(HttpOptionUtilsTest, FormatApiVersionFromUrlPatternError) { - std::string file_name = "google/foo/v1/service.proto"; +TEST_F(HttpOptionUtilsTest, FormatApiVersionFromUrlPatternNullOptional) { std::string url_pattern = "/foo/bar"; - EXPECT_DEATH_IF_SUPPORTED( - FormatApiVersionFromUrlPattern(url_pattern, file_name), - "Unrecognized API version in file: " - "google/foo/v1/service.proto, url pattern: /foo/bar"); + EXPECT_THAT(FormatApiVersionFromUrlPattern(url_pattern), + Eq(absl::nullopt)); } } // namespace diff --git a/generator/internal/make_generators.cc b/generator/internal/make_generators.cc index f999eb3c14ba5..3aec7bca48bff 100644 --- a/generator/internal/make_generators.cc +++ b/generator/internal/make_generators.cc @@ -61,22 +61,26 @@ std::vector> MakeGenerators( YAML::Node const& service_config, std::vector> const& vars) { std::vector mixin_methods; - if (service->name() == "DataMigrationService") { - std::cout << "###########################################" - << service->name() << std::endl; + if (service->file()->name() != "google/pubsub/v1/pubsub.proto" && + service->file()->name() != "google/pubsub/v1/schema.proto") { mixin_methods = GetMixinMethods(service_config, *service); - for (auto const& mixin_method : mixin_methods) { - absl::optional body = mixin_method.method_override.http_body; + if (!mixin_methods.empty()) { + std::cout << "###########################################" + << service->full_name() << std::endl; + for (auto const& mixin_method : mixin_methods) { + absl::optional body = + mixin_method.method_override.http_body; - std::cout << mixin_method.method.get().full_name() << " " - << mixin_method.grpc_stub_fqn << " " - << mixin_method.grpc_stub_name << " " - << mixin_method.method_override.http_verb << " " - << mixin_method.method_override.http_path << " " - << (body.has_value() ? *body : "") << std::endl; - } + std::cout << mixin_method.method.get().full_name() << " " + << mixin_method.grpc_stub_fqn << " " + << mixin_method.grpc_stub_name << " " + << mixin_method.method_override.http_verb << " " + << mixin_method.method_override.http_path << " " + << (body.has_value() ? *body : "") << std::endl; + } - std::cout << "###########################################" << std::endl; + std::cout << "###########################################" << std::endl; + } } std::vector sources; std::vector> code_generators; diff --git a/generator/internal/mixin_utils.cc b/generator/internal/mixin_utils.cc index 266a457501548..900d53ffa2aba 100644 --- a/generator/internal/mixin_utils.cc +++ b/generator/internal/mixin_utils.cc @@ -8,6 +8,7 @@ #include #include #include +#include #include using ::google::protobuf::DescriptorPool; @@ -37,6 +38,7 @@ std::unordered_map GetMixinMethodOverrides( std::unordered_map mixin_method_overrides; if (service_config.Type() != YAML::NodeType::Map) return mixin_method_overrides; + if (!service_config["http"]) return mixin_method_overrides; auto const& http = service_config["http"]; if (http.Type() != YAML::NodeType::Map) return mixin_method_overrides; auto const& rules = http["rules"]; @@ -70,19 +72,14 @@ std::unordered_map GetMixinMethodOverrides( return mixin_method_overrides; } -std::unordered_map -GetDedupedMixinMethodOverrides(YAML::Node const& service_config, - ServiceDescriptor const& service) { - auto mixin_method_overrides = GetMixinMethodOverrides(service_config); +std::unordered_set GetMethodNames( + ServiceDescriptor const& service) { + std::unordered_set method_names; for (int i = 0; i < service.method_count(); ++i) { auto const* method = service.method(i); - auto method_full_name = method->full_name(); - if (mixin_method_overrides.find(method_full_name) != - mixin_method_overrides.end()) { - mixin_method_overrides.erase(method_full_name); - } + method_names.insert(method->name()); } - return mixin_method_overrides; + return method_names; } } // namespace @@ -118,9 +115,9 @@ std::vector GetMixinMethods(YAML::Node const& service_config, << " DescriptorPool doesn't exist for service: " << service.full_name(); } + std::unordered_set const method_names = GetMethodNames(service); auto mixin_proto_paths = GetMixinProtoPaths(service_config); - auto mixin_method_overrides = - GetDedupedMixinMethodOverrides(service_config, service); + auto mixin_method_overrides = GetMixinMethodOverrides(service_config); for (auto const& mixin_proto_path : mixin_proto_paths) { FileDescriptor const* mixin_file = pool->FindFileByName(mixin_proto_path); @@ -138,6 +135,11 @@ std::vector GetMixinMethods(YAML::Node const& service_config, if (mixin_method_overrides.find(mixin_method_full_name) == mixin_method_overrides.end()) continue; + + auto mixin_method_name = mixin_method->name(); + if (method_names.find(mixin_method_name) != method_names.end()) + continue; + mixin_methods.push_back( {absl::AsciiStrToLower(mixin_service->name()) + "_stub", ProtoNameToCppName(mixin_service->full_name()), *mixin_method, diff --git a/generator/internal/stub_generator.cc b/generator/internal/stub_generator.cc index fb3339df769d4..218bf2c5e86e1 100644 --- a/generator/internal/stub_generator.cc +++ b/generator/internal/stub_generator.cc @@ -249,9 +249,9 @@ Status StubGenerator::GenerateHeader() { std::string mixin_stub_members = ""; for (auto const& mixin_grpc_stub : mixin_grpc_stubs) { mixin_stub_inputs += absl::StrFormat( - " std::unique_ptr<%s::StubInterface> %s,", mixin_grpc_stub.second, mixin_grpc_stub.first); + ", std::unique_ptr<%s::StubInterface> %s", mixin_grpc_stub.second, mixin_grpc_stub.first); mixin_stub_members_init += absl::StrFormat( - " %s_(std::move(%s)),", mixin_grpc_stub.first, mixin_grpc_stub.first); + ", %s_(std::move(%s))", mixin_grpc_stub.first, mixin_grpc_stub.first); mixin_stub_members += absl::StrFormat( "std::unique_ptr<%s::StubInterface> %s_;\n", mixin_grpc_stub.second, mixin_grpc_stub.first); } @@ -260,22 +260,26 @@ Status StubGenerator::GenerateHeader() { HeaderPrint( absl::StrCat(R"""( Default$stub_class_name$( - std::unique_ptr<$grpc_stub_fqn$::StubInterface> grpc_stub,)""" + std::unique_ptr<$grpc_stub_fqn$::StubInterface> grpc_stub)""" , mixin_stub_inputs, R"""( - std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)),)""" + ,std::unique_ptr operations) + : grpc_stub_(std::move(grpc_stub)))""" , mixin_stub_members_init, R"""( - operations_(std::move(operations)) {} + , operations_(std::move(operations)) {} )""")); } else { HeaderPrint( - R"""( + absl::StrCat(R"""( explicit Default$stub_class_name$( - std::unique_ptr<$grpc_stub_fqn$::StubInterface> grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} -)"""); + std::unique_ptr<$grpc_stub_fqn$::StubInterface> grpc_stub)""" + , mixin_stub_inputs, + R"""() + : grpc_stub_(std::move(grpc_stub)))""" + , mixin_stub_members_init, + R"""({} +)""")); } HeaderPrintPublicMethods(); diff --git a/generator/standalone_main.cc b/generator/standalone_main.cc index 28e28183765be..2c1d587b3cea7 100644 --- a/generator/standalone_main.cc +++ b/generator/standalone_main.cc @@ -372,20 +372,19 @@ std::vector> GenerateCodeFromProtos( if (!path.empty()) { args.emplace_back(absl::StrCat("--cpp_codegen_opt=service_config_yaml=", std::move(path))); - if (service.service_proto_path() == - "google/cloud/clouddms/v1/clouddms.proto") { - std::vector const mixin_proto_paths = - GetMixinProtoPaths(path); - - std::cout << "-----------------------------" - << service.service_proto_path() << std::endl; - for (auto const& mixin_proto_path : mixin_proto_paths) { - std::cout << mixin_proto_path << std::endl; - args.emplace_back("--cpp_codegen_opt=additional_proto_file=" + - mixin_proto_path); - } - std::cout << "-----------------------------" << std::endl; + // if (service.service_proto_path() == + // "google/cloud/clouddms/v1/clouddms.proto") { + std::vector const mixin_proto_paths = + GetMixinProtoPaths(path); + + // std::cout << "-----------------------------" + // << service.service_proto_path() << std::endl; + for (auto const& mixin_proto_path : mixin_proto_paths) { + std::cout << mixin_proto_path << std::endl; + args.emplace_back("--cpp_codegen_opt=additional_proto_file=" + + mixin_proto_path); } + // std::cout << "-----------------------------" << std::endl; } GCP_LOG(INFO) << "Generating service code using: " diff --git a/google/cloud/aiplatform/BUILD.bazel b/google/cloud/aiplatform/BUILD.bazel index 3a32819257484..abea516fe62f6 100644 --- a/google/cloud/aiplatform/BUILD.bazel +++ b/google/cloud/aiplatform/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/aiplatform/v1:aiplatform_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/aiplatform/v1/dataset_client.cc b/google/cloud/aiplatform/v1/dataset_client.cc index 86a641759f46e..585c732865969 100644 --- a/google/cloud/aiplatform/v1/dataset_client.cc +++ b/google/cloud/aiplatform/v1/dataset_client.cc @@ -554,6 +554,38 @@ DatasetServiceClient::ListAnnotations( return connection_->ListAnnotations(std::move(request)); } +StreamRange +DatasetServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr DatasetServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr DatasetServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr DatasetServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +DatasetServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/dataset_client.h b/google/cloud/aiplatform/v1/dataset_client.h index e142a106788f5..61e2b48ae8ac6 100644 --- a/google/cloud/aiplatform/v1/dataset_client.h +++ b/google/cloud/aiplatform/v1/dataset_client.h @@ -1758,6 +1758,178 @@ class DatasetServiceClient { google::cloud::aiplatform::v1::ListAnnotationsRequest request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/dataset_connection.cc b/google/cloud/aiplatform/v1/dataset_connection.cc index d5adef9ac9627..e803d2530a11d 100644 --- a/google/cloud/aiplatform/v1/dataset_connection.cc +++ b/google/cloud/aiplatform/v1/dataset_connection.cc @@ -297,6 +297,36 @@ DatasetServiceConnection::ListAnnotations( StreamRange>(); } +StreamRange +DatasetServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DatasetServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr DatasetServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr DatasetServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +DatasetServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDatasetServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include +#include #include #include #include @@ -325,6 +327,21 @@ class DatasetServiceConnection { virtual StreamRange ListAnnotations( google::cloud::aiplatform::v1::ListAnnotationsRequest request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/dataset_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/dataset_connection_idempotency_policy.cc index cd8a493292981..6a7e12d3a5bc6 100644 --- a/google/cloud/aiplatform/v1/dataset_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/dataset_connection_idempotency_policy.cc @@ -129,6 +129,32 @@ Idempotency DatasetServiceConnectionIdempotencyPolicy::ListAnnotations( return Idempotency::kIdempotent; } +Idempotency DatasetServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DatasetServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DatasetServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency DatasetServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DatasetServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultDatasetServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/aiplatform/v1/dataset_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/dataset_connection_idempotency_policy.h index 43ac4baeac381..9bd7bcadd2c66 100644 --- a/google/cloud/aiplatform/v1/dataset_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/dataset_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -97,6 +99,21 @@ class DatasetServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListAnnotations( google::cloud::aiplatform::v1::ListAnnotationsRequest request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/aiplatform/v1/deployment_resource_pool_client.cc b/google/cloud/aiplatform/v1/deployment_resource_pool_client.cc index 16d91add94b53..40d13aa64b541 100644 --- a/google/cloud/aiplatform/v1/deployment_resource_pool_client.cc +++ b/google/cloud/aiplatform/v1/deployment_resource_pool_client.cc @@ -218,6 +218,41 @@ DeploymentResourcePoolServiceClient::DeleteDeploymentResourcePool( return connection_->DeleteDeploymentResourcePool(operation); } +StreamRange +DeploymentResourcePoolServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +DeploymentResourcePoolServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr +DeploymentResourcePoolServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr +DeploymentResourcePoolServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +DeploymentResourcePoolServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/deployment_resource_pool_client.h b/google/cloud/aiplatform/v1/deployment_resource_pool_client.h index 06504a5d98014..7fb6f334f7e9e 100644 --- a/google/cloud/aiplatform/v1/deployment_resource_pool_client.h +++ b/google/cloud/aiplatform/v1/deployment_resource_pool_client.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -605,6 +606,178 @@ class DeploymentResourcePoolServiceClient { DeleteDeploymentResourcePool(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/deployment_resource_pool_connection.cc b/google/cloud/aiplatform/v1/deployment_resource_pool_connection.cc index ff27356959af6..0001b60432c53 100644 --- a/google/cloud/aiplatform/v1/deployment_resource_pool_connection.cc +++ b/google/cloud/aiplatform/v1/deployment_resource_pool_connection.cc @@ -125,6 +125,38 @@ DeploymentResourcePoolServiceConnection::DeleteDeploymentResourcePool( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +DeploymentResourcePoolServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DeploymentResourcePoolServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +DeploymentResourcePoolServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +DeploymentResourcePoolServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +DeploymentResourcePoolServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDeploymentResourcePoolServiceConnection(std::string const& location, Options options) { diff --git a/google/cloud/aiplatform/v1/deployment_resource_pool_connection.h b/google/cloud/aiplatform/v1/deployment_resource_pool_connection.h index ce2408be23f17..debb27a442463 100644 --- a/google/cloud/aiplatform/v1/deployment_resource_pool_connection.h +++ b/google/cloud/aiplatform/v1/deployment_resource_pool_connection.h @@ -31,6 +31,8 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -259,6 +261,21 @@ class DeploymentResourcePoolServiceConnection { virtual future< StatusOr> DeleteDeploymentResourcePool(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/deployment_resource_pool_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/deployment_resource_pool_connection_idempotency_policy.cc index cc9613f29cf10..9718825832b29 100644 --- a/google/cloud/aiplatform/v1/deployment_resource_pool_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/deployment_resource_pool_connection_idempotency_policy.cc @@ -69,6 +69,37 @@ Idempotency DeploymentResourcePoolServiceConnectionIdempotencyPolicy:: return Idempotency::kNonIdempotent; } +Idempotency +DeploymentResourcePoolServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency +DeploymentResourcePoolServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +DeploymentResourcePoolServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency +DeploymentResourcePoolServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +DeploymentResourcePoolServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultDeploymentResourcePoolServiceConnectionIdempotencyPolicy() { return std::make_unique< diff --git a/google/cloud/aiplatform/v1/deployment_resource_pool_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/deployment_resource_pool_connection_idempotency_policy.h index f2d89ac97a82f..f988062c0dd60 100644 --- a/google/cloud/aiplatform/v1/deployment_resource_pool_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/deployment_resource_pool_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -57,6 +59,21 @@ class DeploymentResourcePoolServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteDeploymentResourcePool( google::cloud::aiplatform::v1::DeleteDeploymentResourcePoolRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/aiplatform/v1/endpoint_client.cc b/google/cloud/aiplatform/v1/endpoint_client.cc index 10e9988dd6f87..ff3e3c01c8165 100644 --- a/google/cloud/aiplatform/v1/endpoint_client.cc +++ b/google/cloud/aiplatform/v1/endpoint_client.cc @@ -339,6 +339,38 @@ EndpointServiceClient::MutateDeployedModel( return connection_->MutateDeployedModel(operation); } +StreamRange +EndpointServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr EndpointServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr EndpointServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr EndpointServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +EndpointServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/endpoint_client.h b/google/cloud/aiplatform/v1/endpoint_client.h index ae66197ac2056..222f54018eb68 100644 --- a/google/cloud/aiplatform/v1/endpoint_client.h +++ b/google/cloud/aiplatform/v1/endpoint_client.h @@ -1001,6 +1001,178 @@ class EndpointServiceClient { MutateDeployedModel(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/endpoint_connection.cc b/google/cloud/aiplatform/v1/endpoint_connection.cc index fb55812bc4a29..c4036d4011e73 100644 --- a/google/cloud/aiplatform/v1/endpoint_connection.cc +++ b/google/cloud/aiplatform/v1/endpoint_connection.cc @@ -172,6 +172,36 @@ EndpointServiceConnection::MutateDeployedModel( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +EndpointServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +EndpointServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr EndpointServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr EndpointServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +EndpointServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeEndpointServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include +#include #include #include #include @@ -254,6 +256,21 @@ class EndpointServiceConnection { virtual future< StatusOr> MutateDeployedModel(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/endpoint_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/endpoint_connection_idempotency_policy.cc index e1c894c34c214..4cd98f5733bad 100644 --- a/google/cloud/aiplatform/v1/endpoint_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/endpoint_connection_idempotency_policy.cc @@ -74,6 +74,32 @@ Idempotency EndpointServiceConnectionIdempotencyPolicy::MutateDeployedModel( return Idempotency::kNonIdempotent; } +Idempotency EndpointServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency EndpointServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency EndpointServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency EndpointServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency EndpointServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultEndpointServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/aiplatform/v1/endpoint_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/endpoint_connection_idempotency_policy.h index f35b7a7e222bf..ab01f6caa4cbe 100644 --- a/google/cloud/aiplatform/v1/endpoint_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/endpoint_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -60,6 +62,21 @@ class EndpointServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency MutateDeployedModel( google::cloud::aiplatform::v1::MutateDeployedModelRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/aiplatform/v1/feature_online_store_admin_client.cc b/google/cloud/aiplatform/v1/feature_online_store_admin_client.cc index 168a747d7eba1..561df2ddbb1fe 100644 --- a/google/cloud/aiplatform/v1/feature_online_store_admin_client.cc +++ b/google/cloud/aiplatform/v1/feature_online_store_admin_client.cc @@ -443,6 +443,41 @@ FeatureOnlineStoreAdminServiceClient::ListFeatureViewSyncs( return connection_->ListFeatureViewSyncs(std::move(request)); } +StreamRange +FeatureOnlineStoreAdminServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +FeatureOnlineStoreAdminServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr +FeatureOnlineStoreAdminServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr +FeatureOnlineStoreAdminServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +FeatureOnlineStoreAdminServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/feature_online_store_admin_client.h b/google/cloud/aiplatform/v1/feature_online_store_admin_client.h index a81a20f24f377..ac4f35c01f78e 100644 --- a/google/cloud/aiplatform/v1/feature_online_store_admin_client.h +++ b/google/cloud/aiplatform/v1/feature_online_store_admin_client.h @@ -1336,6 +1336,178 @@ class FeatureOnlineStoreAdminServiceClient { google::cloud::aiplatform::v1::ListFeatureViewSyncsRequest request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/feature_online_store_admin_connection.cc b/google/cloud/aiplatform/v1/feature_online_store_admin_connection.cc index 70f5f5e1db467..50abc9f417cd0 100644 --- a/google/cloud/aiplatform/v1/feature_online_store_admin_connection.cc +++ b/google/cloud/aiplatform/v1/feature_online_store_admin_connection.cc @@ -231,6 +231,38 @@ FeatureOnlineStoreAdminServiceConnection::ListFeatureViewSyncs( StreamRange>(); } +StreamRange +FeatureOnlineStoreAdminServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +FeatureOnlineStoreAdminServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +FeatureOnlineStoreAdminServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +FeatureOnlineStoreAdminServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +FeatureOnlineStoreAdminServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeFeatureOnlineStoreAdminServiceConnection(std::string const& location, Options options) { diff --git a/google/cloud/aiplatform/v1/feature_online_store_admin_connection.h b/google/cloud/aiplatform/v1/feature_online_store_admin_connection.h index 11a56d7e8c0bd..4d7b31f561b34 100644 --- a/google/cloud/aiplatform/v1/feature_online_store_admin_connection.h +++ b/google/cloud/aiplatform/v1/feature_online_store_admin_connection.h @@ -31,6 +31,8 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -308,6 +310,21 @@ class FeatureOnlineStoreAdminServiceConnection { virtual StreamRange ListFeatureViewSyncs( google::cloud::aiplatform::v1::ListFeatureViewSyncsRequest request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/feature_online_store_admin_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/feature_online_store_admin_connection_idempotency_policy.cc index 09ffe1bf98ac8..517f99e9a9c03 100644 --- a/google/cloud/aiplatform/v1/feature_online_store_admin_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/feature_online_store_admin_connection_idempotency_policy.cc @@ -113,6 +113,37 @@ FeatureOnlineStoreAdminServiceConnectionIdempotencyPolicy::ListFeatureViewSyncs( return Idempotency::kIdempotent; } +Idempotency +FeatureOnlineStoreAdminServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency +FeatureOnlineStoreAdminServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +FeatureOnlineStoreAdminServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency +FeatureOnlineStoreAdminServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +FeatureOnlineStoreAdminServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultFeatureOnlineStoreAdminServiceConnectionIdempotencyPolicy() { return std::make_unique< diff --git a/google/cloud/aiplatform/v1/feature_online_store_admin_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/feature_online_store_admin_connection_idempotency_policy.h index ff9b5fc4f3cd0..edabc15bc17aa 100644 --- a/google/cloud/aiplatform/v1/feature_online_store_admin_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/feature_online_store_admin_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -80,6 +82,21 @@ class FeatureOnlineStoreAdminServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListFeatureViewSyncs( google::cloud::aiplatform::v1::ListFeatureViewSyncsRequest request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/aiplatform/v1/feature_online_store_client.cc b/google/cloud/aiplatform/v1/feature_online_store_client.cc index 1ce2f6c63fc0e..56bcedab1680b 100644 --- a/google/cloud/aiplatform/v1/feature_online_store_client.cc +++ b/google/cloud/aiplatform/v1/feature_online_store_client.cc @@ -61,6 +61,39 @@ FeatureOnlineStoreServiceClient::SearchNearestEntities( return connection_->SearchNearestEntities(request); } +StreamRange +FeatureOnlineStoreServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +FeatureOnlineStoreServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr FeatureOnlineStoreServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr FeatureOnlineStoreServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +FeatureOnlineStoreServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/feature_online_store_client.h b/google/cloud/aiplatform/v1/feature_online_store_client.h index 2384fe43eef2b..fa53b7b21002f 100644 --- a/google/cloud/aiplatform/v1/feature_online_store_client.h +++ b/google/cloud/aiplatform/v1/feature_online_store_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -186,6 +187,178 @@ class FeatureOnlineStoreServiceClient { request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/feature_online_store_connection.cc b/google/cloud/aiplatform/v1/feature_online_store_connection.cc index 84d633c20600b..6c70f4c434146 100644 --- a/google/cloud/aiplatform/v1/feature_online_store_connection.cc +++ b/google/cloud/aiplatform/v1/feature_online_store_connection.cc @@ -26,6 +26,7 @@ #include "google/cloud/common_options.h" #include "google/cloud/credentials.h" #include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/unified_grpc_credentials.h" #include #include @@ -50,6 +51,38 @@ FeatureOnlineStoreServiceConnection::SearchNearestEntities( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +FeatureOnlineStoreServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +FeatureOnlineStoreServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +FeatureOnlineStoreServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +FeatureOnlineStoreServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +FeatureOnlineStoreServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeFeatureOnlineStoreServiceConnection(std::string const& location, Options options) { diff --git a/google/cloud/aiplatform/v1/feature_online_store_connection.h b/google/cloud/aiplatform/v1/feature_online_store_connection.h index 7c88e5ccbdf87..a4e4a31b0e1e8 100644 --- a/google/cloud/aiplatform/v1/feature_online_store_connection.h +++ b/google/cloud/aiplatform/v1/feature_online_store_connection.h @@ -25,8 +25,11 @@ #include "google/cloud/internal/retry_policy_impl.h" #include "google/cloud/options.h" #include "google/cloud/status_or.h" +#include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -204,6 +207,21 @@ class FeatureOnlineStoreServiceConnection { SearchNearestEntities( google::cloud::aiplatform::v1::SearchNearestEntitiesRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/feature_online_store_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/feature_online_store_connection_idempotency_policy.cc index deadba54b36fe..c49d6da8ce617 100644 --- a/google/cloud/aiplatform/v1/feature_online_store_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/feature_online_store_connection_idempotency_policy.cc @@ -47,6 +47,33 @@ FeatureOnlineStoreServiceConnectionIdempotencyPolicy::SearchNearestEntities( return Idempotency::kNonIdempotent; } +Idempotency FeatureOnlineStoreServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency FeatureOnlineStoreServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency FeatureOnlineStoreServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency FeatureOnlineStoreServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +FeatureOnlineStoreServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultFeatureOnlineStoreServiceConnectionIdempotencyPolicy() { return std::make_unique< diff --git a/google/cloud/aiplatform/v1/feature_online_store_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/feature_online_store_connection_idempotency_policy.h index f117c36817eb7..95ae0243009f0 100644 --- a/google/cloud/aiplatform/v1/feature_online_store_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/feature_online_store_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -43,6 +45,21 @@ class FeatureOnlineStoreServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency SearchNearestEntities( google::cloud::aiplatform::v1::SearchNearestEntitiesRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/aiplatform/v1/feature_registry_client.cc b/google/cloud/aiplatform/v1/feature_registry_client.cc index b35b8423bd459..e5381c547a87f 100644 --- a/google/cloud/aiplatform/v1/feature_registry_client.cc +++ b/google/cloud/aiplatform/v1/feature_registry_client.cc @@ -379,6 +379,39 @@ FeatureRegistryServiceClient::DeleteFeature( return connection_->DeleteFeature(operation); } +StreamRange +FeatureRegistryServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +FeatureRegistryServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr FeatureRegistryServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr FeatureRegistryServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +FeatureRegistryServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/feature_registry_client.h b/google/cloud/aiplatform/v1/feature_registry_client.h index 5a801d2d019ce..a3ee8d99113ab 100644 --- a/google/cloud/aiplatform/v1/feature_registry_client.h +++ b/google/cloud/aiplatform/v1/feature_registry_client.h @@ -1121,6 +1121,178 @@ class FeatureRegistryServiceClient { DeleteFeature(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/feature_registry_connection.cc b/google/cloud/aiplatform/v1/feature_registry_connection.cc index 9901a08e1ac5f..981db39dbfcbc 100644 --- a/google/cloud/aiplatform/v1/feature_registry_connection.cc +++ b/google/cloud/aiplatform/v1/feature_registry_connection.cc @@ -207,6 +207,38 @@ FeatureRegistryServiceConnection::DeleteFeature( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +FeatureRegistryServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +FeatureRegistryServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +FeatureRegistryServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +FeatureRegistryServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +FeatureRegistryServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeFeatureRegistryServiceConnection(std::string const& location, Options options) { diff --git a/google/cloud/aiplatform/v1/feature_registry_connection.h b/google/cloud/aiplatform/v1/feature_registry_connection.h index 415ef29d6f811..a198d7792355b 100644 --- a/google/cloud/aiplatform/v1/feature_registry_connection.h +++ b/google/cloud/aiplatform/v1/feature_registry_connection.h @@ -31,6 +31,8 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -275,6 +277,21 @@ class FeatureRegistryServiceConnection { virtual future< StatusOr> DeleteFeature(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/feature_registry_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/feature_registry_connection_idempotency_policy.cc index 14c9ec0e2ffe4..e2dae75aa2171 100644 --- a/google/cloud/aiplatform/v1/feature_registry_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/feature_registry_connection_idempotency_policy.cc @@ -89,6 +89,33 @@ Idempotency FeatureRegistryServiceConnectionIdempotencyPolicy::DeleteFeature( return Idempotency::kNonIdempotent; } +Idempotency FeatureRegistryServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency FeatureRegistryServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency FeatureRegistryServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency FeatureRegistryServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +FeatureRegistryServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultFeatureRegistryServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/aiplatform/v1/feature_registry_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/feature_registry_connection_idempotency_policy.h index 6ad8a94c867b7..81611c2be347b 100644 --- a/google/cloud/aiplatform/v1/feature_registry_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/feature_registry_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -66,6 +68,21 @@ class FeatureRegistryServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteFeature( google::cloud::aiplatform::v1::DeleteFeatureRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/aiplatform/v1/featurestore_client.cc b/google/cloud/aiplatform/v1/featurestore_client.cc index 8b31e8dfa7252..422348bce37aa 100644 --- a/google/cloud/aiplatform/v1/featurestore_client.cc +++ b/google/cloud/aiplatform/v1/featurestore_client.cc @@ -853,6 +853,39 @@ FeaturestoreServiceClient::SearchFeatures( return connection_->SearchFeatures(std::move(request)); } +StreamRange +FeaturestoreServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +FeaturestoreServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr FeaturestoreServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr FeaturestoreServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +FeaturestoreServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/featurestore_client.h b/google/cloud/aiplatform/v1/featurestore_client.h index d6dbb15c23cb0..1ec21907899ab 100644 --- a/google/cloud/aiplatform/v1/featurestore_client.h +++ b/google/cloud/aiplatform/v1/featurestore_client.h @@ -2561,6 +2561,178 @@ class FeaturestoreServiceClient { google::cloud::aiplatform::v1::SearchFeaturesRequest request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/featurestore_connection.cc b/google/cloud/aiplatform/v1/featurestore_connection.cc index 0321074bbff87..0f156f79be9b2 100644 --- a/google/cloud/aiplatform/v1/featurestore_connection.cc +++ b/google/cloud/aiplatform/v1/featurestore_connection.cc @@ -384,6 +384,36 @@ FeaturestoreServiceConnection::SearchFeatures( StreamRange>(); } +StreamRange +FeaturestoreServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +FeaturestoreServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr FeaturestoreServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr FeaturestoreServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +FeaturestoreServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeFeaturestoreServiceConnection(std::string const& location, Options options) { diff --git a/google/cloud/aiplatform/v1/featurestore_connection.h b/google/cloud/aiplatform/v1/featurestore_connection.h index e8752aa8be836..c1ddc7c6f7aed 100644 --- a/google/cloud/aiplatform/v1/featurestore_connection.h +++ b/google/cloud/aiplatform/v1/featurestore_connection.h @@ -31,6 +31,8 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -368,6 +370,21 @@ class FeaturestoreServiceConnection { virtual StreamRange SearchFeatures( google::cloud::aiplatform::v1::SearchFeaturesRequest request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/featurestore_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/featurestore_connection_idempotency_policy.cc index 5e7faa42e4ef0..66f5719d4f4a5 100644 --- a/google/cloud/aiplatform/v1/featurestore_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/featurestore_connection_idempotency_policy.cc @@ -141,6 +141,32 @@ Idempotency FeaturestoreServiceConnectionIdempotencyPolicy::SearchFeatures( return Idempotency::kIdempotent; } +Idempotency FeaturestoreServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency FeaturestoreServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency FeaturestoreServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency FeaturestoreServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency FeaturestoreServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultFeaturestoreServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/aiplatform/v1/featurestore_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/featurestore_connection_idempotency_policy.h index f1bc70291f96d..56ffb0a417fc2 100644 --- a/google/cloud/aiplatform/v1/featurestore_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/featurestore_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -100,6 +102,21 @@ class FeaturestoreServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency SearchFeatures( google::cloud::aiplatform::v1::SearchFeaturesRequest request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/aiplatform/v1/featurestore_online_serving_client.cc b/google/cloud/aiplatform/v1/featurestore_online_serving_client.cc index 0f3ad7a1dd628..d9860e159d91e 100644 --- a/google/cloud/aiplatform/v1/featurestore_online_serving_client.cc +++ b/google/cloud/aiplatform/v1/featurestore_online_serving_client.cc @@ -90,6 +90,41 @@ FeaturestoreOnlineServingServiceClient::WriteFeatureValues( return connection_->WriteFeatureValues(request); } +StreamRange +FeaturestoreOnlineServingServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +FeaturestoreOnlineServingServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr +FeaturestoreOnlineServingServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr +FeaturestoreOnlineServingServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +FeaturestoreOnlineServingServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/featurestore_online_serving_client.h b/google/cloud/aiplatform/v1/featurestore_online_serving_client.h index 2e56fd7d7e1e3..5972576d3dc4c 100644 --- a/google/cloud/aiplatform/v1/featurestore_online_serving_client.h +++ b/google/cloud/aiplatform/v1/featurestore_online_serving_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -299,6 +300,178 @@ class FeaturestoreOnlineServingServiceClient { google::cloud::aiplatform::v1::WriteFeatureValuesRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/featurestore_online_serving_connection.cc b/google/cloud/aiplatform/v1/featurestore_online_serving_connection.cc index 08e3e417113cc..78a9ff8d91037 100644 --- a/google/cloud/aiplatform/v1/featurestore_online_serving_connection.cc +++ b/google/cloud/aiplatform/v1/featurestore_online_serving_connection.cc @@ -26,6 +26,7 @@ #include "google/cloud/common_options.h" #include "google/cloud/credentials.h" #include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/unified_grpc_credentials.h" #include #include @@ -62,6 +63,38 @@ FeaturestoreOnlineServingServiceConnection::WriteFeatureValues( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +FeaturestoreOnlineServingServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +FeaturestoreOnlineServingServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +FeaturestoreOnlineServingServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +FeaturestoreOnlineServingServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +FeaturestoreOnlineServingServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeFeaturestoreOnlineServingServiceConnection(std::string const& location, Options options) { diff --git a/google/cloud/aiplatform/v1/featurestore_online_serving_connection.h b/google/cloud/aiplatform/v1/featurestore_online_serving_connection.h index 4df76e75a827b..aaa2d7533bde0 100644 --- a/google/cloud/aiplatform/v1/featurestore_online_serving_connection.h +++ b/google/cloud/aiplatform/v1/featurestore_online_serving_connection.h @@ -28,6 +28,8 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -215,6 +217,21 @@ class FeaturestoreOnlineServingServiceConnection { virtual StatusOr WriteFeatureValues( google::cloud::aiplatform::v1::WriteFeatureValuesRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/featurestore_online_serving_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/featurestore_online_serving_connection_idempotency_policy.cc index 1b34845f90b94..d417e611975dc 100644 --- a/google/cloud/aiplatform/v1/featurestore_online_serving_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/featurestore_online_serving_connection_idempotency_policy.cc @@ -47,6 +47,37 @@ FeaturestoreOnlineServingServiceConnectionIdempotencyPolicy::WriteFeatureValues( return Idempotency::kNonIdempotent; } +Idempotency +FeaturestoreOnlineServingServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency +FeaturestoreOnlineServingServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +FeaturestoreOnlineServingServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency +FeaturestoreOnlineServingServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +FeaturestoreOnlineServingServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultFeaturestoreOnlineServingServiceConnectionIdempotencyPolicy() { return std::make_unique< diff --git a/google/cloud/aiplatform/v1/featurestore_online_serving_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/featurestore_online_serving_connection_idempotency_policy.h index a16777824fd42..fe4879246186a 100644 --- a/google/cloud/aiplatform/v1/featurestore_online_serving_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/featurestore_online_serving_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -43,6 +45,21 @@ class FeaturestoreOnlineServingServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency WriteFeatureValues( google::cloud::aiplatform::v1::WriteFeatureValuesRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/aiplatform/v1/gen_ai_tuning_client.cc b/google/cloud/aiplatform/v1/gen_ai_tuning_client.cc index 11cd62c7cde32..bdfb3f30acbe3 100644 --- a/google/cloud/aiplatform/v1/gen_ai_tuning_client.cc +++ b/google/cloud/aiplatform/v1/gen_ai_tuning_client.cc @@ -99,6 +99,39 @@ Status GenAiTuningServiceClient::CancelTuningJob( return connection_->CancelTuningJob(request); } +StreamRange +GenAiTuningServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +GenAiTuningServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr GenAiTuningServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr GenAiTuningServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +GenAiTuningServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/gen_ai_tuning_client.h b/google/cloud/aiplatform/v1/gen_ai_tuning_client.h index eb55058d8393d..252dfd5efcad3 100644 --- a/google/cloud/aiplatform/v1/gen_ai_tuning_client.h +++ b/google/cloud/aiplatform/v1/gen_ai_tuning_client.h @@ -362,6 +362,178 @@ class GenAiTuningServiceClient { google::cloud::aiplatform::v1::CancelTuningJobRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/gen_ai_tuning_connection.cc b/google/cloud/aiplatform/v1/gen_ai_tuning_connection.cc index 84c7a0141e6e9..a5846a6ba43e3 100644 --- a/google/cloud/aiplatform/v1/gen_ai_tuning_connection.cc +++ b/google/cloud/aiplatform/v1/gen_ai_tuning_connection.cc @@ -63,6 +63,36 @@ Status GenAiTuningServiceConnection::CancelTuningJob( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +GenAiTuningServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +GenAiTuningServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr GenAiTuningServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr GenAiTuningServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +GenAiTuningServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeGenAiTuningServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include +#include #include #include @@ -197,6 +199,21 @@ class GenAiTuningServiceConnection { virtual Status CancelTuningJob( google::cloud::aiplatform::v1::CancelTuningJobRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/gen_ai_tuning_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/gen_ai_tuning_connection_idempotency_policy.cc index 89ce7eb5de2e1..b67fa08f25387 100644 --- a/google/cloud/aiplatform/v1/gen_ai_tuning_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/gen_ai_tuning_connection_idempotency_policy.cc @@ -54,6 +54,32 @@ Idempotency GenAiTuningServiceConnectionIdempotencyPolicy::CancelTuningJob( return Idempotency::kNonIdempotent; } +Idempotency GenAiTuningServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency GenAiTuningServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency GenAiTuningServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency GenAiTuningServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency GenAiTuningServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultGenAiTuningServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/aiplatform/v1/gen_ai_tuning_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/gen_ai_tuning_connection_idempotency_policy.h index b5f02ff6b527a..86c1d24f0b4d0 100644 --- a/google/cloud/aiplatform/v1/gen_ai_tuning_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/gen_ai_tuning_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -48,6 +50,21 @@ class GenAiTuningServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency CancelTuningJob( google::cloud::aiplatform::v1::CancelTuningJobRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/aiplatform/v1/index_client.cc b/google/cloud/aiplatform/v1/index_client.cc index 636ca3973e027..45ef50a093d43 100644 --- a/google/cloud/aiplatform/v1/index_client.cc +++ b/google/cloud/aiplatform/v1/index_client.cc @@ -205,6 +205,38 @@ IndexServiceClient::RemoveDatapoints( return connection_->RemoveDatapoints(request); } +StreamRange +IndexServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr IndexServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr IndexServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr IndexServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +IndexServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/index_client.h b/google/cloud/aiplatform/v1/index_client.h index 77aaf10793429..c2c4caef258cb 100644 --- a/google/cloud/aiplatform/v1/index_client.h +++ b/google/cloud/aiplatform/v1/index_client.h @@ -643,6 +643,178 @@ class IndexServiceClient { google::cloud::aiplatform::v1::RemoveDatapointsRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/index_connection.cc b/google/cloud/aiplatform/v1/index_connection.cc index be7e1230aa975..0236737e7d6d5 100644 --- a/google/cloud/aiplatform/v1/index_connection.cc +++ b/google/cloud/aiplatform/v1/index_connection.cc @@ -126,6 +126,35 @@ IndexServiceConnection::RemoveDatapoints( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +IndexServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr IndexServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr IndexServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr IndexServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +IndexServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeIndexServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include +#include #include #include #include @@ -232,6 +234,21 @@ class IndexServiceConnection { virtual StatusOr RemoveDatapoints( google::cloud::aiplatform::v1::RemoveDatapointsRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/index_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/index_connection_idempotency_policy.cc index fd2fedbe2c0df..1c472e30a0757 100644 --- a/google/cloud/aiplatform/v1/index_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/index_connection_idempotency_policy.cc @@ -69,6 +69,32 @@ Idempotency IndexServiceConnectionIdempotencyPolicy::RemoveDatapoints( return Idempotency::kNonIdempotent; } +Idempotency IndexServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency IndexServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency IndexServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency IndexServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency IndexServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultIndexServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/aiplatform/v1/index_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/index_connection_idempotency_policy.h index 97e1b1309fa7a..e24d898466dbb 100644 --- a/google/cloud/aiplatform/v1/index_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/index_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -57,6 +59,21 @@ class IndexServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency RemoveDatapoints( google::cloud::aiplatform::v1::RemoveDatapointsRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/aiplatform/v1/index_endpoint_client.cc b/google/cloud/aiplatform/v1/index_endpoint_client.cc index 34ea6d4a8a48b..d8177c1d03753 100644 --- a/google/cloud/aiplatform/v1/index_endpoint_client.cc +++ b/google/cloud/aiplatform/v1/index_endpoint_client.cc @@ -319,6 +319,39 @@ IndexEndpointServiceClient::MutateDeployedIndex( return connection_->MutateDeployedIndex(operation); } +StreamRange +IndexEndpointServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +IndexEndpointServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr IndexEndpointServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr IndexEndpointServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +IndexEndpointServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/index_endpoint_client.h b/google/cloud/aiplatform/v1/index_endpoint_client.h index 012e73c808ffa..6af49f655ded0 100644 --- a/google/cloud/aiplatform/v1/index_endpoint_client.h +++ b/google/cloud/aiplatform/v1/index_endpoint_client.h @@ -891,6 +891,178 @@ class IndexEndpointServiceClient { MutateDeployedIndex(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/index_endpoint_connection.cc b/google/cloud/aiplatform/v1/index_endpoint_connection.cc index 8dc5eda1595e7..9f143136ae087 100644 --- a/google/cloud/aiplatform/v1/index_endpoint_connection.cc +++ b/google/cloud/aiplatform/v1/index_endpoint_connection.cc @@ -176,6 +176,36 @@ IndexEndpointServiceConnection::MutateDeployedIndex( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +IndexEndpointServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +IndexEndpointServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr IndexEndpointServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr IndexEndpointServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +IndexEndpointServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeIndexEndpointServiceConnection(std::string const& location, Options options) { diff --git a/google/cloud/aiplatform/v1/index_endpoint_connection.h b/google/cloud/aiplatform/v1/index_endpoint_connection.h index 89f24f1f53240..a6c73cb15d816 100644 --- a/google/cloud/aiplatform/v1/index_endpoint_connection.h +++ b/google/cloud/aiplatform/v1/index_endpoint_connection.h @@ -31,6 +31,8 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -260,6 +262,21 @@ class IndexEndpointServiceConnection { virtual future< StatusOr> MutateDeployedIndex(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/index_endpoint_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/index_endpoint_connection_idempotency_policy.cc index f8c952838d629..3111c23fe84ad 100644 --- a/google/cloud/aiplatform/v1/index_endpoint_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/index_endpoint_connection_idempotency_policy.cc @@ -79,6 +79,32 @@ IndexEndpointServiceConnectionIdempotencyPolicy::MutateDeployedIndex( return Idempotency::kNonIdempotent; } +Idempotency IndexEndpointServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency IndexEndpointServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency IndexEndpointServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency IndexEndpointServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency IndexEndpointServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultIndexEndpointServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/aiplatform/v1/index_endpoint_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/index_endpoint_connection_idempotency_policy.h index d44f222932bf5..9f08e23bc1e94 100644 --- a/google/cloud/aiplatform/v1/index_endpoint_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/index_endpoint_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -60,6 +62,21 @@ class IndexEndpointServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency MutateDeployedIndex( google::cloud::aiplatform::v1::MutateDeployedIndexRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/aiplatform/v1/internal/dataset_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/dataset_auth_decorator.cc index 28c3ea02bfc32..82c2035606232 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/dataset_auth_decorator.cc @@ -358,6 +358,48 @@ DatasetServiceAuth::ListAnnotations( return child_->ListAnnotations(context, options, request); } +StatusOr +DatasetServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr DatasetServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr DatasetServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr DatasetServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +DatasetServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> DatasetServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/dataset_auth_decorator.h b/google/cloud/aiplatform/v1/internal/dataset_auth_decorator.h index 8616d3057920a..8619d64a4f3ea 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/dataset_auth_decorator.h @@ -186,6 +186,26 @@ class DatasetServiceAuth : public DatasetServiceStub { google::cloud::aiplatform::v1::ListAnnotationsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/dataset_connection_impl.cc b/google/cloud/aiplatform/v1/internal/dataset_connection_impl.cc index 8a7e31d87953c..30aa76c127f99 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/dataset_connection_impl.cc @@ -1092,6 +1092,94 @@ DatasetServiceConnectionImpl::ListAnnotations( }); } +StreamRange +DatasetServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DatasetServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr DatasetServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr DatasetServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +DatasetServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/dataset_connection_impl.h b/google/cloud/aiplatform/v1/internal/dataset_connection_impl.h index 51498c7753021..3ab7730ba8e0d 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/dataset_connection_impl.h @@ -190,6 +190,21 @@ class DatasetServiceConnectionImpl StreamRange ListAnnotations( google::cloud::aiplatform::v1::ListAnnotationsRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/aiplatform/v1/internal/dataset_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/dataset_logging_decorator.cc index a9304f8ccdfd0..289ff4911aead 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/dataset_logging_decorator.cc @@ -427,6 +427,63 @@ DatasetServiceLogging::ListAnnotations( context, options, request, __func__, tracing_options_); } +StatusOr +DatasetServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DatasetServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DatasetServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DatasetServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DatasetServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> DatasetServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/dataset_logging_decorator.h b/google/cloud/aiplatform/v1/internal/dataset_logging_decorator.h index 94dbc20b32db0..d9409c179887e 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/dataset_logging_decorator.h @@ -186,6 +186,26 @@ class DatasetServiceLogging : public DatasetServiceStub { google::cloud::aiplatform::v1::ListAnnotationsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/dataset_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/dataset_metadata_decorator.cc index 16483bb6d9d53..f329a658ea6cc 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/dataset_metadata_decorator.cc @@ -312,6 +312,51 @@ DatasetServiceMetadata::ListAnnotations( return child_->ListAnnotations(context, options, request); } +StatusOr +DatasetServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr DatasetServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr DatasetServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr DatasetServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +DatasetServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> DatasetServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/dataset_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/dataset_metadata_decorator.h index 753a4436cf519..26561d7e867f3 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/dataset_metadata_decorator.h @@ -186,6 +186,26 @@ class DatasetServiceMetadata : public DatasetServiceStub { google::cloud::aiplatform::v1::ListAnnotationsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/dataset_stub.cc b/google/cloud/aiplatform/v1/internal/dataset_stub.cc index 077a68b09bafd..46948449565d6 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_stub.cc +++ b/google/cloud/aiplatform/v1/internal/dataset_stub.cc @@ -407,6 +407,65 @@ DefaultDatasetServiceStub::ListAnnotations( return response; } +StatusOr +DefaultDatasetServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDatasetServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultDatasetServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultDatasetServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDatasetServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultDatasetServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/dataset_stub.h b/google/cloud/aiplatform/v1/internal/dataset_stub.h index 70de73918f46d..f523e03dc7744 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_stub.h +++ b/google/cloud/aiplatform/v1/internal/dataset_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -187,6 +191,28 @@ class DatasetServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::aiplatform::v1::ListAnnotationsRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -206,9 +232,15 @@ class DefaultDatasetServiceStub : public DatasetServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::DatasetService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateDataset( google::cloud::CompletionQueue& cq, @@ -357,6 +389,26 @@ class DefaultDatasetServiceStub : public DatasetServiceStub { google::cloud::aiplatform::v1::ListAnnotationsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -372,6 +424,9 @@ class DefaultDatasetServiceStub : public DatasetServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/aiplatform/v1/internal/dataset_stub_factory.cc b/google/cloud/aiplatform/v1/internal/dataset_stub_factory.cc index 652c90413cef4..027fd383b9215 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/dataset_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultDatasetServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::DatasetService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/aiplatform/v1/internal/dataset_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/dataset_tracing_connection.cc index d43db3eb30989..4cf49e3e9d9f4 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/dataset_tracing_connection.cc @@ -385,6 +385,51 @@ DatasetServiceTracingConnection::ListAnnotations( std::move(sr)); } +StreamRange +DatasetServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::DatasetServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DatasetServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::DatasetServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr DatasetServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::DatasetServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr DatasetServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::DatasetServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +DatasetServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::DatasetServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/dataset_tracing_connection.h b/google/cloud/aiplatform/v1/internal/dataset_tracing_connection.h index 98a27b08cd1c3..5e9e9d8dea772 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/dataset_tracing_connection.h @@ -178,6 +178,21 @@ class DatasetServiceTracingConnection StreamRange ListAnnotations( google::cloud::aiplatform::v1::ListAnnotationsRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/aiplatform/v1/internal/dataset_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/dataset_tracing_stub.cc index 6b408d4f96f4f..12d2cdd551faf 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/dataset_tracing_stub.cc @@ -376,6 +376,64 @@ DatasetServiceTracingStub::ListAnnotations( child_->ListAnnotations(context, options, request)); } +StatusOr +DatasetServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.DatasetService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +DatasetServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.DatasetService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr DatasetServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.DatasetService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr DatasetServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.DatasetService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +DatasetServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.DatasetService", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> DatasetServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/dataset_tracing_stub.h b/google/cloud/aiplatform/v1/internal/dataset_tracing_stub.h index 4b539c625b4ed..847ab427f5660 100644 --- a/google/cloud/aiplatform/v1/internal/dataset_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/dataset_tracing_stub.h @@ -185,6 +185,26 @@ class DatasetServiceTracingStub : public DatasetServiceStub { google::cloud::aiplatform::v1::ListAnnotationsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_auth_decorator.cc index 75d010c846d96..b117d264d49de 100644 --- a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_auth_decorator.cc @@ -144,6 +144,51 @@ DeploymentResourcePoolServiceAuth::DeleteDeploymentResourcePool( return child_->DeleteDeploymentResourcePool(context, options, request); } +StatusOr +DeploymentResourcePoolServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +DeploymentResourcePoolServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr +DeploymentResourcePoolServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr +DeploymentResourcePoolServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +DeploymentResourcePoolServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> DeploymentResourcePoolServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_auth_decorator.h b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_auth_decorator.h index ab4ec26efbe51..1571947a6c630 100644 --- a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_auth_decorator.h @@ -91,6 +91,26 @@ class DeploymentResourcePoolServiceAuth google::cloud::aiplatform::v1::DeleteDeploymentResourcePoolRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_connection_impl.cc b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_connection_impl.cc index 47d158c84825e..7abbb4c1f7d91 100644 --- a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_connection_impl.cc @@ -416,6 +416,97 @@ DeploymentResourcePoolServiceConnectionImpl::DeleteDeploymentResourcePool( polling_policy(*current), __func__); } +StreamRange +DeploymentResourcePoolServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr< + aiplatform_v1::DeploymentResourcePoolServiceRetryPolicy>( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DeploymentResourcePoolServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +DeploymentResourcePoolServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +DeploymentResourcePoolServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +DeploymentResourcePoolServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_connection_impl.h b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_connection_impl.h index d59884dcef861..24911e5a8c0bc 100644 --- a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_connection_impl.h @@ -105,6 +105,21 @@ class DeploymentResourcePoolServiceConnectionImpl DeleteDeploymentResourcePool( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_logging_decorator.cc index e1bd81283b54a..b5eeabc429ebe 100644 --- a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_logging_decorator.cc @@ -166,6 +166,66 @@ DeploymentResourcePoolServiceLogging::DeleteDeploymentResourcePool( context, options, request, __func__, tracing_options_); } +StatusOr +DeploymentResourcePoolServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DeploymentResourcePoolServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DeploymentResourcePoolServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DeploymentResourcePoolServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DeploymentResourcePoolServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> DeploymentResourcePoolServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_logging_decorator.h b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_logging_decorator.h index 3a723f3ee16ef..184bb31dde4fb 100644 --- a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_logging_decorator.h @@ -91,6 +91,26 @@ class DeploymentResourcePoolServiceLogging google::cloud::aiplatform::v1::DeleteDeploymentResourcePoolRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_metadata_decorator.cc index d6e638aabb548..8a1e5a6a8aea8 100644 --- a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_metadata_decorator.cc @@ -137,6 +137,54 @@ DeploymentResourcePoolServiceMetadata::DeleteDeploymentResourcePool( return child_->DeleteDeploymentResourcePool(context, options, request); } +StatusOr +DeploymentResourcePoolServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +DeploymentResourcePoolServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr +DeploymentResourcePoolServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr +DeploymentResourcePoolServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +DeploymentResourcePoolServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> DeploymentResourcePoolServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_metadata_decorator.h index 626cbee48e27f..de221c27e5e90 100644 --- a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_metadata_decorator.h @@ -92,6 +92,26 @@ class DeploymentResourcePoolServiceMetadata google::cloud::aiplatform::v1::DeleteDeploymentResourcePoolRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_stub.cc b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_stub.cc index 885da8984ccc0..a8ada38bb0e3e 100644 --- a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_stub.cc +++ b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_stub.cc @@ -165,6 +165,67 @@ DefaultDeploymentResourcePoolServiceStub::DeleteDeploymentResourcePool( return response; } +StatusOr +DefaultDeploymentResourcePoolServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDeploymentResourcePoolServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDeploymentResourcePoolServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDeploymentResourcePoolServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDeploymentResourcePoolServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultDeploymentResourcePoolServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_stub.h b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_stub.h index ac795c3f0bac4..71499db7fce02 100644 --- a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_stub.h +++ b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -90,6 +94,28 @@ class DeploymentResourcePoolServiceStub { google::cloud::aiplatform::v1::DeleteDeploymentResourcePoolRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -110,9 +136,15 @@ class DefaultDeploymentResourcePoolServiceStub std::unique_ptr grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateDeploymentResourcePool( @@ -165,6 +197,26 @@ class DefaultDeploymentResourcePoolServiceStub google::cloud::aiplatform::v1::DeleteDeploymentResourcePoolRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -181,6 +233,9 @@ class DefaultDeploymentResourcePoolServiceStub std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_stub_factory.cc b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_stub_factory.cc index 1b8d6fb8965a2..ac624c0d25549 100644 --- a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -46,9 +48,13 @@ CreateDefaultDeploymentResourcePoolServiceStub( auto service_grpc_stub = google::cloud::aiplatform::v1::DeploymentResourcePoolService::NewStub( channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_tracing_connection.cc index 25397cbaa4b67..78287bcf1acca 100644 --- a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_tracing_connection.cc @@ -167,6 +167,54 @@ DeploymentResourcePoolServiceTracingConnection::DeleteDeploymentResourcePool( child_->DeleteDeploymentResourcePool(operation)); } +StreamRange +DeploymentResourcePoolServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::DeploymentResourcePoolServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DeploymentResourcePoolServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::DeploymentResourcePoolServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +DeploymentResourcePoolServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::DeploymentResourcePoolServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +DeploymentResourcePoolServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::DeploymentResourcePoolServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +DeploymentResourcePoolServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::DeploymentResourcePoolServiceConnection::" + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_tracing_connection.h b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_tracing_connection.h index 6a858cd102bb7..2b40c79dea784 100644 --- a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_tracing_connection.h @@ -93,6 +93,21 @@ class DeploymentResourcePoolServiceTracingConnection DeleteDeploymentResourcePool( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; diff --git a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_tracing_stub.cc index 083caabe5e9cb..8076cc19e8b59 100644 --- a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_tracing_stub.cc @@ -159,6 +159,71 @@ DeploymentResourcePoolServiceTracingStub::DeleteDeploymentResourcePool( child_->DeleteDeploymentResourcePool(context, options, request)); } +StatusOr +DeploymentResourcePoolServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.DeploymentResourcePoolService", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +DeploymentResourcePoolServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.DeploymentResourcePoolService", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr +DeploymentResourcePoolServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.DeploymentResourcePoolService", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr +DeploymentResourcePoolServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.DeploymentResourcePoolService", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +DeploymentResourcePoolServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.DeploymentResourcePoolService", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> DeploymentResourcePoolServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_tracing_stub.h b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_tracing_stub.h index 7512b76b0e1d4..c85addf550688 100644 --- a/google/cloud/aiplatform/v1/internal/deployment_resource_pool_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/deployment_resource_pool_tracing_stub.h @@ -91,6 +91,26 @@ class DeploymentResourcePoolServiceTracingStub google::cloud::aiplatform::v1::DeleteDeploymentResourcePoolRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/endpoint_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/endpoint_auth_decorator.cc index 2764927087657..cdbbd2f554c03 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/endpoint_auth_decorator.cc @@ -199,6 +199,48 @@ EndpointServiceAuth::MutateDeployedModel( return child_->MutateDeployedModel(context, options, request); } +StatusOr +EndpointServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr EndpointServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr EndpointServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr EndpointServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +EndpointServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> EndpointServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/endpoint_auth_decorator.h b/google/cloud/aiplatform/v1/internal/endpoint_auth_decorator.h index 17956b8f1304e..8feb98437678f 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/endpoint_auth_decorator.h @@ -114,6 +114,26 @@ class EndpointServiceAuth : public EndpointServiceStub { google::cloud::aiplatform::v1::MutateDeployedModelRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/endpoint_connection_impl.cc b/google/cloud/aiplatform/v1/internal/endpoint_connection_impl.cc index 350cd28c181d1..00fa2a8a1dd8e 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/endpoint_connection_impl.cc @@ -594,6 +594,94 @@ EndpointServiceConnectionImpl::MutateDeployedModel( polling_policy(*current), __func__); } +StreamRange +EndpointServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +EndpointServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr EndpointServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr EndpointServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +EndpointServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/endpoint_connection_impl.h b/google/cloud/aiplatform/v1/internal/endpoint_connection_impl.h index 35b2564cbbe7d..277ceac3da3ff 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/endpoint_connection_impl.h @@ -124,6 +124,21 @@ class EndpointServiceConnectionImpl future> MutateDeployedModel(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/aiplatform/v1/internal/endpoint_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/endpoint_logging_decorator.cc index b65c3e84f0f12..8224dbeafa709 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/endpoint_logging_decorator.cc @@ -227,6 +227,63 @@ EndpointServiceLogging::MutateDeployedModel( context, options, request, __func__, tracing_options_); } +StatusOr +EndpointServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EndpointServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EndpointServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EndpointServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +EndpointServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> EndpointServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/endpoint_logging_decorator.h b/google/cloud/aiplatform/v1/internal/endpoint_logging_decorator.h index 6f83b60a5b81a..50de68bdd5ae8 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/endpoint_logging_decorator.h @@ -114,6 +114,26 @@ class EndpointServiceLogging : public EndpointServiceStub { google::cloud::aiplatform::v1::MutateDeployedModelRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/endpoint_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/endpoint_metadata_decorator.cc index 2300bb6dbeba7..cc6e97db24384 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/endpoint_metadata_decorator.cc @@ -181,6 +181,52 @@ EndpointServiceMetadata::MutateDeployedModel( return child_->MutateDeployedModel(context, options, request); } +StatusOr +EndpointServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +EndpointServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr EndpointServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr EndpointServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +EndpointServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> EndpointServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/endpoint_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/endpoint_metadata_decorator.h index 1acc2ee09d995..624fa7eb447d2 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/endpoint_metadata_decorator.h @@ -115,6 +115,26 @@ class EndpointServiceMetadata : public EndpointServiceStub { google::cloud::aiplatform::v1::MutateDeployedModelRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/endpoint_stub.cc b/google/cloud/aiplatform/v1/internal/endpoint_stub.cc index 29497c1612284..b3eb18f4f0d49 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_stub.cc +++ b/google/cloud/aiplatform/v1/internal/endpoint_stub.cc @@ -220,6 +220,65 @@ DefaultEndpointServiceStub::MutateDeployedModel( return response; } +StatusOr +DefaultEndpointServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultEndpointServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultEndpointServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultEndpointServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultEndpointServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultEndpointServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/endpoint_stub.h b/google/cloud/aiplatform/v1/internal/endpoint_stub.h index 9414714e221e5..0fb61b73afea0 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_stub.h +++ b/google/cloud/aiplatform/v1/internal/endpoint_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -104,6 +108,28 @@ class EndpointServiceStub { google::cloud::aiplatform::v1::MutateDeployedModelRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -123,9 +149,15 @@ class DefaultEndpointServiceStub : public EndpointServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::EndpointService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateEndpoint( google::cloud::CompletionQueue& cq, @@ -202,6 +234,26 @@ class DefaultEndpointServiceStub : public EndpointServiceStub { google::cloud::aiplatform::v1::MutateDeployedModelRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -217,6 +269,9 @@ class DefaultEndpointServiceStub : public EndpointServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/aiplatform/v1/internal/endpoint_stub_factory.cc b/google/cloud/aiplatform/v1/internal/endpoint_stub_factory.cc index 01324f91ce3bd..0a15b2ee204e3 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/endpoint_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultEndpointServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::EndpointService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/aiplatform/v1/internal/endpoint_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/endpoint_tracing_connection.cc index 989b85aab32e3..ff810f9d026d1 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/endpoint_tracing_connection.cc @@ -207,6 +207,53 @@ EndpointServiceTracingConnection::MutateDeployedModel( child_->MutateDeployedModel(operation)); } +StreamRange +EndpointServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::EndpointServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +EndpointServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::EndpointServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +EndpointServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::EndpointServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +EndpointServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::EndpointServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +EndpointServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::EndpointServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/endpoint_tracing_connection.h b/google/cloud/aiplatform/v1/internal/endpoint_tracing_connection.h index 475a974a30138..40e17b2b843b8 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/endpoint_tracing_connection.h @@ -112,6 +112,21 @@ class EndpointServiceTracingConnection future> MutateDeployedModel(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/aiplatform/v1/internal/endpoint_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/endpoint_tracing_stub.cc index 1f0dd4980ad59..befaac55792e4 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/endpoint_tracing_stub.cc @@ -201,6 +201,64 @@ EndpointServiceTracingStub::MutateDeployedModel( context, *span, child_->MutateDeployedModel(context, options, request)); } +StatusOr +EndpointServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.EndpointService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +EndpointServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.EndpointService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr EndpointServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.EndpointService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr EndpointServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.EndpointService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +EndpointServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.EndpointService", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> EndpointServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/endpoint_tracing_stub.h b/google/cloud/aiplatform/v1/internal/endpoint_tracing_stub.h index 5d8d5478e092c..0fd240c1b7b83 100644 --- a/google/cloud/aiplatform/v1/internal/endpoint_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/endpoint_tracing_stub.h @@ -114,6 +114,26 @@ class EndpointServiceTracingStub : public EndpointServiceStub { google::cloud::aiplatform::v1::MutateDeployedModelRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_auth_decorator.cc index c0421a05459c5..3f3aa8a6e378d 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_auth_decorator.cc @@ -276,6 +276,51 @@ FeatureOnlineStoreAdminServiceAuth::ListFeatureViewSyncs( return child_->ListFeatureViewSyncs(context, options, request); } +StatusOr +FeatureOnlineStoreAdminServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +FeatureOnlineStoreAdminServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr +FeatureOnlineStoreAdminServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr +FeatureOnlineStoreAdminServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +FeatureOnlineStoreAdminServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> FeatureOnlineStoreAdminServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_auth_decorator.h b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_auth_decorator.h index d6280b1305cb5..1f585afc1ce99 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_auth_decorator.h @@ -153,6 +153,26 @@ class FeatureOnlineStoreAdminServiceAuth google::cloud::aiplatform::v1::ListFeatureViewSyncsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_connection_impl.cc b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_connection_impl.cc index 5451119e8a33e..cf192f98d869c 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_connection_impl.cc @@ -819,6 +819,97 @@ FeatureOnlineStoreAdminServiceConnectionImpl::ListFeatureViewSyncs( }); } +StreamRange +FeatureOnlineStoreAdminServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr< + aiplatform_v1::FeatureOnlineStoreAdminServiceRetryPolicy>( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +FeatureOnlineStoreAdminServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +FeatureOnlineStoreAdminServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +FeatureOnlineStoreAdminServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +FeatureOnlineStoreAdminServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_connection_impl.h b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_connection_impl.h index 19140233ef4f7..4a0d13dfa5a10 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_connection_impl.h @@ -165,6 +165,21 @@ class FeatureOnlineStoreAdminServiceConnectionImpl google::cloud::aiplatform::v1::ListFeatureViewSyncsRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_logging_decorator.cc index 23c8380ad3653..b91d98e913d27 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_logging_decorator.cc @@ -333,6 +333,66 @@ FeatureOnlineStoreAdminServiceLogging::ListFeatureViewSyncs( context, options, request, __func__, tracing_options_); } +StatusOr +FeatureOnlineStoreAdminServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeatureOnlineStoreAdminServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeatureOnlineStoreAdminServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeatureOnlineStoreAdminServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeatureOnlineStoreAdminServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> FeatureOnlineStoreAdminServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_logging_decorator.h b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_logging_decorator.h index 83cbff762c0fd..c5d66a6502e71 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_logging_decorator.h @@ -153,6 +153,26 @@ class FeatureOnlineStoreAdminServiceLogging google::cloud::aiplatform::v1::ListFeatureViewSyncsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_metadata_decorator.cc index 8f83ac43d124a..13e0838854f4b 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_metadata_decorator.cc @@ -248,6 +248,54 @@ FeatureOnlineStoreAdminServiceMetadata::ListFeatureViewSyncs( return child_->ListFeatureViewSyncs(context, options, request); } +StatusOr +FeatureOnlineStoreAdminServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +FeatureOnlineStoreAdminServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr +FeatureOnlineStoreAdminServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr +FeatureOnlineStoreAdminServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +FeatureOnlineStoreAdminServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> FeatureOnlineStoreAdminServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_metadata_decorator.h index 053505ad50f61..884c377301e2a 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_metadata_decorator.h @@ -154,6 +154,26 @@ class FeatureOnlineStoreAdminServiceMetadata google::cloud::aiplatform::v1::ListFeatureViewSyncsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_stub.cc b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_stub.cc index 4e4a688bea047..da5ccbe33461b 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_stub.cc +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_stub.cc @@ -317,6 +317,67 @@ DefaultFeatureOnlineStoreAdminServiceStub::ListFeatureViewSyncs( return response; } +StatusOr +DefaultFeatureOnlineStoreAdminServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFeatureOnlineStoreAdminServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFeatureOnlineStoreAdminServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFeatureOnlineStoreAdminServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFeatureOnlineStoreAdminServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultFeatureOnlineStoreAdminServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_stub.h b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_stub.h index ef72ac3be0a70..f5aae747d16fa 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_stub.h +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -155,6 +159,28 @@ class FeatureOnlineStoreAdminServiceStub { google::cloud::aiplatform::v1::ListFeatureViewSyncsRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -175,9 +201,15 @@ class DefaultFeatureOnlineStoreAdminServiceStub std::unique_ptr grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateFeatureOnlineStore( @@ -292,6 +324,26 @@ class DefaultFeatureOnlineStoreAdminServiceStub google::cloud::aiplatform::v1::ListFeatureViewSyncsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -308,6 +360,9 @@ class DefaultFeatureOnlineStoreAdminServiceStub std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_stub_factory.cc b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_stub_factory.cc index 404fe679e33fa..17514569a557c 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -46,9 +48,13 @@ CreateDefaultFeatureOnlineStoreAdminServiceStub( auto service_grpc_stub = google::cloud::aiplatform::v1::FeatureOnlineStoreAdminService::NewStub( channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_tracing_connection.cc index 5314ce97a8e7e..cde65b5635ccb 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_tracing_connection.cc @@ -322,6 +322,54 @@ FeatureOnlineStoreAdminServiceTracingConnection::ListFeatureViewSyncs( std::move(sr)); } +StreamRange +FeatureOnlineStoreAdminServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureOnlineStoreAdminServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +FeatureOnlineStoreAdminServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureOnlineStoreAdminServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +FeatureOnlineStoreAdminServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureOnlineStoreAdminServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +FeatureOnlineStoreAdminServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureOnlineStoreAdminServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +FeatureOnlineStoreAdminServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureOnlineStoreAdminServiceConnection::" + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_tracing_connection.h b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_tracing_connection.h index c329fa120e8fb..a6f9a6157293a 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_tracing_connection.h @@ -152,6 +152,21 @@ class FeatureOnlineStoreAdminServiceTracingConnection google::cloud::aiplatform::v1::ListFeatureViewSyncsRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_tracing_stub.cc index 6fdab063f72b0..a97ff348f30f2 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_tracing_stub.cc @@ -310,6 +310,71 @@ FeatureOnlineStoreAdminServiceTracingStub::ListFeatureViewSyncs( context, *span, child_->ListFeatureViewSyncs(context, options, request)); } +StatusOr +FeatureOnlineStoreAdminServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureOnlineStoreAdminService", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +FeatureOnlineStoreAdminServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureOnlineStoreAdminService", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr +FeatureOnlineStoreAdminServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureOnlineStoreAdminService", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr +FeatureOnlineStoreAdminServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureOnlineStoreAdminService", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +FeatureOnlineStoreAdminServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureOnlineStoreAdminService", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> FeatureOnlineStoreAdminServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_tracing_stub.h b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_tracing_stub.h index c1b5085ebc1f9..57a0f4a7d3eac 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_admin_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_admin_tracing_stub.h @@ -153,6 +153,26 @@ class FeatureOnlineStoreAdminServiceTracingStub google::cloud::aiplatform::v1::ListFeatureViewSyncsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/feature_online_store_auth_decorator.cc index 38381705a8b12..ab16f605a5ef4 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_auth_decorator.cc @@ -50,6 +50,49 @@ FeatureOnlineStoreServiceAuth::SearchNearestEntities( return child_->SearchNearestEntities(context, options, request); } +StatusOr +FeatureOnlineStoreServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +FeatureOnlineStoreServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr FeatureOnlineStoreServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr FeatureOnlineStoreServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +FeatureOnlineStoreServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_auth_decorator.h b/google/cloud/aiplatform/v1/internal/feature_online_store_auth_decorator.h index 4326e9dce33b6..2c3858e096c7a 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_auth_decorator.h @@ -50,6 +50,26 @@ class FeatureOnlineStoreServiceAuth : public FeatureOnlineStoreServiceStub { google::cloud::aiplatform::v1::SearchNearestEntitiesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_connection_impl.cc b/google/cloud/aiplatform/v1/internal/feature_online_store_connection_impl.cc index d235fcc5bd0ed..ab1394994b2e2 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_connection_impl.cc @@ -21,6 +21,7 @@ #include "google/cloud/background_threads.h" #include "google/cloud/common_options.h" #include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/retry_loop.h" #include #include @@ -98,6 +99,97 @@ FeatureOnlineStoreServiceConnectionImpl::SearchNearestEntities( *current, request, __func__); } +StreamRange +FeatureOnlineStoreServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = + std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +FeatureOnlineStoreServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +FeatureOnlineStoreServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +FeatureOnlineStoreServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +FeatureOnlineStoreServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_connection_impl.h b/google/cloud/aiplatform/v1/internal/feature_online_store_connection_impl.h index b7b1e57261379..b3cfbef149e75 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_connection_impl.h @@ -28,6 +28,7 @@ #include "google/cloud/backoff_policy.h" #include "google/cloud/options.h" #include "google/cloud/status_or.h" +#include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include @@ -59,6 +60,21 @@ class FeatureOnlineStoreServiceConnectionImpl google::cloud::aiplatform::v1::SearchNearestEntitiesRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/feature_online_store_logging_decorator.cc index c4a5685a787a5..3cb58943234fd 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_logging_decorator.cc @@ -62,6 +62,66 @@ FeatureOnlineStoreServiceLogging::SearchNearestEntities( context, options, request, __func__, tracing_options_); } +StatusOr +FeatureOnlineStoreServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeatureOnlineStoreServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeatureOnlineStoreServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeatureOnlineStoreServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeatureOnlineStoreServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_logging_decorator.h b/google/cloud/aiplatform/v1/internal/feature_online_store_logging_decorator.h index b87beee84abf9..7b6f8249f9d93 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_logging_decorator.h @@ -50,6 +50,26 @@ class FeatureOnlineStoreServiceLogging : public FeatureOnlineStoreServiceStub { google::cloud::aiplatform::v1::SearchNearestEntitiesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/feature_online_store_metadata_decorator.cc index 11e3ac2136db5..90777c763fb12 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_metadata_decorator.cc @@ -65,6 +65,54 @@ FeatureOnlineStoreServiceMetadata::SearchNearestEntities( return child_->SearchNearestEntities(context, options, request); } +StatusOr +FeatureOnlineStoreServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +FeatureOnlineStoreServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr +FeatureOnlineStoreServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr +FeatureOnlineStoreServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +FeatureOnlineStoreServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + void FeatureOnlineStoreServiceMetadata::SetMetadata( grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/feature_online_store_metadata_decorator.h index fae3219501ac2..cf7723135e560 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_metadata_decorator.h @@ -51,6 +51,26 @@ class FeatureOnlineStoreServiceMetadata : public FeatureOnlineStoreServiceStub { google::cloud::aiplatform::v1::SearchNearestEntitiesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_stub.cc b/google/cloud/aiplatform/v1/internal/feature_online_store_stub.cc index 37c12a80d1d01..99edfe2001685 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_stub.cc +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_stub.cc @@ -55,6 +55,67 @@ DefaultFeatureOnlineStoreServiceStub::SearchNearestEntities( return response; } +StatusOr +DefaultFeatureOnlineStoreServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFeatureOnlineStoreServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFeatureOnlineStoreServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFeatureOnlineStoreServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFeatureOnlineStoreServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_stub.h b/google/cloud/aiplatform/v1/internal/feature_online_store_stub.h index f95f1e749acbd..b3728392fe2a4 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_stub.h +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_stub.h @@ -23,6 +23,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include @@ -46,6 +50,28 @@ class FeatureOnlineStoreServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::aiplatform::v1::SearchNearestEntitiesRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; }; class DefaultFeatureOnlineStoreServiceStub @@ -54,8 +80,13 @@ class DefaultFeatureOnlineStoreServiceStub explicit DefaultFeatureOnlineStoreServiceStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr FetchFeatureValues( @@ -69,10 +100,33 @@ class DefaultFeatureOnlineStoreServiceStub google::cloud::aiplatform::v1::SearchNearestEntitiesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr< google::cloud::aiplatform::v1::FeatureOnlineStoreService::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_stub_factory.cc b/google/cloud/aiplatform/v1/internal/feature_online_store_stub_factory.cc index 00ff9d3018c16..c8d53fcc70229 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -46,9 +48,13 @@ CreateDefaultFeatureOnlineStoreServiceStub( auto service_grpc_stub = google::cloud::aiplatform::v1::FeatureOnlineStoreService::NewStub( channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/feature_online_store_tracing_connection.cc index 85d5adade96ba..146426f608650 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/aiplatform/v1/internal/feature_online_store_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -54,6 +55,53 @@ FeatureOnlineStoreServiceTracingConnection::SearchNearestEntities( return internal::EndSpan(*span, child_->SearchNearestEntities(request)); } +StreamRange +FeatureOnlineStoreServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureOnlineStoreServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +FeatureOnlineStoreServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureOnlineStoreServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +FeatureOnlineStoreServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureOnlineStoreServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +FeatureOnlineStoreServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureOnlineStoreServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +FeatureOnlineStoreServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureOnlineStoreServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_tracing_connection.h b/google/cloud/aiplatform/v1/internal/feature_online_store_tracing_connection.h index 85d76e2d16e7f..61d0662b19079 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_tracing_connection.h @@ -51,6 +51,21 @@ class FeatureOnlineStoreServiceTracingConnection google::cloud::aiplatform::v1::SearchNearestEntitiesRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/feature_online_store_tracing_stub.cc index 8106f14b61702..4a9d22083e1a5 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_tracing_stub.cc @@ -59,6 +59,67 @@ FeatureOnlineStoreServiceTracingStub::SearchNearestEntities( context, *span, child_->SearchNearestEntities(context, options, request)); } +StatusOr +FeatureOnlineStoreServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureOnlineStoreService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +FeatureOnlineStoreServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureOnlineStoreService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr +FeatureOnlineStoreServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureOnlineStoreService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr +FeatureOnlineStoreServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureOnlineStoreService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +FeatureOnlineStoreServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureOnlineStoreService", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/feature_online_store_tracing_stub.h b/google/cloud/aiplatform/v1/internal/feature_online_store_tracing_stub.h index b2be47cf877a9..db1ace75fe898 100644 --- a/google/cloud/aiplatform/v1/internal/feature_online_store_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/feature_online_store_tracing_stub.h @@ -52,6 +52,26 @@ class FeatureOnlineStoreServiceTracingStub google::cloud::aiplatform::v1::SearchNearestEntitiesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/feature_registry_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/feature_registry_auth_decorator.cc index 9b832e3268c3f..194ca27c57ea7 100644 --- a/google/cloud/aiplatform/v1/internal/feature_registry_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/feature_registry_auth_decorator.cc @@ -241,6 +241,49 @@ FeatureRegistryServiceAuth::DeleteFeature( return child_->DeleteFeature(context, options, request); } +StatusOr +FeatureRegistryServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +FeatureRegistryServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr FeatureRegistryServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr FeatureRegistryServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +FeatureRegistryServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> FeatureRegistryServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/feature_registry_auth_decorator.h b/google/cloud/aiplatform/v1/internal/feature_registry_auth_decorator.h index 4a59472d12c15..58acc613a7686 100644 --- a/google/cloud/aiplatform/v1/internal/feature_registry_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/feature_registry_auth_decorator.h @@ -131,6 +131,26 @@ class FeatureRegistryServiceAuth : public FeatureRegistryServiceStub { google::cloud::aiplatform::v1::DeleteFeatureRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/feature_registry_connection_impl.cc b/google/cloud/aiplatform/v1/internal/feature_registry_connection_impl.cc index 041b87df2b9fd..846612946732e 100644 --- a/google/cloud/aiplatform/v1/internal/feature_registry_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/feature_registry_connection_impl.cc @@ -730,6 +730,97 @@ FeatureRegistryServiceConnectionImpl::DeleteFeature( polling_policy(*current), __func__); } +StreamRange +FeatureRegistryServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = + std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +FeatureRegistryServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +FeatureRegistryServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +FeatureRegistryServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +FeatureRegistryServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/feature_registry_connection_impl.h b/google/cloud/aiplatform/v1/internal/feature_registry_connection_impl.h index 7c317e7468c50..bcdff83d5bb91 100644 --- a/google/cloud/aiplatform/v1/internal/feature_registry_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/feature_registry_connection_impl.h @@ -140,6 +140,21 @@ class FeatureRegistryServiceConnectionImpl future> DeleteFeature(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/aiplatform/v1/internal/feature_registry_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/feature_registry_logging_decorator.cc index 6c4317200a3e2..008689fcd225c 100644 --- a/google/cloud/aiplatform/v1/internal/feature_registry_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/feature_registry_logging_decorator.cc @@ -278,6 +278,64 @@ FeatureRegistryServiceLogging::DeleteFeature( context, options, request, __func__, tracing_options_); } +StatusOr +FeatureRegistryServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeatureRegistryServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr FeatureRegistryServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr FeatureRegistryServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeatureRegistryServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> FeatureRegistryServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/feature_registry_logging_decorator.h b/google/cloud/aiplatform/v1/internal/feature_registry_logging_decorator.h index aa9905d6a3b91..90b5ae1fab39b 100644 --- a/google/cloud/aiplatform/v1/internal/feature_registry_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/feature_registry_logging_decorator.h @@ -131,6 +131,26 @@ class FeatureRegistryServiceLogging : public FeatureRegistryServiceStub { google::cloud::aiplatform::v1::DeleteFeatureRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/feature_registry_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/feature_registry_metadata_decorator.cc index 147ad2f6f4f21..b1454cb064044 100644 --- a/google/cloud/aiplatform/v1/internal/feature_registry_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/feature_registry_metadata_decorator.cc @@ -212,6 +212,52 @@ FeatureRegistryServiceMetadata::DeleteFeature( return child_->DeleteFeature(context, options, request); } +StatusOr +FeatureRegistryServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +FeatureRegistryServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr FeatureRegistryServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr FeatureRegistryServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +FeatureRegistryServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> FeatureRegistryServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/feature_registry_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/feature_registry_metadata_decorator.h index defde8ab6d51a..5269020a41df3 100644 --- a/google/cloud/aiplatform/v1/internal/feature_registry_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/feature_registry_metadata_decorator.h @@ -132,6 +132,26 @@ class FeatureRegistryServiceMetadata : public FeatureRegistryServiceStub { google::cloud::aiplatform::v1::DeleteFeatureRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/feature_registry_stub.cc b/google/cloud/aiplatform/v1/internal/feature_registry_stub.cc index a458fbc42511b..5340c952c2d4f 100644 --- a/google/cloud/aiplatform/v1/internal/feature_registry_stub.cc +++ b/google/cloud/aiplatform/v1/internal/feature_registry_stub.cc @@ -262,6 +262,67 @@ DefaultFeatureRegistryServiceStub::DeleteFeature( return response; } +StatusOr +DefaultFeatureRegistryServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFeatureRegistryServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFeatureRegistryServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFeatureRegistryServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFeatureRegistryServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultFeatureRegistryServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/feature_registry_stub.h b/google/cloud/aiplatform/v1/internal/feature_registry_stub.h index cc486bbdf1093..96e6e0aac692d 100644 --- a/google/cloud/aiplatform/v1/internal/feature_registry_stub.h +++ b/google/cloud/aiplatform/v1/internal/feature_registry_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -126,6 +130,28 @@ class FeatureRegistryServiceStub { grpc::ClientContext& context, Options options, google::cloud::aiplatform::v1::DeleteFeatureRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -145,9 +171,15 @@ class DefaultFeatureRegistryServiceStub : public FeatureRegistryServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::FeatureRegistryService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateFeatureGroup( google::cloud::CompletionQueue& cq, @@ -241,6 +273,26 @@ class DefaultFeatureRegistryServiceStub : public FeatureRegistryServiceStub { google::cloud::aiplatform::v1::DeleteFeatureRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -257,6 +309,9 @@ class DefaultFeatureRegistryServiceStub : public FeatureRegistryServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::FeatureRegistryService::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/aiplatform/v1/internal/feature_registry_stub_factory.cc b/google/cloud/aiplatform/v1/internal/feature_registry_stub_factory.cc index da77b11134a46..a1d044af33143 100644 --- a/google/cloud/aiplatform/v1/internal/feature_registry_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/feature_registry_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -45,9 +47,13 @@ CreateDefaultFeatureRegistryServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::FeatureRegistryService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/aiplatform/v1/internal/feature_registry_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/feature_registry_tracing_connection.cc index 3522d02b8f0aa..fd6d637456bb6 100644 --- a/google/cloud/aiplatform/v1/internal/feature_registry_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/feature_registry_tracing_connection.cc @@ -252,6 +252,53 @@ FeatureRegistryServiceTracingConnection::DeleteFeature( return internal::EndSpan(std::move(span), child_->DeleteFeature(operation)); } +StreamRange +FeatureRegistryServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureRegistryServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +FeatureRegistryServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureRegistryServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +FeatureRegistryServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureRegistryServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +FeatureRegistryServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureRegistryServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +FeatureRegistryServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeatureRegistryServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/feature_registry_tracing_connection.h b/google/cloud/aiplatform/v1/internal/feature_registry_tracing_connection.h index 2a6e980d9cc21..208ff65554524 100644 --- a/google/cloud/aiplatform/v1/internal/feature_registry_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/feature_registry_tracing_connection.h @@ -128,6 +128,21 @@ class FeatureRegistryServiceTracingConnection future> DeleteFeature(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/aiplatform/v1/internal/feature_registry_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/feature_registry_tracing_stub.cc index 256a4bd1a5ad8..db33761419676 100644 --- a/google/cloud/aiplatform/v1/internal/feature_registry_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/feature_registry_tracing_stub.cc @@ -245,6 +245,67 @@ FeatureRegistryServiceTracingStub::DeleteFeature( child_->DeleteFeature(context, options, request)); } +StatusOr +FeatureRegistryServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureRegistryService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +FeatureRegistryServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureRegistryService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr +FeatureRegistryServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureRegistryService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr +FeatureRegistryServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureRegistryService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +FeatureRegistryServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeatureRegistryService", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> FeatureRegistryServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/feature_registry_tracing_stub.h b/google/cloud/aiplatform/v1/internal/feature_registry_tracing_stub.h index 49d49f1e436ae..d302af7d97988 100644 --- a/google/cloud/aiplatform/v1/internal/feature_registry_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/feature_registry_tracing_stub.h @@ -131,6 +131,26 @@ class FeatureRegistryServiceTracingStub : public FeatureRegistryServiceStub { google::cloud::aiplatform::v1::DeleteFeatureRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/featurestore_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/featurestore_auth_decorator.cc index cf60367b3da84..fb8dfb73bde53 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/featurestore_auth_decorator.cc @@ -460,6 +460,49 @@ FeaturestoreServiceAuth::SearchFeatures( return child_->SearchFeatures(context, options, request); } +StatusOr +FeaturestoreServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +FeaturestoreServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr FeaturestoreServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr FeaturestoreServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +FeaturestoreServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> FeaturestoreServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/featurestore_auth_decorator.h b/google/cloud/aiplatform/v1/internal/featurestore_auth_decorator.h index 2cd83f3ca7764..f857a641806a9 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/featurestore_auth_decorator.h @@ -228,6 +228,26 @@ class FeaturestoreServiceAuth : public FeaturestoreServiceStub { google::cloud::aiplatform::v1::SearchFeaturesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/featurestore_connection_impl.cc b/google/cloud/aiplatform/v1/internal/featurestore_connection_impl.cc index e0b336798819b..b2fd39fc6e8a2 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/featurestore_connection_impl.cc @@ -1406,6 +1406,96 @@ FeaturestoreServiceConnectionImpl::SearchFeatures( }); } +StreamRange +FeaturestoreServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +FeaturestoreServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +FeaturestoreServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +FeaturestoreServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +FeaturestoreServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/featurestore_connection_impl.h b/google/cloud/aiplatform/v1/internal/featurestore_connection_impl.h index a3e4e296c5327..afd5cdd47c56b 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/featurestore_connection_impl.h @@ -238,6 +238,21 @@ class FeaturestoreServiceConnectionImpl StreamRange SearchFeatures( google::cloud::aiplatform::v1::SearchFeaturesRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/aiplatform/v1/internal/featurestore_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/featurestore_logging_decorator.cc index 1740876f877f8..f36348062541c 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/featurestore_logging_decorator.cc @@ -537,6 +537,64 @@ FeaturestoreServiceLogging::SearchFeatures( context, options, request, __func__, tracing_options_); } +StatusOr +FeaturestoreServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeaturestoreServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr FeaturestoreServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr FeaturestoreServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeaturestoreServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> FeaturestoreServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/featurestore_logging_decorator.h b/google/cloud/aiplatform/v1/internal/featurestore_logging_decorator.h index bec25c01689ae..71ecef4ca3fcf 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/featurestore_logging_decorator.h @@ -228,6 +228,26 @@ class FeaturestoreServiceLogging : public FeaturestoreServiceStub { google::cloud::aiplatform::v1::SearchFeaturesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/featurestore_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/featurestore_metadata_decorator.cc index a6f719f12c124..8611bb9af7b4c 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/featurestore_metadata_decorator.cc @@ -392,6 +392,52 @@ FeaturestoreServiceMetadata::SearchFeatures( return child_->SearchFeatures(context, options, request); } +StatusOr +FeaturestoreServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +FeaturestoreServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr FeaturestoreServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr FeaturestoreServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +FeaturestoreServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> FeaturestoreServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/featurestore_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/featurestore_metadata_decorator.h index 3e0f96cd626e0..5daf34671c57e 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/featurestore_metadata_decorator.h @@ -229,6 +229,26 @@ class FeaturestoreServiceMetadata : public FeaturestoreServiceStub { google::cloud::aiplatform::v1::SearchFeaturesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_auth_decorator.cc index 2a009d661efed..e0baee60d0a48 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_auth_decorator.cc @@ -63,6 +63,51 @@ FeaturestoreOnlineServingServiceAuth::WriteFeatureValues( return child_->WriteFeatureValues(context, options, request); } +StatusOr +FeaturestoreOnlineServingServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +FeaturestoreOnlineServingServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr +FeaturestoreOnlineServingServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr +FeaturestoreOnlineServingServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +FeaturestoreOnlineServingServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_auth_decorator.h b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_auth_decorator.h index bad2e68d482d4..5c5e7bebc95e4 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_auth_decorator.h @@ -58,6 +58,26 @@ class FeaturestoreOnlineServingServiceAuth google::cloud::aiplatform::v1::WriteFeatureValuesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_connection_impl.cc b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_connection_impl.cc index 7add720692d79..289e517d5ace0 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_connection_impl.cc @@ -21,6 +21,7 @@ #include "google/cloud/background_threads.h" #include "google/cloud/common_options.h" #include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/resumable_streaming_read_rpc.h" #include "google/cloud/internal/retry_loop.h" #include "google/cloud/internal/streaming_read_rpc_logging.h" @@ -128,6 +129,97 @@ FeaturestoreOnlineServingServiceConnectionImpl::WriteFeatureValues( *current, request, __func__); } +StreamRange +FeaturestoreOnlineServingServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr< + aiplatform_v1::FeaturestoreOnlineServingServiceRetryPolicy>( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +FeaturestoreOnlineServingServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +FeaturestoreOnlineServingServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +FeaturestoreOnlineServingServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +FeaturestoreOnlineServingServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_connection_impl.h b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_connection_impl.h index 8f0d5f45838bf..d18cd701f681d 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_connection_impl.h @@ -70,6 +70,21 @@ class FeaturestoreOnlineServingServiceConnectionImpl google::cloud::aiplatform::v1::WriteFeatureValuesRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_logging_decorator.cc index 1e9a9f2699525..8d467c85cda63 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_logging_decorator.cc @@ -92,6 +92,66 @@ FeaturestoreOnlineServingServiceLogging::WriteFeatureValues( context, options, request, __func__, tracing_options_); } +StatusOr +FeaturestoreOnlineServingServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeaturestoreOnlineServingServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeaturestoreOnlineServingServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeaturestoreOnlineServingServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FeaturestoreOnlineServingServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_logging_decorator.h b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_logging_decorator.h index 0a817803f8501..99b07574b6c3d 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_logging_decorator.h @@ -58,6 +58,26 @@ class FeaturestoreOnlineServingServiceLogging google::cloud::aiplatform::v1::WriteFeatureValuesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_metadata_decorator.cc index 52988ebf3f516..60542bc914b06 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_metadata_decorator.cc @@ -78,6 +78,54 @@ FeaturestoreOnlineServingServiceMetadata::WriteFeatureValues( return child_->WriteFeatureValues(context, options, request); } +StatusOr +FeaturestoreOnlineServingServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +FeaturestoreOnlineServingServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr +FeaturestoreOnlineServingServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr +FeaturestoreOnlineServingServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +FeaturestoreOnlineServingServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + void FeaturestoreOnlineServingServiceMetadata::SetMetadata( grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_metadata_decorator.h index 6678c97653313..8388f02a457df 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_metadata_decorator.h @@ -59,6 +59,26 @@ class FeaturestoreOnlineServingServiceMetadata google::cloud::aiplatform::v1::WriteFeatureValuesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_stub.cc b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_stub.cc index df4c5f249a1f5..eb91697a28f24 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_stub.cc +++ b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_stub.cc @@ -67,6 +67,67 @@ DefaultFeaturestoreOnlineServingServiceStub::WriteFeatureValues( return response; } +StatusOr +DefaultFeaturestoreOnlineServingServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFeaturestoreOnlineServingServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFeaturestoreOnlineServingServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFeaturestoreOnlineServingServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFeaturestoreOnlineServingServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_stub.h b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_stub.h index c998954ed7af5..89301aa4d84e9 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_stub.h +++ b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_stub.h @@ -24,6 +24,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include @@ -54,6 +58,28 @@ class FeaturestoreOnlineServingServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::aiplatform::v1::WriteFeatureValuesRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; }; class DefaultFeaturestoreOnlineServingServiceStub @@ -62,8 +88,13 @@ class DefaultFeaturestoreOnlineServingServiceStub explicit DefaultFeaturestoreOnlineServingServiceStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ReadFeatureValues( @@ -84,10 +115,33 @@ class DefaultFeaturestoreOnlineServingServiceStub google::cloud::aiplatform::v1::WriteFeatureValuesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_stub_factory.cc b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_stub_factory.cc index 537d84aae8bdf..29cc3dd926aed 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -46,9 +48,13 @@ CreateDefaultFeaturestoreOnlineServingServiceStub( auto service_grpc_stub = google::cloud::aiplatform::v1::FeaturestoreOnlineServingService::NewStub( channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared( diff --git a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_tracing_connection.cc index f801fc6840efd..57a59a47d709e 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_tracing_connection.cc @@ -69,6 +69,57 @@ FeaturestoreOnlineServingServiceTracingConnection::WriteFeatureValues( return internal::EndSpan(*span, child_->WriteFeatureValues(request)); } +StreamRange +FeaturestoreOnlineServingServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeaturestoreOnlineServingServiceConnection::" + "ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +FeaturestoreOnlineServingServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeaturestoreOnlineServingServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +FeaturestoreOnlineServingServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeaturestoreOnlineServingServiceConnection::" + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +FeaturestoreOnlineServingServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeaturestoreOnlineServingServiceConnection::" + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +FeaturestoreOnlineServingServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeaturestoreOnlineServingServiceConnection::" + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_tracing_connection.h b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_tracing_connection.h index d019053ddefa2..2c4a037429ced 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_tracing_connection.h @@ -56,6 +56,21 @@ class FeaturestoreOnlineServingServiceTracingConnection google::cloud::aiplatform::v1::WriteFeatureValuesRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; diff --git a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_tracing_stub.cc index 98d818b590e20..e163253cbb21f 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_tracing_stub.cc @@ -77,6 +77,71 @@ FeaturestoreOnlineServingServiceTracingStub::WriteFeatureValues( context, *span, child_->WriteFeatureValues(context, options, request)); } +StatusOr +FeaturestoreOnlineServingServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeaturestoreOnlineServingService", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +FeaturestoreOnlineServingServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeaturestoreOnlineServingService", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr +FeaturestoreOnlineServingServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeaturestoreOnlineServingService", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr +FeaturestoreOnlineServingServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeaturestoreOnlineServingService", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +FeaturestoreOnlineServingServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeaturestoreOnlineServingService", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_tracing_stub.h b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_tracing_stub.h index 29222532192e9..d50643f5656a5 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_online_serving_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/featurestore_online_serving_tracing_stub.h @@ -59,6 +59,26 @@ class FeaturestoreOnlineServingServiceTracingStub google::cloud::aiplatform::v1::WriteFeatureValuesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/featurestore_stub.cc b/google/cloud/aiplatform/v1/internal/featurestore_stub.cc index 584cfca7f790d..319175b4faf3b 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_stub.cc +++ b/google/cloud/aiplatform/v1/internal/featurestore_stub.cc @@ -512,6 +512,65 @@ DefaultFeaturestoreServiceStub::SearchFeatures( return response; } +StatusOr +DefaultFeaturestoreServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFeaturestoreServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultFeaturestoreServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultFeaturestoreServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFeaturestoreServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultFeaturestoreServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/featurestore_stub.h b/google/cloud/aiplatform/v1/internal/featurestore_stub.h index 06dd4cf08cc77..d89c7ada93745 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_stub.h +++ b/google/cloud/aiplatform/v1/internal/featurestore_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -230,6 +234,28 @@ class FeaturestoreServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::aiplatform::v1::SearchFeaturesRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -249,9 +275,15 @@ class DefaultFeaturestoreServiceStub : public FeaturestoreServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::FeaturestoreService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateFeaturestore( google::cloud::CompletionQueue& cq, @@ -442,6 +474,26 @@ class DefaultFeaturestoreServiceStub : public FeaturestoreServiceStub { google::cloud::aiplatform::v1::SearchFeaturesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -458,6 +510,9 @@ class DefaultFeaturestoreServiceStub : public FeaturestoreServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::FeaturestoreService::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/aiplatform/v1/internal/featurestore_stub_factory.cc b/google/cloud/aiplatform/v1/internal/featurestore_stub_factory.cc index 38f142ce1ac17..85ffc2d30b733 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/featurestore_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultFeaturestoreServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::FeaturestoreService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/aiplatform/v1/internal/featurestore_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/featurestore_tracing_connection.cc index b46dcf8e0d395..8591caf6d573d 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/featurestore_tracing_connection.cc @@ -490,6 +490,53 @@ FeaturestoreServiceTracingConnection::SearchFeatures( google::cloud::aiplatform::v1::Feature>(std::move(span), std::move(sr)); } +StreamRange +FeaturestoreServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeaturestoreServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +FeaturestoreServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeaturestoreServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +FeaturestoreServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeaturestoreServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +FeaturestoreServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeaturestoreServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +FeaturestoreServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::FeaturestoreServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/featurestore_tracing_connection.h b/google/cloud/aiplatform/v1/internal/featurestore_tracing_connection.h index 373e855fc2206..a080fa171523b 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/featurestore_tracing_connection.h @@ -226,6 +226,21 @@ class FeaturestoreServiceTracingConnection StreamRange SearchFeatures( google::cloud::aiplatform::v1::SearchFeaturesRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/aiplatform/v1/internal/featurestore_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/featurestore_tracing_stub.cc index 761b95f1dc863..4c553ba36a1ff 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/featurestore_tracing_stub.cc @@ -467,6 +467,64 @@ FeaturestoreServiceTracingStub::SearchFeatures( child_->SearchFeatures(context, options, request)); } +StatusOr +FeaturestoreServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeaturestoreService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +FeaturestoreServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeaturestoreService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr FeaturestoreServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeaturestoreService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr FeaturestoreServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeaturestoreService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +FeaturestoreServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.FeaturestoreService", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> FeaturestoreServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/featurestore_tracing_stub.h b/google/cloud/aiplatform/v1/internal/featurestore_tracing_stub.h index d7d83b53e384b..80717356c358a 100644 --- a/google/cloud/aiplatform/v1/internal/featurestore_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/featurestore_tracing_stub.h @@ -228,6 +228,26 @@ class FeaturestoreServiceTracingStub : public FeaturestoreServiceStub { google::cloud::aiplatform::v1::SearchFeaturesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_auth_decorator.cc index f41673dd8d2fc..5fda65ea232b1 100644 --- a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_auth_decorator.cc @@ -66,6 +66,48 @@ Status GenAiTuningServiceAuth::CancelTuningJob( return child_->CancelTuningJob(context, options, request); } +StatusOr +GenAiTuningServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr GenAiTuningServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr GenAiTuningServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr GenAiTuningServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +GenAiTuningServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_auth_decorator.h b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_auth_decorator.h index d61a06d46e330..db7627be30f9e 100644 --- a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_auth_decorator.h @@ -58,6 +58,26 @@ class GenAiTuningServiceAuth : public GenAiTuningServiceStub { google::cloud::aiplatform::v1::CancelTuningJobRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_connection_impl.cc b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_connection_impl.cc index 8eb252dad3b80..79f5f62d1816b 100644 --- a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_connection_impl.cc @@ -139,6 +139,96 @@ Status GenAiTuningServiceConnectionImpl::CancelTuningJob( *current, request, __func__); } +StreamRange +GenAiTuningServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +GenAiTuningServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +GenAiTuningServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +GenAiTuningServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +GenAiTuningServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_connection_impl.h b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_connection_impl.h index fbd5f1a7cfa24..403e26c9dc42c 100644 --- a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_connection_impl.h @@ -64,6 +64,21 @@ class GenAiTuningServiceConnectionImpl google::cloud::aiplatform::v1::CancelTuningJobRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_logging_decorator.cc index ace13441be0f5..99b7c9ebe960b 100644 --- a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_logging_decorator.cc @@ -86,6 +86,64 @@ Status GenAiTuningServiceLogging::CancelTuningJob( context, options, request, __func__, tracing_options_); } +StatusOr +GenAiTuningServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +GenAiTuningServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr GenAiTuningServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr GenAiTuningServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +GenAiTuningServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_logging_decorator.h b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_logging_decorator.h index 9e5b8c5f41c54..5a18eda84a60f 100644 --- a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_logging_decorator.h @@ -58,6 +58,26 @@ class GenAiTuningServiceLogging : public GenAiTuningServiceStub { google::cloud::aiplatform::v1::CancelTuningJobRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_metadata_decorator.cc index e40dc23ae9d2f..15cfb1c08aa9a 100644 --- a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_metadata_decorator.cc @@ -79,6 +79,52 @@ Status GenAiTuningServiceMetadata::CancelTuningJob( return child_->CancelTuningJob(context, options, request); } +StatusOr +GenAiTuningServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +GenAiTuningServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr GenAiTuningServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr GenAiTuningServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +GenAiTuningServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + void GenAiTuningServiceMetadata::SetMetadata( grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_metadata_decorator.h index 4d3590ab37398..539e7d40c53e3 100644 --- a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_metadata_decorator.h @@ -59,6 +59,26 @@ class GenAiTuningServiceMetadata : public GenAiTuningServiceStub { google::cloud::aiplatform::v1::CancelTuningJobRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_stub.cc b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_stub.cc index 3b993a1e97ad6..2a8710114ff5f 100644 --- a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_stub.cc +++ b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_stub.cc @@ -77,6 +77,65 @@ Status DefaultGenAiTuningServiceStub::CancelTuningJob( return google::cloud::Status(); } +StatusOr +DefaultGenAiTuningServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultGenAiTuningServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultGenAiTuningServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultGenAiTuningServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultGenAiTuningServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_stub.h b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_stub.h index 582d3ab82839f..d3b2910a9c7f8 100644 --- a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_stub.h +++ b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_stub.h @@ -23,6 +23,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include @@ -51,6 +55,28 @@ class GenAiTuningServiceStub { virtual Status CancelTuningJob( grpc::ClientContext& context, Options const& options, google::cloud::aiplatform::v1::CancelTuningJobRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; }; class DefaultGenAiTuningServiceStub : public GenAiTuningServiceStub { @@ -58,8 +84,13 @@ class DefaultGenAiTuningServiceStub : public GenAiTuningServiceStub { explicit DefaultGenAiTuningServiceStub( std::unique_ptr< google::cloud::aiplatform::v1::GenAiTuningService::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr CreateTuningJob( grpc::ClientContext& context, Options const& options, @@ -81,10 +112,33 @@ class DefaultGenAiTuningServiceStub : public GenAiTuningServiceStub { google::cloud::aiplatform::v1::CancelTuningJobRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr< google::cloud::aiplatform::v1::GenAiTuningService::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_stub_factory.cc b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_stub_factory.cc index 0de3cc3051e18..345eaffcd43ee 100644 --- a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultGenAiTuningServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::GenAiTuningService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_tracing_connection.cc index 362cc8cf5fdea..fd2229d71b2e9 100644 --- a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_tracing_connection.cc @@ -70,6 +70,53 @@ Status GenAiTuningServiceTracingConnection::CancelTuningJob( return internal::EndSpan(*span, child_->CancelTuningJob(request)); } +StreamRange +GenAiTuningServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::GenAiTuningServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +GenAiTuningServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::GenAiTuningServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +GenAiTuningServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::GenAiTuningServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +GenAiTuningServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::GenAiTuningServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +GenAiTuningServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::GenAiTuningServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_tracing_connection.h b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_tracing_connection.h index 5887e84b28005..f5d53eaf5bbac 100644 --- a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_tracing_connection.h @@ -55,6 +55,21 @@ class GenAiTuningServiceTracingConnection google::cloud::aiplatform::v1::CancelTuningJobRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_tracing_stub.cc index 4971a73bc2655..f690d0762e0c9 100644 --- a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_tracing_stub.cc @@ -79,6 +79,64 @@ Status GenAiTuningServiceTracingStub::CancelTuningJob( child_->CancelTuningJob(context, options, request)); } +StatusOr +GenAiTuningServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.GenAiTuningService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +GenAiTuningServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.GenAiTuningService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr GenAiTuningServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.GenAiTuningService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr GenAiTuningServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.GenAiTuningService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +GenAiTuningServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.GenAiTuningService", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeGenAiTuningServiceTracingStub( diff --git a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_tracing_stub.h b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_tracing_stub.h index fec3d6cd63622..52d889c2f4978 100644 --- a/google/cloud/aiplatform/v1/internal/gen_ai_tuning_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/gen_ai_tuning_tracing_stub.h @@ -59,6 +59,26 @@ class GenAiTuningServiceTracingStub : public GenAiTuningServiceStub { google::cloud::aiplatform::v1::CancelTuningJobRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/index_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/index_auth_decorator.cc index 114f84b623364..64998c7133ad0 100644 --- a/google/cloud/aiplatform/v1/internal/index_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/index_auth_decorator.cc @@ -150,6 +150,48 @@ IndexServiceAuth::RemoveDatapoints( return child_->RemoveDatapoints(context, options, request); } +StatusOr +IndexServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr IndexServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr IndexServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr IndexServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +IndexServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> IndexServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/index_auth_decorator.h b/google/cloud/aiplatform/v1/internal/index_auth_decorator.h index 320c219fcfa10..b5133dcf1edcd 100644 --- a/google/cloud/aiplatform/v1/internal/index_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/index_auth_decorator.h @@ -94,6 +94,26 @@ class IndexServiceAuth : public IndexServiceStub { google::cloud::aiplatform::v1::RemoveDatapointsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/index_connection_impl.cc b/google/cloud/aiplatform/v1/internal/index_connection_impl.cc index f086d375ecc91..fec138b4e76bf 100644 --- a/google/cloud/aiplatform/v1/internal/index_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/index_connection_impl.cc @@ -416,6 +416,94 @@ IndexServiceConnectionImpl::RemoveDatapoints( *current, request, __func__); } +StreamRange +IndexServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +IndexServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr IndexServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr IndexServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +IndexServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/index_connection_impl.h b/google/cloud/aiplatform/v1/internal/index_connection_impl.h index ce548192aea41..ab973bfb78f54 100644 --- a/google/cloud/aiplatform/v1/internal/index_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/index_connection_impl.h @@ -102,6 +102,21 @@ class IndexServiceConnectionImpl RemoveDatapoints(google::cloud::aiplatform::v1::RemoveDatapointsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/aiplatform/v1/internal/index_endpoint_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/index_endpoint_auth_decorator.cc index b5ef4091d2e74..3f7e298d4de5d 100644 --- a/google/cloud/aiplatform/v1/internal/index_endpoint_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/index_endpoint_auth_decorator.cc @@ -202,6 +202,49 @@ IndexEndpointServiceAuth::MutateDeployedIndex( return child_->MutateDeployedIndex(context, options, request); } +StatusOr +IndexEndpointServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +IndexEndpointServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr IndexEndpointServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr IndexEndpointServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +IndexEndpointServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> IndexEndpointServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/index_endpoint_auth_decorator.h b/google/cloud/aiplatform/v1/internal/index_endpoint_auth_decorator.h index 7a14c69432696..937ef48c4ed0a 100644 --- a/google/cloud/aiplatform/v1/internal/index_endpoint_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/index_endpoint_auth_decorator.h @@ -115,6 +115,26 @@ class IndexEndpointServiceAuth : public IndexEndpointServiceStub { google::cloud::aiplatform::v1::MutateDeployedIndexRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/index_endpoint_connection_impl.cc b/google/cloud/aiplatform/v1/internal/index_endpoint_connection_impl.cc index b9498bcf2931e..96b48d1b5099b 100644 --- a/google/cloud/aiplatform/v1/internal/index_endpoint_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/index_endpoint_connection_impl.cc @@ -600,6 +600,96 @@ IndexEndpointServiceConnectionImpl::MutateDeployedIndex( polling_policy(*current), __func__); } +StreamRange +IndexEndpointServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +IndexEndpointServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +IndexEndpointServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +IndexEndpointServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +IndexEndpointServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/index_endpoint_connection_impl.h b/google/cloud/aiplatform/v1/internal/index_endpoint_connection_impl.h index 789acdf76e47d..c8f771bb9e712 100644 --- a/google/cloud/aiplatform/v1/internal/index_endpoint_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/index_endpoint_connection_impl.h @@ -127,6 +127,21 @@ class IndexEndpointServiceConnectionImpl future> MutateDeployedIndex(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/aiplatform/v1/internal/index_endpoint_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/index_endpoint_logging_decorator.cc index 6baae80aba18a..876b7819908ea 100644 --- a/google/cloud/aiplatform/v1/internal/index_endpoint_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/index_endpoint_logging_decorator.cc @@ -232,6 +232,64 @@ IndexEndpointServiceLogging::MutateDeployedIndex( context, options, request, __func__, tracing_options_); } +StatusOr +IndexEndpointServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +IndexEndpointServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr IndexEndpointServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr IndexEndpointServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +IndexEndpointServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> IndexEndpointServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/index_endpoint_logging_decorator.h b/google/cloud/aiplatform/v1/internal/index_endpoint_logging_decorator.h index 8517bd32f9ca6..22b03bd40eeb9 100644 --- a/google/cloud/aiplatform/v1/internal/index_endpoint_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/index_endpoint_logging_decorator.h @@ -115,6 +115,26 @@ class IndexEndpointServiceLogging : public IndexEndpointServiceStub { google::cloud::aiplatform::v1::MutateDeployedIndexRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/index_endpoint_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/index_endpoint_metadata_decorator.cc index 76301ac12adf5..4fcdf3bf1533b 100644 --- a/google/cloud/aiplatform/v1/internal/index_endpoint_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/index_endpoint_metadata_decorator.cc @@ -184,6 +184,52 @@ IndexEndpointServiceMetadata::MutateDeployedIndex( return child_->MutateDeployedIndex(context, options, request); } +StatusOr +IndexEndpointServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +IndexEndpointServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr IndexEndpointServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr IndexEndpointServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +IndexEndpointServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> IndexEndpointServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/index_endpoint_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/index_endpoint_metadata_decorator.h index 5e7d57d7f60c4..df1e95f0dc56c 100644 --- a/google/cloud/aiplatform/v1/internal/index_endpoint_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/index_endpoint_metadata_decorator.h @@ -116,6 +116,26 @@ class IndexEndpointServiceMetadata : public IndexEndpointServiceStub { google::cloud::aiplatform::v1::MutateDeployedIndexRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/index_endpoint_stub.cc b/google/cloud/aiplatform/v1/internal/index_endpoint_stub.cc index fa3959da99918..433002fad843c 100644 --- a/google/cloud/aiplatform/v1/internal/index_endpoint_stub.cc +++ b/google/cloud/aiplatform/v1/internal/index_endpoint_stub.cc @@ -220,6 +220,65 @@ DefaultIndexEndpointServiceStub::MutateDeployedIndex( return response; } +StatusOr +DefaultIndexEndpointServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultIndexEndpointServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultIndexEndpointServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultIndexEndpointServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultIndexEndpointServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultIndexEndpointServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/index_endpoint_stub.h b/google/cloud/aiplatform/v1/internal/index_endpoint_stub.h index bf5e602a79ced..8496a05d2ff82 100644 --- a/google/cloud/aiplatform/v1/internal/index_endpoint_stub.h +++ b/google/cloud/aiplatform/v1/internal/index_endpoint_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -114,6 +118,28 @@ class IndexEndpointServiceStub { google::cloud::aiplatform::v1::MutateDeployedIndexRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -133,9 +159,15 @@ class DefaultIndexEndpointServiceStub : public IndexEndpointServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::IndexEndpointService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateIndexEndpoint( google::cloud::CompletionQueue& cq, @@ -213,6 +245,26 @@ class DefaultIndexEndpointServiceStub : public IndexEndpointServiceStub { google::cloud::aiplatform::v1::MutateDeployedIndexRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -229,6 +281,9 @@ class DefaultIndexEndpointServiceStub : public IndexEndpointServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::IndexEndpointService::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/aiplatform/v1/internal/index_endpoint_stub_factory.cc b/google/cloud/aiplatform/v1/internal/index_endpoint_stub_factory.cc index 7b2ee5511930e..549c9943dee4a 100644 --- a/google/cloud/aiplatform/v1/internal/index_endpoint_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/index_endpoint_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultIndexEndpointServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::IndexEndpointService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/aiplatform/v1/internal/index_endpoint_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/index_endpoint_tracing_connection.cc index 8598a8b491e2a..8f717a959c2b9 100644 --- a/google/cloud/aiplatform/v1/internal/index_endpoint_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/index_endpoint_tracing_connection.cc @@ -212,6 +212,53 @@ IndexEndpointServiceTracingConnection::MutateDeployedIndex( child_->MutateDeployedIndex(operation)); } +StreamRange +IndexEndpointServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::IndexEndpointServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +IndexEndpointServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::IndexEndpointServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +IndexEndpointServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::IndexEndpointServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +IndexEndpointServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::IndexEndpointServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +IndexEndpointServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::IndexEndpointServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/index_endpoint_tracing_connection.h b/google/cloud/aiplatform/v1/internal/index_endpoint_tracing_connection.h index 69f88f696e0a7..23cce0560722e 100644 --- a/google/cloud/aiplatform/v1/internal/index_endpoint_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/index_endpoint_tracing_connection.h @@ -115,6 +115,21 @@ class IndexEndpointServiceTracingConnection future> MutateDeployedIndex(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/aiplatform/v1/internal/index_endpoint_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/index_endpoint_tracing_stub.cc index 361df925f49f9..b23428b616ec9 100644 --- a/google/cloud/aiplatform/v1/internal/index_endpoint_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/index_endpoint_tracing_stub.cc @@ -201,6 +201,64 @@ IndexEndpointServiceTracingStub::MutateDeployedIndex( context, *span, child_->MutateDeployedIndex(context, options, request)); } +StatusOr +IndexEndpointServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.IndexEndpointService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +IndexEndpointServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.IndexEndpointService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr IndexEndpointServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.IndexEndpointService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr IndexEndpointServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.IndexEndpointService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +IndexEndpointServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.IndexEndpointService", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> IndexEndpointServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/index_endpoint_tracing_stub.h b/google/cloud/aiplatform/v1/internal/index_endpoint_tracing_stub.h index 7c71c2d0cfc3b..0de2de05c138f 100644 --- a/google/cloud/aiplatform/v1/internal/index_endpoint_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/index_endpoint_tracing_stub.h @@ -115,6 +115,26 @@ class IndexEndpointServiceTracingStub : public IndexEndpointServiceStub { google::cloud::aiplatform::v1::MutateDeployedIndexRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/index_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/index_logging_decorator.cc index df8cea5ed5bd1..81e6487879861 100644 --- a/google/cloud/aiplatform/v1/internal/index_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/index_logging_decorator.cc @@ -171,6 +171,63 @@ IndexServiceLogging::RemoveDatapoints( context, options, request, __func__, tracing_options_); } +StatusOr +IndexServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr IndexServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr IndexServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr IndexServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +IndexServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> IndexServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/index_logging_decorator.h b/google/cloud/aiplatform/v1/internal/index_logging_decorator.h index 2f9cc2d665e95..4786ceaaa7bfa 100644 --- a/google/cloud/aiplatform/v1/internal/index_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/index_logging_decorator.h @@ -94,6 +94,26 @@ class IndexServiceLogging : public IndexServiceStub { google::cloud::aiplatform::v1::RemoveDatapointsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/index_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/index_metadata_decorator.cc index 89e328dcfcd7f..c9f87d740468c 100644 --- a/google/cloud/aiplatform/v1/internal/index_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/index_metadata_decorator.cc @@ -141,6 +141,51 @@ IndexServiceMetadata::RemoveDatapoints( return child_->RemoveDatapoints(context, options, request); } +StatusOr +IndexServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr IndexServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr IndexServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr IndexServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +IndexServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> IndexServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/index_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/index_metadata_decorator.h index 182b758c8b439..31c8f5d8bdf71 100644 --- a/google/cloud/aiplatform/v1/internal/index_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/index_metadata_decorator.h @@ -94,6 +94,26 @@ class IndexServiceMetadata : public IndexServiceStub { google::cloud::aiplatform::v1::RemoveDatapointsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/index_stub.cc b/google/cloud/aiplatform/v1/internal/index_stub.cc index 6011c6a327367..af881db978e99 100644 --- a/google/cloud/aiplatform/v1/internal/index_stub.cc +++ b/google/cloud/aiplatform/v1/internal/index_stub.cc @@ -166,6 +166,65 @@ DefaultIndexServiceStub::RemoveDatapoints( return response; } +StatusOr +DefaultIndexServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultIndexServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultIndexServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultIndexServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultIndexServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultIndexServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/index_stub.h b/google/cloud/aiplatform/v1/internal/index_stub.h index 6b6b709162c64..b1917afbfed1b 100644 --- a/google/cloud/aiplatform/v1/internal/index_stub.h +++ b/google/cloud/aiplatform/v1/internal/index_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -87,6 +91,28 @@ class IndexServiceStub { google::cloud::aiplatform::v1::RemoveDatapointsRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -106,9 +132,15 @@ class DefaultIndexServiceStub : public IndexServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::IndexService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateIndex( google::cloud::CompletionQueue& cq, @@ -165,6 +197,26 @@ class DefaultIndexServiceStub : public IndexServiceStub { google::cloud::aiplatform::v1::RemoveDatapointsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -180,6 +232,9 @@ class DefaultIndexServiceStub : public IndexServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/aiplatform/v1/internal/index_stub_factory.cc b/google/cloud/aiplatform/v1/internal/index_stub_factory.cc index 49215c39fa4d8..318939b0831b9 100644 --- a/google/cloud/aiplatform/v1/internal/index_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/index_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultIndexServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::IndexService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/aiplatform/v1/internal/index_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/index_tracing_connection.cc index ea2e76b9115ed..7d06954d82647 100644 --- a/google/cloud/aiplatform/v1/internal/index_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/index_tracing_connection.cc @@ -155,6 +155,51 @@ IndexServiceTracingConnection::RemoveDatapoints( return internal::EndSpan(*span, child_->RemoveDatapoints(request)); } +StreamRange +IndexServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::IndexServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +IndexServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("aiplatform_v1::IndexServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr IndexServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("aiplatform_v1::IndexServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr IndexServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("aiplatform_v1::IndexServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +IndexServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::IndexServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/index_tracing_connection.h b/google/cloud/aiplatform/v1/internal/index_tracing_connection.h index e7be2430c8cbd..8a972030d0993 100644 --- a/google/cloud/aiplatform/v1/internal/index_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/index_tracing_connection.h @@ -90,6 +90,21 @@ class IndexServiceTracingConnection RemoveDatapoints(google::cloud::aiplatform::v1::RemoveDatapointsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/aiplatform/v1/internal/index_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/index_tracing_stub.cc index 35b13668cf60a..54fefecaa15f7 100644 --- a/google/cloud/aiplatform/v1/internal/index_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/index_tracing_stub.cc @@ -155,6 +155,64 @@ IndexServiceTracingStub::RemoveDatapoints( child_->RemoveDatapoints(context, options, request)); } +StatusOr +IndexServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.IndexService", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +IndexServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.IndexService", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr IndexServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.IndexService", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr IndexServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.IndexService", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +IndexServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.IndexService", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> IndexServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/index_tracing_stub.h b/google/cloud/aiplatform/v1/internal/index_tracing_stub.h index b8913dbb871e1..3bc1c7ce74765 100644 --- a/google/cloud/aiplatform/v1/internal/index_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/index_tracing_stub.h @@ -93,6 +93,26 @@ class IndexServiceTracingStub : public IndexServiceStub { google::cloud::aiplatform::v1::RemoveDatapointsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/job_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/job_auth_decorator.cc index f771c80e06c42..cf2b2d28aed81 100644 --- a/google/cloud/aiplatform/v1/internal/job_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/job_auth_decorator.cc @@ -502,6 +502,48 @@ Status JobServiceAuth::ResumeModelDeploymentMonitoringJob( return child_->ResumeModelDeploymentMonitoringJob(context, options, request); } +StatusOr +JobServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr JobServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr JobServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr JobServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +JobServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> JobServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/job_auth_decorator.h b/google/cloud/aiplatform/v1/internal/job_auth_decorator.h index a5d8bfb1df8ec..e8f834021ef70 100644 --- a/google/cloud/aiplatform/v1/internal/job_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/job_auth_decorator.h @@ -281,6 +281,26 @@ class JobServiceAuth : public JobServiceStub { google::cloud::aiplatform::v1:: ResumeModelDeploymentMonitoringJobRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/job_connection_impl.cc b/google/cloud/aiplatform/v1/internal/job_connection_impl.cc index 72008b7ca641d..619c19edcc1fb 100644 --- a/google/cloud/aiplatform/v1/internal/job_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/job_connection_impl.cc @@ -1340,6 +1340,94 @@ Status JobServiceConnectionImpl::ResumeModelDeploymentMonitoringJob( *current, request, __func__); } +StreamRange +JobServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +JobServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr JobServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr JobServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +JobServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/job_connection_impl.h b/google/cloud/aiplatform/v1/internal/job_connection_impl.h index 8ed9a1ad2f05a..96ecdb1e2a344 100644 --- a/google/cloud/aiplatform/v1/internal/job_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/job_connection_impl.h @@ -266,6 +266,21 @@ class JobServiceConnectionImpl : public aiplatform_v1::JobServiceConnection { google::cloud::aiplatform::v1:: ResumeModelDeploymentMonitoringJobRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/aiplatform/v1/internal/job_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/job_logging_decorator.cc index 585e5c763a92d..dfe9230569c41 100644 --- a/google/cloud/aiplatform/v1/internal/job_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/job_logging_decorator.cc @@ -652,6 +652,63 @@ Status JobServiceLogging::ResumeModelDeploymentMonitoringJob( context, options, request, __func__, tracing_options_); } +StatusOr +JobServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr JobServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr JobServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr JobServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +JobServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> JobServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/job_logging_decorator.h b/google/cloud/aiplatform/v1/internal/job_logging_decorator.h index 4e333f378cc5e..2063551eb7406 100644 --- a/google/cloud/aiplatform/v1/internal/job_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/job_logging_decorator.h @@ -281,6 +281,26 @@ class JobServiceLogging : public JobServiceStub { google::cloud::aiplatform::v1:: ResumeModelDeploymentMonitoringJobRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/job_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/job_metadata_decorator.cc index 1d5c272538f62..4fc4cd0b72091 100644 --- a/google/cloud/aiplatform/v1/internal/job_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/job_metadata_decorator.cc @@ -470,6 +470,51 @@ Status JobServiceMetadata::ResumeModelDeploymentMonitoringJob( return child_->ResumeModelDeploymentMonitoringJob(context, options, request); } +StatusOr +JobServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr JobServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr JobServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr JobServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +JobServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> JobServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/job_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/job_metadata_decorator.h index 3bf6d1615a068..1fb1532cc7243 100644 --- a/google/cloud/aiplatform/v1/internal/job_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/job_metadata_decorator.h @@ -281,6 +281,26 @@ class JobServiceMetadata : public JobServiceStub { google::cloud::aiplatform::v1:: ResumeModelDeploymentMonitoringJobRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/job_stub.cc b/google/cloud/aiplatform/v1/internal/job_stub.cc index 8456cadda1462..f8ab018e1d953 100644 --- a/google/cloud/aiplatform/v1/internal/job_stub.cc +++ b/google/cloud/aiplatform/v1/internal/job_stub.cc @@ -625,6 +625,64 @@ Status DefaultJobServiceStub::ResumeModelDeploymentMonitoringJob( return google::cloud::Status(); } +StatusOr +DefaultJobServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultJobServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultJobServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultJobServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultJobServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultJobServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/job_stub.h b/google/cloud/aiplatform/v1/internal/job_stub.h index fd8b57ec6bf3d..6f351e7d15ee0 100644 --- a/google/cloud/aiplatform/v1/internal/job_stub.h +++ b/google/cloud/aiplatform/v1/internal/job_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -280,6 +284,28 @@ class JobServiceStub { google::cloud::aiplatform::v1:: ResumeModelDeploymentMonitoringJobRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -298,9 +324,15 @@ class DefaultJobServiceStub : public JobServiceStub { DefaultJobServiceStub( std::unique_ptr grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr CreateCustomJob( grpc::ClientContext& context, Options const& options, @@ -544,6 +576,26 @@ class DefaultJobServiceStub : public JobServiceStub { google::cloud::aiplatform::v1:: ResumeModelDeploymentMonitoringJobRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -559,6 +611,9 @@ class DefaultJobServiceStub : public JobServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/aiplatform/v1/internal/job_stub_factory.cc b/google/cloud/aiplatform/v1/internal/job_stub_factory.cc index f2b228adce507..2082d19679f3e 100644 --- a/google/cloud/aiplatform/v1/internal/job_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/job_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultJobServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::JobService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/aiplatform/v1/internal/job_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/job_tracing_connection.cc index 6dcc3a2b877f5..78ae236e2b662 100644 --- a/google/cloud/aiplatform/v1/internal/job_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/job_tracing_connection.cc @@ -551,6 +551,51 @@ Status JobServiceTracingConnection::ResumeModelDeploymentMonitoringJob( child_->ResumeModelDeploymentMonitoringJob(request)); } +StreamRange +JobServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("aiplatform_v1::JobServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +JobServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("aiplatform_v1::JobServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr JobServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("aiplatform_v1::JobServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr JobServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("aiplatform_v1::JobServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +JobServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::JobServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/job_tracing_connection.h b/google/cloud/aiplatform/v1/internal/job_tracing_connection.h index 565a032fe2430..f8c241d9124f1 100644 --- a/google/cloud/aiplatform/v1/internal/job_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/job_tracing_connection.h @@ -254,6 +254,21 @@ class JobServiceTracingConnection : public aiplatform_v1::JobServiceConnection { google::cloud::aiplatform::v1:: ResumeModelDeploymentMonitoringJobRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/aiplatform/v1/internal/job_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/job_tracing_stub.cc index d2f9a299511fc..cc36376fa7d1a 100644 --- a/google/cloud/aiplatform/v1/internal/job_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/job_tracing_stub.cc @@ -594,6 +594,63 @@ Status JobServiceTracingStub::ResumeModelDeploymentMonitoringJob( child_->ResumeModelDeploymentMonitoringJob(context, options, request)); } +StatusOr +JobServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.JobService", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr JobServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.JobService", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr JobServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.JobService", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr JobServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.JobService", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +JobServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.JobService", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> JobServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/job_tracing_stub.h b/google/cloud/aiplatform/v1/internal/job_tracing_stub.h index 128396b25f1a5..2e16f4b4a386e 100644 --- a/google/cloud/aiplatform/v1/internal/job_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/job_tracing_stub.h @@ -280,6 +280,26 @@ class JobServiceTracingStub : public JobServiceStub { google::cloud::aiplatform::v1:: ResumeModelDeploymentMonitoringJobRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/llm_utility_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/llm_utility_auth_decorator.cc index 4cf9aebace447..547f971378124 100644 --- a/google/cloud/aiplatform/v1/internal/llm_utility_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/llm_utility_auth_decorator.cc @@ -49,6 +49,48 @@ LlmUtilityServiceAuth::ComputeTokens( return child_->ComputeTokens(context, options, request); } +StatusOr +LlmUtilityServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr LlmUtilityServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr LlmUtilityServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr LlmUtilityServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +LlmUtilityServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/llm_utility_auth_decorator.h b/google/cloud/aiplatform/v1/internal/llm_utility_auth_decorator.h index 17bbb44dda078..8e36e3a4a59af 100644 --- a/google/cloud/aiplatform/v1/internal/llm_utility_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/llm_utility_auth_decorator.h @@ -48,6 +48,26 @@ class LlmUtilityServiceAuth : public LlmUtilityServiceStub { google::cloud::aiplatform::v1::ComputeTokensRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/aiplatform/v1/internal/llm_utility_connection_impl.cc b/google/cloud/aiplatform/v1/internal/llm_utility_connection_impl.cc index c12a0d67785f1..9e889afa2859a 100644 --- a/google/cloud/aiplatform/v1/internal/llm_utility_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/llm_utility_connection_impl.cc @@ -21,6 +21,7 @@ #include "google/cloud/background_threads.h" #include "google/cloud/common_options.h" #include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/retry_loop.h" #include #include @@ -89,6 +90,94 @@ LlmUtilityServiceConnectionImpl::ComputeTokens( *current, request, __func__); } +StreamRange +LlmUtilityServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +LlmUtilityServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr LlmUtilityServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr LlmUtilityServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +LlmUtilityServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/llm_utility_connection_impl.h b/google/cloud/aiplatform/v1/internal/llm_utility_connection_impl.h index 9da6d2744a4a9..9fe011fef5e41 100644 --- a/google/cloud/aiplatform/v1/internal/llm_utility_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/llm_utility_connection_impl.h @@ -28,6 +28,7 @@ #include "google/cloud/backoff_policy.h" #include "google/cloud/options.h" #include "google/cloud/status_or.h" +#include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include @@ -56,6 +57,21 @@ class LlmUtilityServiceConnectionImpl google::cloud::aiplatform::v1::ComputeTokensRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/aiplatform/v1/internal/llm_utility_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/llm_utility_logging_decorator.cc index f955249868a98..cce14d149504c 100644 --- a/google/cloud/aiplatform/v1/internal/llm_utility_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/llm_utility_logging_decorator.cc @@ -60,6 +60,64 @@ LlmUtilityServiceLogging::ComputeTokens( context, options, request, __func__, tracing_options_); } +StatusOr +LlmUtilityServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +LlmUtilityServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr LlmUtilityServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr LlmUtilityServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +LlmUtilityServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/llm_utility_logging_decorator.h b/google/cloud/aiplatform/v1/internal/llm_utility_logging_decorator.h index 81e8302dbbe25..7574a2def6ecf 100644 --- a/google/cloud/aiplatform/v1/internal/llm_utility_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/llm_utility_logging_decorator.h @@ -48,6 +48,26 @@ class LlmUtilityServiceLogging : public LlmUtilityServiceStub { google::cloud::aiplatform::v1::ComputeTokensRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/aiplatform/v1/internal/llm_utility_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/llm_utility_metadata_decorator.cc index 1ada528eea322..c52604c7c88cc 100644 --- a/google/cloud/aiplatform/v1/internal/llm_utility_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/llm_utility_metadata_decorator.cc @@ -64,6 +64,52 @@ LlmUtilityServiceMetadata::ComputeTokens( return child_->ComputeTokens(context, options, request); } +StatusOr +LlmUtilityServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +LlmUtilityServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr LlmUtilityServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr LlmUtilityServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +LlmUtilityServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + void LlmUtilityServiceMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/aiplatform/v1/internal/llm_utility_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/llm_utility_metadata_decorator.h index f543f6d6b4ffa..32a6ad14083b5 100644 --- a/google/cloud/aiplatform/v1/internal/llm_utility_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/llm_utility_metadata_decorator.h @@ -49,6 +49,26 @@ class LlmUtilityServiceMetadata : public LlmUtilityServiceStub { google::cloud::aiplatform::v1::ComputeTokensRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/aiplatform/v1/internal/llm_utility_stub.cc b/google/cloud/aiplatform/v1/internal/llm_utility_stub.cc index ec1760a4c08c9..adfe4346bc696 100644 --- a/google/cloud/aiplatform/v1/internal/llm_utility_stub.cc +++ b/google/cloud/aiplatform/v1/internal/llm_utility_stub.cc @@ -54,6 +54,65 @@ DefaultLlmUtilityServiceStub::ComputeTokens( return response; } +StatusOr +DefaultLlmUtilityServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultLlmUtilityServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultLlmUtilityServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultLlmUtilityServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultLlmUtilityServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/llm_utility_stub.h b/google/cloud/aiplatform/v1/internal/llm_utility_stub.h index eb8bd76fee153..acf1c7f6a69bb 100644 --- a/google/cloud/aiplatform/v1/internal/llm_utility_stub.h +++ b/google/cloud/aiplatform/v1/internal/llm_utility_stub.h @@ -23,6 +23,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include @@ -44,6 +48,28 @@ class LlmUtilityServiceStub { ComputeTokens( grpc::ClientContext& context, Options const& options, google::cloud::aiplatform::v1::ComputeTokensRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; }; class DefaultLlmUtilityServiceStub : public LlmUtilityServiceStub { @@ -51,8 +77,13 @@ class DefaultLlmUtilityServiceStub : public LlmUtilityServiceStub { explicit DefaultLlmUtilityServiceStub( std::unique_ptr< google::cloud::aiplatform::v1::LlmUtilityService::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr CountTokens( grpc::ClientContext& context, Options const& options, @@ -64,10 +95,33 @@ class DefaultLlmUtilityServiceStub : public LlmUtilityServiceStub { google::cloud::aiplatform::v1::ComputeTokensRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr< google::cloud::aiplatform::v1::LlmUtilityService::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/internal/llm_utility_stub_factory.cc b/google/cloud/aiplatform/v1/internal/llm_utility_stub_factory.cc index 2fd11daee7089..0701d7716977b 100644 --- a/google/cloud/aiplatform/v1/internal/llm_utility_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/llm_utility_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultLlmUtilityServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::LlmUtilityService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/aiplatform/v1/internal/llm_utility_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/llm_utility_tracing_connection.cc index 844d8d7158758..33185046d97c8 100644 --- a/google/cloud/aiplatform/v1/internal/llm_utility_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/llm_utility_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/aiplatform/v1/internal/llm_utility_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -50,6 +51,53 @@ LlmUtilityServiceTracingConnection::ComputeTokens( return internal::EndSpan(*span, child_->ComputeTokens(request)); } +StreamRange +LlmUtilityServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::LlmUtilityServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +LlmUtilityServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::LlmUtilityServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +LlmUtilityServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::LlmUtilityServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +LlmUtilityServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::LlmUtilityServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +LlmUtilityServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::LlmUtilityServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/llm_utility_tracing_connection.h b/google/cloud/aiplatform/v1/internal/llm_utility_tracing_connection.h index d2fe258983fa4..43093aecdceed 100644 --- a/google/cloud/aiplatform/v1/internal/llm_utility_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/llm_utility_tracing_connection.h @@ -48,6 +48,21 @@ class LlmUtilityServiceTracingConnection google::cloud::aiplatform::v1::ComputeTokensRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/aiplatform/v1/internal/llm_utility_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/llm_utility_tracing_stub.cc index e36f79749da73..14b66b4e3edf9 100644 --- a/google/cloud/aiplatform/v1/internal/llm_utility_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/llm_utility_tracing_stub.cc @@ -56,6 +56,64 @@ LlmUtilityServiceTracingStub::ComputeTokens( child_->ComputeTokens(context, options, request)); } +StatusOr +LlmUtilityServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.LlmUtilityService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +LlmUtilityServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.LlmUtilityService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr LlmUtilityServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.LlmUtilityService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr LlmUtilityServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.LlmUtilityService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +LlmUtilityServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.LlmUtilityService", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeLlmUtilityServiceTracingStub( diff --git a/google/cloud/aiplatform/v1/internal/llm_utility_tracing_stub.h b/google/cloud/aiplatform/v1/internal/llm_utility_tracing_stub.h index fe56896db0d2d..f671f064a87df 100644 --- a/google/cloud/aiplatform/v1/internal/llm_utility_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/llm_utility_tracing_stub.h @@ -49,6 +49,26 @@ class LlmUtilityServiceTracingStub : public LlmUtilityServiceStub { google::cloud::aiplatform::v1::ComputeTokensRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/match_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/match_auth_decorator.cc index 6c23291338fc9..6bb3d44db602a 100644 --- a/google/cloud/aiplatform/v1/internal/match_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/match_auth_decorator.cc @@ -49,6 +49,48 @@ MatchServiceAuth::ReadIndexDatapoints( return child_->ReadIndexDatapoints(context, options, request); } +StatusOr +MatchServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr MatchServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr MatchServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr MatchServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +MatchServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/match_auth_decorator.h b/google/cloud/aiplatform/v1/internal/match_auth_decorator.h index 5ffb8ba42d8d2..a020861d07372 100644 --- a/google/cloud/aiplatform/v1/internal/match_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/match_auth_decorator.h @@ -49,6 +49,26 @@ class MatchServiceAuth : public MatchServiceStub { google::cloud::aiplatform::v1::ReadIndexDatapointsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/aiplatform/v1/internal/match_connection_impl.cc b/google/cloud/aiplatform/v1/internal/match_connection_impl.cc index d284e4a36a4e7..6fb944741f3a3 100644 --- a/google/cloud/aiplatform/v1/internal/match_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/match_connection_impl.cc @@ -21,6 +21,7 @@ #include "google/cloud/background_threads.h" #include "google/cloud/common_options.h" #include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/retry_loop.h" #include #include @@ -88,6 +89,94 @@ MatchServiceConnectionImpl::ReadIndexDatapoints( *current, request, __func__); } +StreamRange +MatchServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +MatchServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr MatchServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr MatchServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +MatchServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/match_connection_impl.h b/google/cloud/aiplatform/v1/internal/match_connection_impl.h index ef093802d34d3..5c60988dbcac7 100644 --- a/google/cloud/aiplatform/v1/internal/match_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/match_connection_impl.h @@ -28,6 +28,7 @@ #include "google/cloud/backoff_policy.h" #include "google/cloud/options.h" #include "google/cloud/status_or.h" +#include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include @@ -57,6 +58,21 @@ class MatchServiceConnectionImpl google::cloud::aiplatform::v1::ReadIndexDatapointsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/aiplatform/v1/internal/match_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/match_logging_decorator.cc index 118b976e7f1f6..1a77e9fe597c1 100644 --- a/google/cloud/aiplatform/v1/internal/match_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/match_logging_decorator.cc @@ -61,6 +61,63 @@ MatchServiceLogging::ReadIndexDatapoints( context, options, request, __func__, tracing_options_); } +StatusOr +MatchServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr MatchServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr MatchServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr MatchServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +MatchServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/match_logging_decorator.h b/google/cloud/aiplatform/v1/internal/match_logging_decorator.h index 9673caa3d7ece..7ac0348ab400d 100644 --- a/google/cloud/aiplatform/v1/internal/match_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/match_logging_decorator.h @@ -49,6 +49,26 @@ class MatchServiceLogging : public MatchServiceStub { google::cloud::aiplatform::v1::ReadIndexDatapointsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/aiplatform/v1/internal/match_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/match_metadata_decorator.cc index c9579341be4b5..ee2e2763bb4c3 100644 --- a/google/cloud/aiplatform/v1/internal/match_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/match_metadata_decorator.cc @@ -64,6 +64,51 @@ MatchServiceMetadata::ReadIndexDatapoints( return child_->ReadIndexDatapoints(context, options, request); } +StatusOr +MatchServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr MatchServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr MatchServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr MatchServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +MatchServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + void MatchServiceMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/aiplatform/v1/internal/match_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/match_metadata_decorator.h index 1740c5c88ff01..2972ac5b02fad 100644 --- a/google/cloud/aiplatform/v1/internal/match_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/match_metadata_decorator.h @@ -49,6 +49,26 @@ class MatchServiceMetadata : public MatchServiceStub { google::cloud::aiplatform::v1::ReadIndexDatapointsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/aiplatform/v1/internal/match_stub.cc b/google/cloud/aiplatform/v1/internal/match_stub.cc index 7d179088b5db7..2e3c1d5630a39 100644 --- a/google/cloud/aiplatform/v1/internal/match_stub.cc +++ b/google/cloud/aiplatform/v1/internal/match_stub.cc @@ -54,6 +54,65 @@ DefaultMatchServiceStub::ReadIndexDatapoints( return response; } +StatusOr +DefaultMatchServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultMatchServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultMatchServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultMatchServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultMatchServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/match_stub.h b/google/cloud/aiplatform/v1/internal/match_stub.h index 2d70b04f20e5f..57202550de4af 100644 --- a/google/cloud/aiplatform/v1/internal/match_stub.h +++ b/google/cloud/aiplatform/v1/internal/match_stub.h @@ -23,6 +23,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include @@ -45,6 +49,28 @@ class MatchServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::aiplatform::v1::ReadIndexDatapointsRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; }; class DefaultMatchServiceStub : public MatchServiceStub { @@ -52,8 +78,13 @@ class DefaultMatchServiceStub : public MatchServiceStub { explicit DefaultMatchServiceStub( std::unique_ptr< google::cloud::aiplatform::v1::MatchService::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr FindNeighbors( grpc::ClientContext& context, Options const& options, @@ -66,9 +97,32 @@ class DefaultMatchServiceStub : public MatchServiceStub { google::cloud::aiplatform::v1::ReadIndexDatapointsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/internal/match_stub_factory.cc b/google/cloud/aiplatform/v1/internal/match_stub_factory.cc index 0ec6adfd8fc00..84b9df71ced26 100644 --- a/google/cloud/aiplatform/v1/internal/match_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/match_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,8 +46,13 @@ std::shared_ptr CreateDefaultMatchServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::MatchService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + std::make_shared( + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), std::move(stub)); diff --git a/google/cloud/aiplatform/v1/internal/match_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/match_tracing_connection.cc index 6b82197039111..49fc6d9f9fd18 100644 --- a/google/cloud/aiplatform/v1/internal/match_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/match_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/aiplatform/v1/internal/match_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -50,6 +51,51 @@ MatchServiceTracingConnection::ReadIndexDatapoints( return internal::EndSpan(*span, child_->ReadIndexDatapoints(request)); } +StreamRange +MatchServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MatchServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +MatchServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("aiplatform_v1::MatchServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr MatchServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("aiplatform_v1::MatchServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr MatchServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("aiplatform_v1::MatchServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +MatchServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MatchServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/match_tracing_connection.h b/google/cloud/aiplatform/v1/internal/match_tracing_connection.h index 6f44b953941b0..6bae4616b0f18 100644 --- a/google/cloud/aiplatform/v1/internal/match_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/match_tracing_connection.h @@ -49,6 +49,21 @@ class MatchServiceTracingConnection google::cloud::aiplatform::v1::ReadIndexDatapointsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/aiplatform/v1/internal/match_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/match_tracing_stub.cc index 83d87dbe23721..c2906b3399280 100644 --- a/google/cloud/aiplatform/v1/internal/match_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/match_tracing_stub.cc @@ -56,6 +56,64 @@ MatchServiceTracingStub::ReadIndexDatapoints( context, *span, child_->ReadIndexDatapoints(context, options, request)); } +StatusOr +MatchServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.MatchService", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +MatchServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.MatchService", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr MatchServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.MatchService", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr MatchServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.MatchService", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +MatchServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.MatchService", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeMatchServiceTracingStub( diff --git a/google/cloud/aiplatform/v1/internal/match_tracing_stub.h b/google/cloud/aiplatform/v1/internal/match_tracing_stub.h index 0d55ede2ded54..158d078cd8116 100644 --- a/google/cloud/aiplatform/v1/internal/match_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/match_tracing_stub.h @@ -49,6 +49,26 @@ class MatchServiceTracingStub : public MatchServiceStub { google::cloud::aiplatform::v1::ReadIndexDatapointsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/metadata_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/metadata_auth_decorator.cc index 1431bf85552b8..751fba1a21384 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/metadata_auth_decorator.cc @@ -479,6 +479,48 @@ MetadataServiceAuth::QueryArtifactLineageSubgraph( return child_->QueryArtifactLineageSubgraph(context, options, request); } +StatusOr +MetadataServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr MetadataServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr MetadataServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr MetadataServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +MetadataServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> MetadataServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/metadata_auth_decorator.h b/google/cloud/aiplatform/v1/internal/metadata_auth_decorator.h index 04e8e931bbb24..ac1158721fd92 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/metadata_auth_decorator.h @@ -264,6 +264,26 @@ class MetadataServiceAuth : public MetadataServiceStub { google::cloud::aiplatform::v1::QueryArtifactLineageSubgraphRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/metadata_connection_impl.cc b/google/cloud/aiplatform/v1/internal/metadata_connection_impl.cc index cdc203e9e52b2..49ce1510f237c 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/metadata_connection_impl.cc @@ -1279,6 +1279,94 @@ MetadataServiceConnectionImpl::QueryArtifactLineageSubgraph( *current, request, __func__); } +StreamRange +MetadataServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +MetadataServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr MetadataServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr MetadataServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +MetadataServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/metadata_connection_impl.h b/google/cloud/aiplatform/v1/internal/metadata_connection_impl.h index 756681d3c6f4d..22f30e687fd33 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/metadata_connection_impl.h @@ -252,6 +252,21 @@ class MetadataServiceConnectionImpl google::cloud::aiplatform::v1::QueryArtifactLineageSubgraphRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/aiplatform/v1/internal/metadata_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/metadata_logging_decorator.cc index 8ee1247c157d7..b1a11fcce0912 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/metadata_logging_decorator.cc @@ -605,6 +605,63 @@ MetadataServiceLogging::QueryArtifactLineageSubgraph( context, options, request, __func__, tracing_options_); } +StatusOr +MetadataServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr MetadataServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr MetadataServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr MetadataServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +MetadataServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> MetadataServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/metadata_logging_decorator.h b/google/cloud/aiplatform/v1/internal/metadata_logging_decorator.h index 49d4dd4190542..a01f52adc3844 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/metadata_logging_decorator.h @@ -264,6 +264,26 @@ class MetadataServiceLogging : public MetadataServiceStub { google::cloud::aiplatform::v1::QueryArtifactLineageSubgraphRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/metadata_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/metadata_metadata_decorator.cc index e88614498daaa..ad19afcf80e53 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/metadata_metadata_decorator.cc @@ -438,6 +438,52 @@ MetadataServiceMetadata::QueryArtifactLineageSubgraph( return child_->QueryArtifactLineageSubgraph(context, options, request); } +StatusOr +MetadataServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +MetadataServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr MetadataServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr MetadataServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +MetadataServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> MetadataServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/metadata_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/metadata_metadata_decorator.h index 31501d269aa73..edfadbd209a3c 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/metadata_metadata_decorator.h @@ -265,6 +265,26 @@ class MetadataServiceMetadata : public MetadataServiceStub { google::cloud::aiplatform::v1::QueryArtifactLineageSubgraphRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/metadata_stub.cc b/google/cloud/aiplatform/v1/internal/metadata_stub.cc index e28d58b127995..cce3edad0919a 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_stub.cc +++ b/google/cloud/aiplatform/v1/internal/metadata_stub.cc @@ -576,6 +576,65 @@ DefaultMetadataServiceStub::QueryArtifactLineageSubgraph( return response; } +StatusOr +DefaultMetadataServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultMetadataServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultMetadataServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultMetadataServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultMetadataServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultMetadataServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/metadata_stub.h b/google/cloud/aiplatform/v1/internal/metadata_stub.h index 04099a3469983..52179f737a40b 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_stub.h +++ b/google/cloud/aiplatform/v1/internal/metadata_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -247,6 +251,28 @@ class MetadataServiceStub { google::cloud::aiplatform::v1::QueryArtifactLineageSubgraphRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -266,9 +292,15 @@ class DefaultMetadataServiceStub : public MetadataServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::MetadataService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateMetadataStore( google::cloud::CompletionQueue& cq, @@ -495,6 +527,26 @@ class DefaultMetadataServiceStub : public MetadataServiceStub { google::cloud::aiplatform::v1::QueryArtifactLineageSubgraphRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -510,6 +562,9 @@ class DefaultMetadataServiceStub : public MetadataServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/aiplatform/v1/internal/metadata_stub_factory.cc b/google/cloud/aiplatform/v1/internal/metadata_stub_factory.cc index b24dec2d01f4f..4647780f059b2 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/metadata_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultMetadataServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::MetadataService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/aiplatform/v1/internal/metadata_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/metadata_tracing_connection.cc index f8d4966ce362d..c3d5f7281e37a 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/metadata_tracing_connection.cc @@ -508,6 +508,53 @@ MetadataServiceTracingConnection::QueryArtifactLineageSubgraph( child_->QueryArtifactLineageSubgraph(request)); } +StreamRange +MetadataServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MetadataServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +MetadataServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MetadataServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +MetadataServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MetadataServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +MetadataServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MetadataServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +MetadataServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MetadataServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/metadata_tracing_connection.h b/google/cloud/aiplatform/v1/internal/metadata_tracing_connection.h index d6241cdcaebb7..dc9a6e74e7ccc 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/metadata_tracing_connection.h @@ -240,6 +240,21 @@ class MetadataServiceTracingConnection google::cloud::aiplatform::v1::QueryArtifactLineageSubgraphRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/aiplatform/v1/internal/metadata_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/metadata_tracing_stub.cc index 772b32319a74a..60b2c99cc6217 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/metadata_tracing_stub.cc @@ -548,6 +548,64 @@ MetadataServiceTracingStub::QueryArtifactLineageSubgraph( child_->QueryArtifactLineageSubgraph(context, options, request)); } +StatusOr +MetadataServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.MetadataService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +MetadataServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.MetadataService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr MetadataServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.MetadataService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr MetadataServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.MetadataService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +MetadataServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.MetadataService", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> MetadataServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/metadata_tracing_stub.h b/google/cloud/aiplatform/v1/internal/metadata_tracing_stub.h index dffb5de44ab79..5cf00f7b7d6de 100644 --- a/google/cloud/aiplatform/v1/internal/metadata_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/metadata_tracing_stub.h @@ -264,6 +264,26 @@ class MetadataServiceTracingStub : public MetadataServiceStub { google::cloud::aiplatform::v1::QueryArtifactLineageSubgraphRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/migration_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/migration_auth_decorator.cc index a11c7dae4646d..8fba96c0cd215 100644 --- a/google/cloud/aiplatform/v1/internal/migration_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/migration_auth_decorator.cc @@ -72,6 +72,48 @@ MigrationServiceAuth::BatchMigrateResources( return child_->BatchMigrateResources(context, options, request); } +StatusOr +MigrationServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr MigrationServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr MigrationServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr MigrationServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +MigrationServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> MigrationServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/migration_auth_decorator.h b/google/cloud/aiplatform/v1/internal/migration_auth_decorator.h index 78ef22c011126..65756f77d72d3 100644 --- a/google/cloud/aiplatform/v1/internal/migration_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/migration_auth_decorator.h @@ -57,6 +57,26 @@ class MigrationServiceAuth : public MigrationServiceStub { google::cloud::aiplatform::v1::BatchMigrateResourcesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/migration_connection_impl.cc b/google/cloud/aiplatform/v1/internal/migration_connection_impl.cc index 248198caabea4..204bd74c43f1b 100644 --- a/google/cloud/aiplatform/v1/internal/migration_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/migration_connection_impl.cc @@ -199,6 +199,94 @@ MigrationServiceConnectionImpl::BatchMigrateResources( polling_policy(*current), __func__); } +StreamRange +MigrationServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +MigrationServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr MigrationServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr MigrationServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +MigrationServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/migration_connection_impl.h b/google/cloud/aiplatform/v1/internal/migration_connection_impl.h index a15b5338d990f..77f0c7850eb00 100644 --- a/google/cloud/aiplatform/v1/internal/migration_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/migration_connection_impl.h @@ -71,6 +71,21 @@ class MigrationServiceConnectionImpl BatchMigrateResources( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/aiplatform/v1/internal/migration_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/migration_logging_decorator.cc index 05d1a83a0a903..066fe04e678ed 100644 --- a/google/cloud/aiplatform/v1/internal/migration_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/migration_logging_decorator.cc @@ -84,6 +84,64 @@ MigrationServiceLogging::BatchMigrateResources( context, options, request, __func__, tracing_options_); } +StatusOr +MigrationServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +MigrationServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr MigrationServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr MigrationServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +MigrationServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> MigrationServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/migration_logging_decorator.h b/google/cloud/aiplatform/v1/internal/migration_logging_decorator.h index c4a7514204188..6e7493c598ab5 100644 --- a/google/cloud/aiplatform/v1/internal/migration_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/migration_logging_decorator.h @@ -57,6 +57,26 @@ class MigrationServiceLogging : public MigrationServiceStub { google::cloud::aiplatform::v1::BatchMigrateResourcesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/migration_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/migration_metadata_decorator.cc index efc8b74167415..88b86cda5da73 100644 --- a/google/cloud/aiplatform/v1/internal/migration_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/migration_metadata_decorator.cc @@ -77,6 +77,52 @@ MigrationServiceMetadata::BatchMigrateResources( return child_->BatchMigrateResources(context, options, request); } +StatusOr +MigrationServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +MigrationServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr MigrationServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr MigrationServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +MigrationServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> MigrationServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/migration_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/migration_metadata_decorator.h index cfcaac1542974..3cae6aa4c5cee 100644 --- a/google/cloud/aiplatform/v1/internal/migration_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/migration_metadata_decorator.h @@ -58,6 +58,26 @@ class MigrationServiceMetadata : public MigrationServiceStub { google::cloud::aiplatform::v1::BatchMigrateResourcesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/migration_stub.cc b/google/cloud/aiplatform/v1/internal/migration_stub.cc index 0482ed9b3b646..5beb377c2071d 100644 --- a/google/cloud/aiplatform/v1/internal/migration_stub.cc +++ b/google/cloud/aiplatform/v1/internal/migration_stub.cc @@ -78,6 +78,65 @@ DefaultMigrationServiceStub::BatchMigrateResources( return response; } +StatusOr +DefaultMigrationServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultMigrationServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultMigrationServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultMigrationServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultMigrationServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultMigrationServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/migration_stub.h b/google/cloud/aiplatform/v1/internal/migration_stub.h index e33ef1cbd3c57..6756428709245 100644 --- a/google/cloud/aiplatform/v1/internal/migration_stub.h +++ b/google/cloud/aiplatform/v1/internal/migration_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -58,6 +62,28 @@ class MigrationServiceStub { google::cloud::aiplatform::v1::BatchMigrateResourcesRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -77,9 +103,15 @@ class DefaultMigrationServiceStub : public MigrationServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::MigrationService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr SearchMigratableResources( @@ -99,6 +131,26 @@ class DefaultMigrationServiceStub : public MigrationServiceStub { google::cloud::aiplatform::v1::BatchMigrateResourcesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -115,6 +167,9 @@ class DefaultMigrationServiceStub : public MigrationServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::MigrationService::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/aiplatform/v1/internal/migration_stub_factory.cc b/google/cloud/aiplatform/v1/internal/migration_stub_factory.cc index ee72b3856f45e..54efce9218a55 100644 --- a/google/cloud/aiplatform/v1/internal/migration_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/migration_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultMigrationServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::MigrationService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/aiplatform/v1/internal/migration_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/migration_tracing_connection.cc index f5bcba4c10d13..d100157186ec2 100644 --- a/google/cloud/aiplatform/v1/internal/migration_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/migration_tracing_connection.cc @@ -78,6 +78,53 @@ MigrationServiceTracingConnection::BatchMigrateResources( child_->BatchMigrateResources(operation)); } +StreamRange +MigrationServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MigrationServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +MigrationServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MigrationServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +MigrationServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MigrationServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +MigrationServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MigrationServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +MigrationServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::MigrationServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/migration_tracing_connection.h b/google/cloud/aiplatform/v1/internal/migration_tracing_connection.h index 35c7c256b3555..7f47982b20cba 100644 --- a/google/cloud/aiplatform/v1/internal/migration_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/migration_tracing_connection.h @@ -59,6 +59,21 @@ class MigrationServiceTracingConnection BatchMigrateResources( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/aiplatform/v1/internal/migration_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/migration_tracing_stub.cc index cdb2aee24bc74..0cbd45dd7706d 100644 --- a/google/cloud/aiplatform/v1/internal/migration_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/migration_tracing_stub.cc @@ -76,6 +76,64 @@ MigrationServiceTracingStub::BatchMigrateResources( context, *span, child_->BatchMigrateResources(context, options, request)); } +StatusOr +MigrationServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.MigrationService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +MigrationServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.MigrationService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr MigrationServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.MigrationService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr MigrationServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.MigrationService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +MigrationServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.MigrationService", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> MigrationServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/migration_tracing_stub.h b/google/cloud/aiplatform/v1/internal/migration_tracing_stub.h index 74a04718d04bc..6f70bf0efe32b 100644 --- a/google/cloud/aiplatform/v1/internal/migration_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/migration_tracing_stub.h @@ -57,6 +57,26 @@ class MigrationServiceTracingStub : public MigrationServiceStub { google::cloud::aiplatform::v1::BatchMigrateResourcesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/model_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/model_auth_decorator.cc index 455014eaa3b83..990337c646e1c 100644 --- a/google/cloud/aiplatform/v1/internal/model_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/model_auth_decorator.cc @@ -314,6 +314,48 @@ ModelServiceAuth::ListModelEvaluationSlices( return child_->ListModelEvaluationSlices(context, options, request); } +StatusOr +ModelServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr ModelServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr ModelServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr ModelServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +ModelServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> ModelServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/model_auth_decorator.h b/google/cloud/aiplatform/v1/internal/model_auth_decorator.h index 9ceb1b0b9f23b..198257dbe2fea 100644 --- a/google/cloud/aiplatform/v1/internal/model_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/model_auth_decorator.h @@ -177,6 +177,26 @@ class ModelServiceAuth : public ModelServiceStub { google::cloud::aiplatform::v1::ListModelEvaluationSlicesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/model_connection_impl.cc b/google/cloud/aiplatform/v1/internal/model_connection_impl.cc index 2b79c20d1f26c..63ea6be81de3d 100644 --- a/google/cloud/aiplatform/v1/internal/model_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/model_connection_impl.cc @@ -889,6 +889,94 @@ ModelServiceConnectionImpl::ListModelEvaluationSlices( }); } +StreamRange +ModelServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ModelServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr ModelServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr ModelServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +ModelServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/model_connection_impl.h b/google/cloud/aiplatform/v1/internal/model_connection_impl.h index 5f1656fd8287b..9ed3380c61620 100644 --- a/google/cloud/aiplatform/v1/internal/model_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/model_connection_impl.h @@ -180,6 +180,21 @@ class ModelServiceConnectionImpl google::cloud::aiplatform::v1::ListModelEvaluationSlicesRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/aiplatform/v1/internal/model_garden_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/model_garden_auth_decorator.cc index 1ba1f11e6d843..11fc38113c5ce 100644 --- a/google/cloud/aiplatform/v1/internal/model_garden_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/model_garden_auth_decorator.cc @@ -40,6 +40,48 @@ ModelGardenServiceAuth::GetPublisherModel( return child_->GetPublisherModel(context, options, request); } +StatusOr +ModelGardenServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr ModelGardenServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr ModelGardenServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr ModelGardenServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +ModelGardenServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/model_garden_auth_decorator.h b/google/cloud/aiplatform/v1/internal/model_garden_auth_decorator.h index 0dfb2106ac3a9..34cc543ce9230 100644 --- a/google/cloud/aiplatform/v1/internal/model_garden_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/model_garden_auth_decorator.h @@ -43,6 +43,26 @@ class ModelGardenServiceAuth : public ModelGardenServiceStub { google::cloud::aiplatform::v1::GetPublisherModelRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/aiplatform/v1/internal/model_garden_connection_impl.cc b/google/cloud/aiplatform/v1/internal/model_garden_connection_impl.cc index 5224faac72669..5552684896571 100644 --- a/google/cloud/aiplatform/v1/internal/model_garden_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/model_garden_connection_impl.cc @@ -21,6 +21,7 @@ #include "google/cloud/background_threads.h" #include "google/cloud/common_options.h" #include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/retry_loop.h" #include #include @@ -75,6 +76,96 @@ ModelGardenServiceConnectionImpl::GetPublisherModel( *current, request, __func__); } +StreamRange +ModelGardenServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ModelGardenServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +ModelGardenServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +ModelGardenServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +ModelGardenServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/model_garden_connection_impl.h b/google/cloud/aiplatform/v1/internal/model_garden_connection_impl.h index eb5b91468dd9d..8495cde90c16b 100644 --- a/google/cloud/aiplatform/v1/internal/model_garden_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/model_garden_connection_impl.h @@ -28,6 +28,7 @@ #include "google/cloud/backoff_policy.h" #include "google/cloud/options.h" #include "google/cloud/status_or.h" +#include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include @@ -52,6 +53,21 @@ class ModelGardenServiceConnectionImpl google::cloud::aiplatform::v1::GetPublisherModelRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/aiplatform/v1/internal/model_garden_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/model_garden_logging_decorator.cc index 25de3e4ed3a74..9cb39654e59ce 100644 --- a/google/cloud/aiplatform/v1/internal/model_garden_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/model_garden_logging_decorator.cc @@ -48,6 +48,64 @@ ModelGardenServiceLogging::GetPublisherModel( context, options, request, __func__, tracing_options_); } +StatusOr +ModelGardenServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ModelGardenServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ModelGardenServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ModelGardenServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ModelGardenServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/model_garden_logging_decorator.h b/google/cloud/aiplatform/v1/internal/model_garden_logging_decorator.h index 4fe8ab1b8202a..b038d35ba7da6 100644 --- a/google/cloud/aiplatform/v1/internal/model_garden_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/model_garden_logging_decorator.h @@ -43,6 +43,26 @@ class ModelGardenServiceLogging : public ModelGardenServiceStub { google::cloud::aiplatform::v1::GetPublisherModelRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/aiplatform/v1/internal/model_garden_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/model_garden_metadata_decorator.cc index 26fb677cf25a6..2a1be874f8144 100644 --- a/google/cloud/aiplatform/v1/internal/model_garden_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/model_garden_metadata_decorator.cc @@ -53,6 +53,52 @@ ModelGardenServiceMetadata::GetPublisherModel( return child_->GetPublisherModel(context, options, request); } +StatusOr +ModelGardenServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +ModelGardenServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr ModelGardenServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr ModelGardenServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +ModelGardenServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + void ModelGardenServiceMetadata::SetMetadata( grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/aiplatform/v1/internal/model_garden_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/model_garden_metadata_decorator.h index 231f4f0bac324..cca4e4f08ea3c 100644 --- a/google/cloud/aiplatform/v1/internal/model_garden_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/model_garden_metadata_decorator.h @@ -44,6 +44,26 @@ class ModelGardenServiceMetadata : public ModelGardenServiceStub { google::cloud::aiplatform::v1::GetPublisherModelRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/aiplatform/v1/internal/model_garden_stub.cc b/google/cloud/aiplatform/v1/internal/model_garden_stub.cc index ebf811e7ab1db..745aa81ef29b7 100644 --- a/google/cloud/aiplatform/v1/internal/model_garden_stub.cc +++ b/google/cloud/aiplatform/v1/internal/model_garden_stub.cc @@ -42,6 +42,65 @@ DefaultModelGardenServiceStub::GetPublisherModel( return response; } +StatusOr +DefaultModelGardenServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultModelGardenServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultModelGardenServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultModelGardenServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultModelGardenServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/model_garden_stub.h b/google/cloud/aiplatform/v1/internal/model_garden_stub.h index c07538397f9e1..5fbd5be3e70bd 100644 --- a/google/cloud/aiplatform/v1/internal/model_garden_stub.h +++ b/google/cloud/aiplatform/v1/internal/model_garden_stub.h @@ -23,6 +23,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include @@ -40,6 +44,28 @@ class ModelGardenServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::aiplatform::v1::GetPublisherModelRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; }; class DefaultModelGardenServiceStub : public ModelGardenServiceStub { @@ -47,18 +73,46 @@ class DefaultModelGardenServiceStub : public ModelGardenServiceStub { explicit DefaultModelGardenServiceStub( std::unique_ptr< google::cloud::aiplatform::v1::ModelGardenService::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr GetPublisherModel( grpc::ClientContext& context, Options const& options, google::cloud::aiplatform::v1::GetPublisherModelRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr< google::cloud::aiplatform::v1::ModelGardenService::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/internal/model_garden_stub_factory.cc b/google/cloud/aiplatform/v1/internal/model_garden_stub_factory.cc index fcb2ba48c7cc0..4e60f923549ee 100644 --- a/google/cloud/aiplatform/v1/internal/model_garden_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/model_garden_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultModelGardenServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::ModelGardenService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/aiplatform/v1/internal/model_garden_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/model_garden_tracing_connection.cc index d3fcbbf24dd3a..f92f5fcbd7e86 100644 --- a/google/cloud/aiplatform/v1/internal/model_garden_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/model_garden_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/aiplatform/v1/internal/model_garden_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -41,6 +42,53 @@ ModelGardenServiceTracingConnection::GetPublisherModel( return internal::EndSpan(*span, child_->GetPublisherModel(request)); } +StreamRange +ModelGardenServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ModelGardenServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ModelGardenServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ModelGardenServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +ModelGardenServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ModelGardenServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +ModelGardenServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ModelGardenServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +ModelGardenServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ModelGardenServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/model_garden_tracing_connection.h b/google/cloud/aiplatform/v1/internal/model_garden_tracing_connection.h index e02097d998615..cc3ef691024bb 100644 --- a/google/cloud/aiplatform/v1/internal/model_garden_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/model_garden_tracing_connection.h @@ -44,6 +44,21 @@ class ModelGardenServiceTracingConnection google::cloud::aiplatform::v1::GetPublisherModelRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/aiplatform/v1/internal/model_garden_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/model_garden_tracing_stub.cc index 4a04ef121a5d5..0bb8ee51a7389 100644 --- a/google/cloud/aiplatform/v1/internal/model_garden_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/model_garden_tracing_stub.cc @@ -44,6 +44,64 @@ ModelGardenServiceTracingStub::GetPublisherModel( context, *span, child_->GetPublisherModel(context, options, request)); } +StatusOr +ModelGardenServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.ModelGardenService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +ModelGardenServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.ModelGardenService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr ModelGardenServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.ModelGardenService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr ModelGardenServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.ModelGardenService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +ModelGardenServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.ModelGardenService", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeModelGardenServiceTracingStub( diff --git a/google/cloud/aiplatform/v1/internal/model_garden_tracing_stub.h b/google/cloud/aiplatform/v1/internal/model_garden_tracing_stub.h index adedeecb8e500..37d8bafe2e3d2 100644 --- a/google/cloud/aiplatform/v1/internal/model_garden_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/model_garden_tracing_stub.h @@ -44,6 +44,26 @@ class ModelGardenServiceTracingStub : public ModelGardenServiceStub { google::cloud::aiplatform::v1::GetPublisherModelRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/model_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/model_logging_decorator.cc index 56a51ff842808..3f3c8a2883d18 100644 --- a/google/cloud/aiplatform/v1/internal/model_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/model_logging_decorator.cc @@ -380,6 +380,63 @@ ModelServiceLogging::ListModelEvaluationSlices( context, options, request, __func__, tracing_options_); } +StatusOr +ModelServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ModelServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ModelServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ModelServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ModelServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ModelServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/model_logging_decorator.h b/google/cloud/aiplatform/v1/internal/model_logging_decorator.h index ea377332c0ccf..e653c2a5c2038 100644 --- a/google/cloud/aiplatform/v1/internal/model_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/model_logging_decorator.h @@ -177,6 +177,26 @@ class ModelServiceLogging : public ModelServiceStub { google::cloud::aiplatform::v1::ListModelEvaluationSlicesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/model_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/model_metadata_decorator.cc index cd6c207616f7b..833249b2c0790 100644 --- a/google/cloud/aiplatform/v1/internal/model_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/model_metadata_decorator.cc @@ -282,6 +282,51 @@ ModelServiceMetadata::ListModelEvaluationSlices( return child_->ListModelEvaluationSlices(context, options, request); } +StatusOr +ModelServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr ModelServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr ModelServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr ModelServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +ModelServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> ModelServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/model_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/model_metadata_decorator.h index 6b953d7f59c90..6f0d1b24e03bb 100644 --- a/google/cloud/aiplatform/v1/internal/model_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/model_metadata_decorator.h @@ -177,6 +177,26 @@ class ModelServiceMetadata : public ModelServiceStub { google::cloud::aiplatform::v1::ListModelEvaluationSlicesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/model_stub.cc b/google/cloud/aiplatform/v1/internal/model_stub.cc index 082625fba3ed8..c292520532d1f 100644 --- a/google/cloud/aiplatform/v1/internal/model_stub.cc +++ b/google/cloud/aiplatform/v1/internal/model_stub.cc @@ -369,6 +369,65 @@ DefaultModelServiceStub::ListModelEvaluationSlices( return response; } +StatusOr +DefaultModelServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultModelServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultModelServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultModelServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultModelServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultModelServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/model_stub.h b/google/cloud/aiplatform/v1/internal/model_stub.h index cf4760af0998f..8f70f280a6fd9 100644 --- a/google/cloud/aiplatform/v1/internal/model_stub.h +++ b/google/cloud/aiplatform/v1/internal/model_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -173,6 +177,28 @@ class ModelServiceStub { google::cloud::aiplatform::v1::ListModelEvaluationSlicesRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -192,9 +218,15 @@ class DefaultModelServiceStub : public ModelServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::ModelService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncUploadModel( google::cloud::CompletionQueue& cq, @@ -334,6 +366,26 @@ class DefaultModelServiceStub : public ModelServiceStub { google::cloud::aiplatform::v1::ListModelEvaluationSlicesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -349,6 +401,9 @@ class DefaultModelServiceStub : public ModelServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/aiplatform/v1/internal/model_stub_factory.cc b/google/cloud/aiplatform/v1/internal/model_stub_factory.cc index 7d3a589b7da7f..a334e22da425c 100644 --- a/google/cloud/aiplatform/v1/internal/model_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/model_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultModelServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::ModelService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/aiplatform/v1/internal/model_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/model_tracing_connection.cc index f01ac57b59845..552a2c97c292a 100644 --- a/google/cloud/aiplatform/v1/internal/model_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/model_tracing_connection.cc @@ -337,6 +337,51 @@ ModelServiceTracingConnection::ListModelEvaluationSlices( std::move(sr)); } +StreamRange +ModelServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ModelServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ModelServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("aiplatform_v1::ModelServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr ModelServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("aiplatform_v1::ModelServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr ModelServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("aiplatform_v1::ModelServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +ModelServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ModelServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/model_tracing_connection.h b/google/cloud/aiplatform/v1/internal/model_tracing_connection.h index 3e5e23b1f7cbe..e45c517a8c831 100644 --- a/google/cloud/aiplatform/v1/internal/model_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/model_tracing_connection.h @@ -168,6 +168,21 @@ class ModelServiceTracingConnection google::cloud::aiplatform::v1::ListModelEvaluationSlicesRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/aiplatform/v1/internal/model_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/model_tracing_stub.cc index dc1fb01ca329b..1429efa6aad21 100644 --- a/google/cloud/aiplatform/v1/internal/model_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/model_tracing_stub.cc @@ -343,6 +343,64 @@ ModelServiceTracingStub::ListModelEvaluationSlices( child_->ListModelEvaluationSlices(context, options, request)); } +StatusOr +ModelServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.ModelService", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +ModelServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.ModelService", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr ModelServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.ModelService", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr ModelServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.ModelService", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +ModelServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.ModelService", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> ModelServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/model_tracing_stub.h b/google/cloud/aiplatform/v1/internal/model_tracing_stub.h index db69417560561..f1a9d19ca5d76 100644 --- a/google/cloud/aiplatform/v1/internal/model_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/model_tracing_stub.h @@ -176,6 +176,26 @@ class ModelServiceTracingStub : public ModelServiceStub { google::cloud::aiplatform::v1::ListModelEvaluationSlicesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/notebook_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/notebook_auth_decorator.cc index 99b43f5bd6187..9a733eeedeedb 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/notebook_auth_decorator.cc @@ -345,6 +345,48 @@ NotebookServiceAuth::DeleteNotebookExecutionJob( return child_->DeleteNotebookExecutionJob(context, options, request); } +StatusOr +NotebookServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr NotebookServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr NotebookServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr NotebookServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +NotebookServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> NotebookServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/notebook_auth_decorator.h b/google/cloud/aiplatform/v1/internal/notebook_auth_decorator.h index b8cdc58d4f44d..8666115fdc7bc 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/notebook_auth_decorator.h @@ -180,6 +180,26 @@ class NotebookServiceAuth : public NotebookServiceStub { google::cloud::aiplatform::v1::DeleteNotebookExecutionJobRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/notebook_connection_impl.cc b/google/cloud/aiplatform/v1/internal/notebook_connection_impl.cc index 77492c4bfde59..e73949218f665 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/notebook_connection_impl.cc @@ -1003,6 +1003,94 @@ NotebookServiceConnectionImpl::DeleteNotebookExecutionJob( polling_policy(*current), __func__); } +StreamRange +NotebookServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +NotebookServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr NotebookServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr NotebookServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +NotebookServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/notebook_connection_impl.h b/google/cloud/aiplatform/v1/internal/notebook_connection_impl.h index ef179292ec2f0..faaf71292c83e 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/notebook_connection_impl.h @@ -200,6 +200,21 @@ class NotebookServiceConnectionImpl DeleteNotebookExecutionJob( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/aiplatform/v1/internal/notebook_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/notebook_logging_decorator.cc index 3801622023295..5f2ed096e2188 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/notebook_logging_decorator.cc @@ -403,6 +403,63 @@ NotebookServiceLogging::DeleteNotebookExecutionJob( context, options, request, __func__, tracing_options_); } +StatusOr +NotebookServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr NotebookServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr NotebookServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr NotebookServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +NotebookServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> NotebookServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/notebook_logging_decorator.h b/google/cloud/aiplatform/v1/internal/notebook_logging_decorator.h index 5858753824bf0..bc6d8f81853e1 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/notebook_logging_decorator.h @@ -180,6 +180,26 @@ class NotebookServiceLogging : public NotebookServiceStub { google::cloud::aiplatform::v1::DeleteNotebookExecutionJobRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/notebook_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/notebook_metadata_decorator.cc index 282809b0a9e85..6643cf279545f 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/notebook_metadata_decorator.cc @@ -296,6 +296,52 @@ NotebookServiceMetadata::DeleteNotebookExecutionJob( return child_->DeleteNotebookExecutionJob(context, options, request); } +StatusOr +NotebookServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +NotebookServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr NotebookServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr NotebookServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +NotebookServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> NotebookServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/notebook_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/notebook_metadata_decorator.h index d287b8da500f8..ace36f63f5abd 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/notebook_metadata_decorator.h @@ -181,6 +181,26 @@ class NotebookServiceMetadata : public NotebookServiceStub { google::cloud::aiplatform::v1::DeleteNotebookExecutionJobRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/notebook_stub.cc b/google/cloud/aiplatform/v1/internal/notebook_stub.cc index 9ea7fe3ee6687..ece9a49f269be 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_stub.cc +++ b/google/cloud/aiplatform/v1/internal/notebook_stub.cc @@ -396,6 +396,65 @@ DefaultNotebookServiceStub::DeleteNotebookExecutionJob( return response; } +StatusOr +DefaultNotebookServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultNotebookServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultNotebookServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultNotebookServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultNotebookServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultNotebookServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/notebook_stub.h b/google/cloud/aiplatform/v1/internal/notebook_stub.h index e1c660bdf60fe..96d364db5ee64 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_stub.h +++ b/google/cloud/aiplatform/v1/internal/notebook_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -188,6 +192,28 @@ class NotebookServiceStub { google::cloud::aiplatform::v1::DeleteNotebookExecutionJobRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -207,9 +233,15 @@ class DefaultNotebookServiceStub : public NotebookServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::NotebookService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateNotebookRuntimeTemplate( @@ -352,6 +384,26 @@ class DefaultNotebookServiceStub : public NotebookServiceStub { google::cloud::aiplatform::v1::DeleteNotebookExecutionJobRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -367,6 +419,9 @@ class DefaultNotebookServiceStub : public NotebookServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/aiplatform/v1/internal/notebook_stub_factory.cc b/google/cloud/aiplatform/v1/internal/notebook_stub_factory.cc index 697bab6ef0c54..1e5767568ed36 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/notebook_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultNotebookServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::NotebookService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/aiplatform/v1/internal/notebook_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/notebook_tracing_connection.cc index f8772e47299cd..21ed0bad5390c 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/notebook_tracing_connection.cc @@ -379,6 +379,53 @@ NotebookServiceTracingConnection::DeleteNotebookExecutionJob( child_->DeleteNotebookExecutionJob(operation)); } +StreamRange +NotebookServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::NotebookServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +NotebookServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::NotebookServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +NotebookServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::NotebookServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +NotebookServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::NotebookServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +NotebookServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::NotebookServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/notebook_tracing_connection.h b/google/cloud/aiplatform/v1/internal/notebook_tracing_connection.h index 3a83b6798c89a..bba36b9157dec 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/notebook_tracing_connection.h @@ -188,6 +188,21 @@ class NotebookServiceTracingConnection DeleteNotebookExecutionJob( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/aiplatform/v1/internal/notebook_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/notebook_tracing_stub.cc index 4f608f9c9e74d..c99a375fd8450 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/notebook_tracing_stub.cc @@ -373,6 +373,64 @@ NotebookServiceTracingStub::DeleteNotebookExecutionJob( child_->DeleteNotebookExecutionJob(context, options, request)); } +StatusOr +NotebookServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.NotebookService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +NotebookServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.NotebookService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr NotebookServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.NotebookService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr NotebookServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.NotebookService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +NotebookServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.NotebookService", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> NotebookServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/notebook_tracing_stub.h b/google/cloud/aiplatform/v1/internal/notebook_tracing_stub.h index b991d180f661d..ae96c1aac66b0 100644 --- a/google/cloud/aiplatform/v1/internal/notebook_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/notebook_tracing_stub.h @@ -180,6 +180,26 @@ class NotebookServiceTracingStub : public NotebookServiceStub { google::cloud::aiplatform::v1::DeleteNotebookExecutionJobRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/persistent_resource_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/persistent_resource_auth_decorator.cc index 941aceb57ed11..57c4e4af1e053 100644 --- a/google/cloud/aiplatform/v1/internal/persistent_resource_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/persistent_resource_auth_decorator.cc @@ -175,6 +175,49 @@ PersistentResourceServiceAuth::RebootPersistentResource( return child_->RebootPersistentResource(context, options, request); } +StatusOr +PersistentResourceServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +PersistentResourceServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr PersistentResourceServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr PersistentResourceServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +PersistentResourceServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> PersistentResourceServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/persistent_resource_auth_decorator.h b/google/cloud/aiplatform/v1/internal/persistent_resource_auth_decorator.h index d42c748a33bdc..5742ae4365b2c 100644 --- a/google/cloud/aiplatform/v1/internal/persistent_resource_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/persistent_resource_auth_decorator.h @@ -103,6 +103,26 @@ class PersistentResourceServiceAuth : public PersistentResourceServiceStub { google::cloud::aiplatform::v1::RebootPersistentResourceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/persistent_resource_connection_impl.cc b/google/cloud/aiplatform/v1/internal/persistent_resource_connection_impl.cc index fadb6e14606ed..11dd18f5b5189 100644 --- a/google/cloud/aiplatform/v1/internal/persistent_resource_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/persistent_resource_connection_impl.cc @@ -516,6 +516,97 @@ PersistentResourceServiceConnectionImpl::RebootPersistentResource( polling_policy(*current), __func__); } +StreamRange +PersistentResourceServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = + std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +PersistentResourceServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +PersistentResourceServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +PersistentResourceServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +PersistentResourceServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/persistent_resource_connection_impl.h b/google/cloud/aiplatform/v1/internal/persistent_resource_connection_impl.h index 875813df5b8c8..85541dd19d72b 100644 --- a/google/cloud/aiplatform/v1/internal/persistent_resource_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/persistent_resource_connection_impl.h @@ -119,6 +119,21 @@ class PersistentResourceServiceConnectionImpl RebootPersistentResource( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/aiplatform/v1/internal/persistent_resource_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/persistent_resource_logging_decorator.cc index 697e0ef647bfd..222426fc32939 100644 --- a/google/cloud/aiplatform/v1/internal/persistent_resource_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/persistent_resource_logging_decorator.cc @@ -208,6 +208,66 @@ PersistentResourceServiceLogging::RebootPersistentResource( context, options, request, __func__, tracing_options_); } +StatusOr +PersistentResourceServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PersistentResourceServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PersistentResourceServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PersistentResourceServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PersistentResourceServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> PersistentResourceServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/persistent_resource_logging_decorator.h b/google/cloud/aiplatform/v1/internal/persistent_resource_logging_decorator.h index 309c9b8424a84..6eafe6a33b9f3 100644 --- a/google/cloud/aiplatform/v1/internal/persistent_resource_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/persistent_resource_logging_decorator.h @@ -103,6 +103,26 @@ class PersistentResourceServiceLogging : public PersistentResourceServiceStub { google::cloud::aiplatform::v1::RebootPersistentResourceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/persistent_resource_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/persistent_resource_metadata_decorator.cc index 55383e31d3c46..9d6111b6a2ebe 100644 --- a/google/cloud/aiplatform/v1/internal/persistent_resource_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/persistent_resource_metadata_decorator.cc @@ -160,6 +160,54 @@ PersistentResourceServiceMetadata::RebootPersistentResource( return child_->RebootPersistentResource(context, options, request); } +StatusOr +PersistentResourceServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +PersistentResourceServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr +PersistentResourceServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr +PersistentResourceServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +PersistentResourceServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> PersistentResourceServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/persistent_resource_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/persistent_resource_metadata_decorator.h index 0ec4672356f7c..02a8682791d0d 100644 --- a/google/cloud/aiplatform/v1/internal/persistent_resource_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/persistent_resource_metadata_decorator.h @@ -104,6 +104,26 @@ class PersistentResourceServiceMetadata : public PersistentResourceServiceStub { google::cloud::aiplatform::v1::RebootPersistentResourceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/persistent_resource_stub.cc b/google/cloud/aiplatform/v1/internal/persistent_resource_stub.cc index e0a0f44763940..4e548a2b98c6a 100644 --- a/google/cloud/aiplatform/v1/internal/persistent_resource_stub.cc +++ b/google/cloud/aiplatform/v1/internal/persistent_resource_stub.cc @@ -198,6 +198,67 @@ DefaultPersistentResourceServiceStub::RebootPersistentResource( return response; } +StatusOr +DefaultPersistentResourceServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPersistentResourceServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPersistentResourceServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPersistentResourceServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPersistentResourceServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultPersistentResourceServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/persistent_resource_stub.h b/google/cloud/aiplatform/v1/internal/persistent_resource_stub.h index 7f540f76c3c81..3ab0508d36437 100644 --- a/google/cloud/aiplatform/v1/internal/persistent_resource_stub.h +++ b/google/cloud/aiplatform/v1/internal/persistent_resource_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -103,6 +107,28 @@ class PersistentResourceServiceStub { google::cloud::aiplatform::v1::RebootPersistentResourceRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -123,9 +149,15 @@ class DefaultPersistentResourceServiceStub std::unique_ptr grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreatePersistentResource( @@ -191,6 +223,26 @@ class DefaultPersistentResourceServiceStub google::cloud::aiplatform::v1::RebootPersistentResourceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -207,6 +259,9 @@ class DefaultPersistentResourceServiceStub std::unique_ptr< google::cloud::aiplatform::v1::PersistentResourceService::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/aiplatform/v1/internal/persistent_resource_stub_factory.cc b/google/cloud/aiplatform/v1/internal/persistent_resource_stub_factory.cc index 48ed9239e04fa..481730538055b 100644 --- a/google/cloud/aiplatform/v1/internal/persistent_resource_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/persistent_resource_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -46,9 +48,13 @@ CreateDefaultPersistentResourceServiceStub( auto service_grpc_stub = google::cloud::aiplatform::v1::PersistentResourceService::NewStub( channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/aiplatform/v1/internal/persistent_resource_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/persistent_resource_tracing_connection.cc index c030e1d110069..95f46cfa9bb8e 100644 --- a/google/cloud/aiplatform/v1/internal/persistent_resource_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/persistent_resource_tracing_connection.cc @@ -203,6 +203,53 @@ PersistentResourceServiceTracingConnection::RebootPersistentResource( child_->RebootPersistentResource(operation)); } +StreamRange +PersistentResourceServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PersistentResourceServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +PersistentResourceServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PersistentResourceServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +PersistentResourceServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PersistentResourceServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +PersistentResourceServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PersistentResourceServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +PersistentResourceServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PersistentResourceServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/persistent_resource_tracing_connection.h b/google/cloud/aiplatform/v1/internal/persistent_resource_tracing_connection.h index 0ed8de2478e5b..a86529183a751 100644 --- a/google/cloud/aiplatform/v1/internal/persistent_resource_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/persistent_resource_tracing_connection.h @@ -107,6 +107,21 @@ class PersistentResourceServiceTracingConnection RebootPersistentResource( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/aiplatform/v1/internal/persistent_resource_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/persistent_resource_tracing_stub.cc index 725435c558107..cdb0ca9d3513c 100644 --- a/google/cloud/aiplatform/v1/internal/persistent_resource_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/persistent_resource_tracing_stub.cc @@ -189,6 +189,67 @@ PersistentResourceServiceTracingStub::RebootPersistentResource( child_->RebootPersistentResource(context, options, request)); } +StatusOr +PersistentResourceServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PersistentResourceService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +PersistentResourceServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PersistentResourceService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr +PersistentResourceServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PersistentResourceService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr +PersistentResourceServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PersistentResourceService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +PersistentResourceServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PersistentResourceService", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> PersistentResourceServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/persistent_resource_tracing_stub.h b/google/cloud/aiplatform/v1/internal/persistent_resource_tracing_stub.h index 6c5889428bb58..bbfd2fd7c8572 100644 --- a/google/cloud/aiplatform/v1/internal/persistent_resource_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/persistent_resource_tracing_stub.h @@ -104,6 +104,26 @@ class PersistentResourceServiceTracingStub google::cloud::aiplatform::v1::RebootPersistentResourceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/pipeline_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/pipeline_auth_decorator.cc index 4a7ff1c96b2dd..b09bab0004904 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/pipeline_auth_decorator.cc @@ -225,6 +225,48 @@ PipelineServiceAuth::BatchCancelPipelineJobs( return child_->BatchCancelPipelineJobs(context, options, request); } +StatusOr +PipelineServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr PipelineServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr PipelineServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr PipelineServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +PipelineServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> PipelineServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/pipeline_auth_decorator.h b/google/cloud/aiplatform/v1/internal/pipeline_auth_decorator.h index 865c01a8c45ea..881d81e2ed1ab 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/pipeline_auth_decorator.h @@ -129,6 +129,26 @@ class PipelineServiceAuth : public PipelineServiceStub { google::cloud::aiplatform::v1::BatchCancelPipelineJobsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/pipeline_connection_impl.cc b/google/cloud/aiplatform/v1/internal/pipeline_connection_impl.cc index 2f41cac3a6801..d7ff4ac3df02d 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/pipeline_connection_impl.cc @@ -611,6 +611,94 @@ PipelineServiceConnectionImpl::BatchCancelPipelineJobs( polling_policy(*current), __func__); } +StreamRange +PipelineServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +PipelineServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr PipelineServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr PipelineServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +PipelineServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/pipeline_connection_impl.h b/google/cloud/aiplatform/v1/internal/pipeline_connection_impl.h index 9c3f8d7509944..9f565049a588a 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/pipeline_connection_impl.h @@ -144,6 +144,21 @@ class PipelineServiceConnectionImpl BatchCancelPipelineJobs( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/aiplatform/v1/internal/pipeline_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/pipeline_logging_decorator.cc index 7d11a82963ee6..4630c54d774c9 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/pipeline_logging_decorator.cc @@ -278,6 +278,63 @@ PipelineServiceLogging::BatchCancelPipelineJobs( context, options, request, __func__, tracing_options_); } +StatusOr +PipelineServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr PipelineServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr PipelineServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr PipelineServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PipelineServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> PipelineServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/pipeline_logging_decorator.h b/google/cloud/aiplatform/v1/internal/pipeline_logging_decorator.h index 3275d4caedd4c..1a4bd13500fa4 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/pipeline_logging_decorator.h @@ -129,6 +129,26 @@ class PipelineServiceLogging : public PipelineServiceStub { google::cloud::aiplatform::v1::BatchCancelPipelineJobsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/pipeline_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/pipeline_metadata_decorator.cc index edc69d03342f6..b7e597747131d 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/pipeline_metadata_decorator.cc @@ -207,6 +207,52 @@ PipelineServiceMetadata::BatchCancelPipelineJobs( return child_->BatchCancelPipelineJobs(context, options, request); } +StatusOr +PipelineServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +PipelineServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr PipelineServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr PipelineServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +PipelineServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> PipelineServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/pipeline_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/pipeline_metadata_decorator.h index 1e86c5ec7836e..86b1393e103c0 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/pipeline_metadata_decorator.h @@ -130,6 +130,26 @@ class PipelineServiceMetadata : public PipelineServiceStub { google::cloud::aiplatform::v1::BatchCancelPipelineJobsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/pipeline_stub.cc b/google/cloud/aiplatform/v1/internal/pipeline_stub.cc index 6a4e774bf1053..3369fe57054e2 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_stub.cc +++ b/google/cloud/aiplatform/v1/internal/pipeline_stub.cc @@ -265,6 +265,65 @@ DefaultPipelineServiceStub::BatchCancelPipelineJobs( return response; } +StatusOr +DefaultPipelineServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPipelineServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultPipelineServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultPipelineServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPipelineServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultPipelineServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/pipeline_stub.h b/google/cloud/aiplatform/v1/internal/pipeline_stub.h index 14e3935108ad6..1f6e46366efb7 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_stub.h +++ b/google/cloud/aiplatform/v1/internal/pipeline_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -133,6 +137,28 @@ class PipelineServiceStub { google::cloud::aiplatform::v1::BatchCancelPipelineJobsRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -152,9 +178,15 @@ class DefaultPipelineServiceStub : public PipelineServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::PipelineService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr CreateTrainingPipeline( @@ -246,6 +278,26 @@ class DefaultPipelineServiceStub : public PipelineServiceStub { google::cloud::aiplatform::v1::BatchCancelPipelineJobsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -261,6 +313,9 @@ class DefaultPipelineServiceStub : public PipelineServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/aiplatform/v1/internal/pipeline_stub_factory.cc b/google/cloud/aiplatform/v1/internal/pipeline_stub_factory.cc index 6f80d4c8536a2..40d0ca501f47f 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/pipeline_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultPipelineServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::PipelineService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/aiplatform/v1/internal/pipeline_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/pipeline_tracing_connection.cc index 6c0613adb6c2b..f73ab3e89677f 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/pipeline_tracing_connection.cc @@ -240,6 +240,53 @@ PipelineServiceTracingConnection::BatchCancelPipelineJobs( child_->BatchCancelPipelineJobs(operation)); } +StreamRange +PipelineServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PipelineServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +PipelineServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PipelineServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +PipelineServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PipelineServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +PipelineServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PipelineServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +PipelineServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PipelineServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/pipeline_tracing_connection.h b/google/cloud/aiplatform/v1/internal/pipeline_tracing_connection.h index 706983d1ef75e..994fc9ee1a5fa 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/pipeline_tracing_connection.h @@ -132,6 +132,21 @@ class PipelineServiceTracingConnection BatchCancelPipelineJobs( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/aiplatform/v1/internal/pipeline_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/pipeline_tracing_stub.cc index 4c2b11d2de4cf..d97720f3080ec 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/pipeline_tracing_stub.cc @@ -248,6 +248,64 @@ PipelineServiceTracingStub::BatchCancelPipelineJobs( child_->BatchCancelPipelineJobs(context, options, request)); } +StatusOr +PipelineServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PipelineService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +PipelineServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PipelineService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr PipelineServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PipelineService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr PipelineServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PipelineService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +PipelineServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PipelineService", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> PipelineServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/pipeline_tracing_stub.h b/google/cloud/aiplatform/v1/internal/pipeline_tracing_stub.h index 1c3199155291f..f4479df209a55 100644 --- a/google/cloud/aiplatform/v1/internal/pipeline_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/pipeline_tracing_stub.h @@ -129,6 +129,26 @@ class PipelineServiceTracingStub : public PipelineServiceStub { google::cloud::aiplatform::v1::BatchCancelPipelineJobsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/prediction_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/prediction_auth_decorator.cc index 9ce0a09e263f6..49294662682fc 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/prediction_auth_decorator.cc @@ -197,6 +197,48 @@ PredictionServiceAuth::StreamGenerateContent( return child_->StreamGenerateContent(std::move(context), options, request); } +StatusOr +PredictionServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr PredictionServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr PredictionServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr PredictionServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +PredictionServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/prediction_auth_decorator.h b/google/cloud/aiplatform/v1/internal/prediction_auth_decorator.h index aacae555793f2..babcb7eb99d05 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/prediction_auth_decorator.h @@ -118,6 +118,26 @@ class PredictionServiceAuth : public PredictionServiceStub { google::cloud::aiplatform::v1::GenerateContentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/aiplatform/v1/internal/prediction_connection_impl.cc b/google/cloud/aiplatform/v1/internal/prediction_connection_impl.cc index d255c2cbe3830..17b21ba6f4c04 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/prediction_connection_impl.cc @@ -21,6 +21,7 @@ #include "google/cloud/background_threads.h" #include "google/cloud/common_options.h" #include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/resumable_streaming_read_rpc.h" #include "google/cloud/internal/retry_loop.h" #include "google/cloud/internal/streaming_read_rpc_logging.h" @@ -261,6 +262,94 @@ PredictionServiceConnectionImpl::StreamGenerateContent( [resumable] { return resumable->Read(); })); } +StreamRange +PredictionServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +PredictionServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr PredictionServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr PredictionServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +PredictionServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/prediction_connection_impl.h b/google/cloud/aiplatform/v1/internal/prediction_connection_impl.h index ff74598c3f161..7a667dd67a72d 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/prediction_connection_impl.h @@ -117,6 +117,21 @@ class PredictionServiceConnectionImpl google::cloud::aiplatform::v1::GenerateContentRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/aiplatform/v1/internal/prediction_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/prediction_logging_decorator.cc index 3cf01762b02fb..e7c84b2884772 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/prediction_logging_decorator.cc @@ -280,6 +280,64 @@ PredictionServiceLogging::StreamGenerateContent( std::move(context), options, request, __func__, tracing_options_); } +StatusOr +PredictionServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PredictionServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr PredictionServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr PredictionServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PredictionServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/prediction_logging_decorator.h b/google/cloud/aiplatform/v1/internal/prediction_logging_decorator.h index b065fbb29b0e2..9c6704e16d35f 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/prediction_logging_decorator.h @@ -118,6 +118,26 @@ class PredictionServiceLogging : public PredictionServiceStub { google::cloud::aiplatform::v1::GenerateContentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/aiplatform/v1/internal/prediction_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/prediction_metadata_decorator.cc index 663bbcabe56d6..1025f705e046b 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/prediction_metadata_decorator.cc @@ -182,6 +182,52 @@ PredictionServiceMetadata::StreamGenerateContent( return child_->StreamGenerateContent(std::move(context), options, request); } +StatusOr +PredictionServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +PredictionServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr PredictionServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr PredictionServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +PredictionServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + void PredictionServiceMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/aiplatform/v1/internal/prediction_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/prediction_metadata_decorator.h index 34932d1a2f1cb..f8889fd527f89 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/prediction_metadata_decorator.h @@ -119,6 +119,26 @@ class PredictionServiceMetadata : public PredictionServiceStub { google::cloud::aiplatform::v1::GenerateContentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/aiplatform/v1/internal/prediction_stub.cc b/google/cloud/aiplatform/v1/internal/prediction_stub.cc index 0d3b3467ad4dc..a65de9835670f 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_stub.cc +++ b/google/cloud/aiplatform/v1/internal/prediction_stub.cc @@ -199,6 +199,65 @@ DefaultPredictionServiceStub::StreamGenerateContent( std::move(context), std::move(stream)); } +StatusOr +DefaultPredictionServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPredictionServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultPredictionServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultPredictionServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPredictionServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/prediction_stub.h b/google/cloud/aiplatform/v1/internal/prediction_stub.h index e3268fa6df95d..0a3a0213ff937 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_stub.h +++ b/google/cloud/aiplatform/v1/internal/prediction_stub.h @@ -26,6 +26,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include @@ -115,6 +119,28 @@ class PredictionServiceStub { StreamGenerateContent( std::shared_ptr context, Options const& options, google::cloud::aiplatform::v1::GenerateContentRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; }; class DefaultPredictionServiceStub : public PredictionServiceStub { @@ -122,8 +148,13 @@ class DefaultPredictionServiceStub : public PredictionServiceStub { explicit DefaultPredictionServiceStub( std::unique_ptr< google::cloud::aiplatform::v1::PredictionService::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr Predict( grpc::ClientContext& context, Options const& options, @@ -205,10 +236,33 @@ class DefaultPredictionServiceStub : public PredictionServiceStub { google::cloud::aiplatform::v1::GenerateContentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr< google::cloud::aiplatform::v1::PredictionService::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/internal/prediction_stub_factory.cc b/google/cloud/aiplatform/v1/internal/prediction_stub_factory.cc index 1ca0e5c27c3c0..d776652d96da1 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/prediction_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultPredictionServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::PredictionService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/aiplatform/v1/internal/prediction_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/prediction_tracing_connection.cc index e248323852163..b33ff4b91884f 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/prediction_tracing_connection.cc @@ -146,6 +146,53 @@ PredictionServiceTracingConnection::StreamGenerateContent( google::cloud::aiplatform::v1::GenerateContentResponse>(std::move(span), std::move(sr)); } +StreamRange +PredictionServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PredictionServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +PredictionServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PredictionServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +PredictionServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PredictionServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +PredictionServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PredictionServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +PredictionServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::PredictionServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/prediction_tracing_connection.h b/google/cloud/aiplatform/v1/internal/prediction_tracing_connection.h index b6d928fe5ad01..35282515e8ca1 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/prediction_tracing_connection.h @@ -95,6 +95,21 @@ class PredictionServiceTracingConnection google::cloud::aiplatform::v1::GenerateContentRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/aiplatform/v1/internal/prediction_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/prediction_tracing_stub.cc index 2c17db4b3c46b..57e49c1bc75af 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/prediction_tracing_stub.cc @@ -221,6 +221,64 @@ PredictionServiceTracingStub::StreamGenerateContent( std::move(context), std::move(stream), std::move(span)); } +StatusOr +PredictionServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PredictionService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +PredictionServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PredictionService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr PredictionServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PredictionService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr PredictionServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PredictionService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +PredictionServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.PredictionService", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakePredictionServiceTracingStub( diff --git a/google/cloud/aiplatform/v1/internal/prediction_tracing_stub.h b/google/cloud/aiplatform/v1/internal/prediction_tracing_stub.h index 06f033632f3df..54130418efc8a 100644 --- a/google/cloud/aiplatform/v1/internal/prediction_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/prediction_tracing_stub.h @@ -119,6 +119,26 @@ class PredictionServiceTracingStub : public PredictionServiceStub { google::cloud::aiplatform::v1::GenerateContentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/schedule_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/schedule_auth_decorator.cc index d2fc4445901d2..06cb232e7b185 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/schedule_auth_decorator.cc @@ -111,6 +111,48 @@ ScheduleServiceAuth::UpdateSchedule( return child_->UpdateSchedule(context, options, request); } +StatusOr +ScheduleServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr ScheduleServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr ScheduleServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr ScheduleServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +ScheduleServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> ScheduleServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/schedule_auth_decorator.h b/google/cloud/aiplatform/v1/internal/schedule_auth_decorator.h index 6ece2c1c23537..aaaad7e5997f0 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/schedule_auth_decorator.h @@ -81,6 +81,26 @@ class ScheduleServiceAuth : public ScheduleServiceStub { google::cloud::aiplatform::v1::UpdateScheduleRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/schedule_connection_impl.cc b/google/cloud/aiplatform/v1/internal/schedule_connection_impl.cc index 790118c60823a..a32dc78e1b23a 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/schedule_connection_impl.cc @@ -266,6 +266,94 @@ ScheduleServiceConnectionImpl::UpdateSchedule( *current, request, __func__); } +StreamRange +ScheduleServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ScheduleServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr ScheduleServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr ScheduleServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +ScheduleServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/schedule_connection_impl.h b/google/cloud/aiplatform/v1/internal/schedule_connection_impl.h index af216c1df88f2..6f1168e300536 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/schedule_connection_impl.h @@ -87,6 +87,21 @@ class ScheduleServiceConnectionImpl google::cloud::aiplatform::v1::UpdateScheduleRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/aiplatform/v1/internal/schedule_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/schedule_logging_decorator.cc index c2146984a1612..f5a529f7415d6 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/schedule_logging_decorator.cc @@ -141,6 +141,63 @@ ScheduleServiceLogging::UpdateSchedule( context, options, request, __func__, tracing_options_); } +StatusOr +ScheduleServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ScheduleServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ScheduleServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ScheduleServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ScheduleServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ScheduleServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/schedule_logging_decorator.h b/google/cloud/aiplatform/v1/internal/schedule_logging_decorator.h index 1093c9e80c67c..df03f7db5f7d2 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/schedule_logging_decorator.h @@ -81,6 +81,26 @@ class ScheduleServiceLogging : public ScheduleServiceStub { google::cloud::aiplatform::v1::UpdateScheduleRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/schedule_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/schedule_metadata_decorator.cc index 8c25a4555c943..781b34e73ff1d 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/schedule_metadata_decorator.cc @@ -118,6 +118,52 @@ ScheduleServiceMetadata::UpdateSchedule( return child_->UpdateSchedule(context, options, request); } +StatusOr +ScheduleServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +ScheduleServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr ScheduleServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr ScheduleServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +ScheduleServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> ScheduleServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/schedule_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/schedule_metadata_decorator.h index 50850da60bd8e..0d666669fee0e 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/schedule_metadata_decorator.h @@ -82,6 +82,26 @@ class ScheduleServiceMetadata : public ScheduleServiceStub { google::cloud::aiplatform::v1::UpdateScheduleRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/schedule_stub.cc b/google/cloud/aiplatform/v1/internal/schedule_stub.cc index 6c750fdc7f358..713a54ac0fe4e 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_stub.cc +++ b/google/cloud/aiplatform/v1/internal/schedule_stub.cc @@ -132,6 +132,65 @@ DefaultScheduleServiceStub::UpdateSchedule( return response; } +StatusOr +DefaultScheduleServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultScheduleServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultScheduleServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultScheduleServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultScheduleServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultScheduleServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/schedule_stub.h b/google/cloud/aiplatform/v1/internal/schedule_stub.h index 6dea12c5fc145..7d704c5134f88 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_stub.h +++ b/google/cloud/aiplatform/v1/internal/schedule_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -73,6 +77,28 @@ class ScheduleServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::aiplatform::v1::UpdateScheduleRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -92,9 +118,15 @@ class DefaultScheduleServiceStub : public ScheduleServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::ScheduleService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr CreateSchedule( grpc::ClientContext& context, Options const& options, @@ -138,6 +170,26 @@ class DefaultScheduleServiceStub : public ScheduleServiceStub { google::cloud::aiplatform::v1::UpdateScheduleRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -153,6 +205,9 @@ class DefaultScheduleServiceStub : public ScheduleServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/aiplatform/v1/internal/schedule_stub_factory.cc b/google/cloud/aiplatform/v1/internal/schedule_stub_factory.cc index 9422c7b024de3..02df54ddbdd88 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/schedule_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultScheduleServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::ScheduleService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/aiplatform/v1/internal/schedule_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/schedule_tracing_connection.cc index 1000e2486f352..98d4166fb9336 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/schedule_tracing_connection.cc @@ -116,6 +116,53 @@ ScheduleServiceTracingConnection::UpdateSchedule( return internal::EndSpan(*span, child_->UpdateSchedule(request)); } +StreamRange +ScheduleServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ScheduleServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ScheduleServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ScheduleServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +ScheduleServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ScheduleServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +ScheduleServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ScheduleServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +ScheduleServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::ScheduleServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/schedule_tracing_connection.h b/google/cloud/aiplatform/v1/internal/schedule_tracing_connection.h index 261d83aeeaac3..75b87a89d33b6 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/schedule_tracing_connection.h @@ -75,6 +75,21 @@ class ScheduleServiceTracingConnection google::cloud::aiplatform::v1::UpdateScheduleRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/aiplatform/v1/internal/schedule_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/schedule_tracing_stub.cc index 558b35f2033d7..a6c12c1ea70d4 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/schedule_tracing_stub.cc @@ -129,6 +129,64 @@ ScheduleServiceTracingStub::UpdateSchedule( child_->UpdateSchedule(context, options, request)); } +StatusOr +ScheduleServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.ScheduleService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +ScheduleServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.ScheduleService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr ScheduleServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.ScheduleService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr ScheduleServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.ScheduleService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +ScheduleServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.ScheduleService", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> ScheduleServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/schedule_tracing_stub.h b/google/cloud/aiplatform/v1/internal/schedule_tracing_stub.h index 376eeee2c59dd..2567b0211475a 100644 --- a/google/cloud/aiplatform/v1/internal/schedule_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/schedule_tracing_stub.h @@ -81,6 +81,26 @@ class ScheduleServiceTracingStub : public ScheduleServiceStub { google::cloud::aiplatform::v1::UpdateScheduleRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/specialist_pool_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/specialist_pool_auth_decorator.cc index 0bf781b1e30a8..6112c6b311e37 100644 --- a/google/cloud/aiplatform/v1/internal/specialist_pool_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/specialist_pool_auth_decorator.cc @@ -136,6 +136,49 @@ SpecialistPoolServiceAuth::UpdateSpecialistPool( return child_->UpdateSpecialistPool(context, options, request); } +StatusOr +SpecialistPoolServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +SpecialistPoolServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr SpecialistPoolServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr SpecialistPoolServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +SpecialistPoolServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> SpecialistPoolServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/specialist_pool_auth_decorator.h b/google/cloud/aiplatform/v1/internal/specialist_pool_auth_decorator.h index a43033ef4dc76..6d33607856939 100644 --- a/google/cloud/aiplatform/v1/internal/specialist_pool_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/specialist_pool_auth_decorator.h @@ -86,6 +86,26 @@ class SpecialistPoolServiceAuth : public SpecialistPoolServiceStub { google::cloud::aiplatform::v1::UpdateSpecialistPoolRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/specialist_pool_connection_impl.cc b/google/cloud/aiplatform/v1/internal/specialist_pool_connection_impl.cc index a549d8cd919d2..58068fd6a0b4f 100644 --- a/google/cloud/aiplatform/v1/internal/specialist_pool_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/specialist_pool_connection_impl.cc @@ -400,6 +400,96 @@ SpecialistPoolServiceConnectionImpl::UpdateSpecialistPool( polling_policy(*current), __func__); } +StreamRange +SpecialistPoolServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +SpecialistPoolServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +SpecialistPoolServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +SpecialistPoolServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +SpecialistPoolServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/specialist_pool_connection_impl.h b/google/cloud/aiplatform/v1/internal/specialist_pool_connection_impl.h index 628b169be2332..3a5dc38bb5af2 100644 --- a/google/cloud/aiplatform/v1/internal/specialist_pool_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/specialist_pool_connection_impl.h @@ -102,6 +102,21 @@ class SpecialistPoolServiceConnectionImpl UpdateSpecialistPool( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/aiplatform/v1/internal/specialist_pool_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/specialist_pool_logging_decorator.cc index 6290b47363c92..de55c4023141b 100644 --- a/google/cloud/aiplatform/v1/internal/specialist_pool_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/specialist_pool_logging_decorator.cc @@ -157,6 +157,64 @@ SpecialistPoolServiceLogging::UpdateSpecialistPool( context, options, request, __func__, tracing_options_); } +StatusOr +SpecialistPoolServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +SpecialistPoolServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr SpecialistPoolServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr SpecialistPoolServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +SpecialistPoolServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> SpecialistPoolServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/specialist_pool_logging_decorator.h b/google/cloud/aiplatform/v1/internal/specialist_pool_logging_decorator.h index 2f399b9c516b9..59c29560b8c22 100644 --- a/google/cloud/aiplatform/v1/internal/specialist_pool_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/specialist_pool_logging_decorator.h @@ -86,6 +86,26 @@ class SpecialistPoolServiceLogging : public SpecialistPoolServiceStub { google::cloud::aiplatform::v1::UpdateSpecialistPoolRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/specialist_pool_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/specialist_pool_metadata_decorator.cc index 641009acb4371..4fb524a425297 100644 --- a/google/cloud/aiplatform/v1/internal/specialist_pool_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/specialist_pool_metadata_decorator.cc @@ -129,6 +129,52 @@ SpecialistPoolServiceMetadata::UpdateSpecialistPool( return child_->UpdateSpecialistPool(context, options, request); } +StatusOr +SpecialistPoolServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +SpecialistPoolServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr SpecialistPoolServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr SpecialistPoolServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +SpecialistPoolServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> SpecialistPoolServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/specialist_pool_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/specialist_pool_metadata_decorator.h index a089f77f78e37..504e7e70d70a2 100644 --- a/google/cloud/aiplatform/v1/internal/specialist_pool_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/specialist_pool_metadata_decorator.h @@ -87,6 +87,26 @@ class SpecialistPoolServiceMetadata : public SpecialistPoolServiceStub { google::cloud::aiplatform::v1::UpdateSpecialistPoolRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/specialist_pool_stub.cc b/google/cloud/aiplatform/v1/internal/specialist_pool_stub.cc index aa0697a0ca65c..4bd1e00fa394f 100644 --- a/google/cloud/aiplatform/v1/internal/specialist_pool_stub.cc +++ b/google/cloud/aiplatform/v1/internal/specialist_pool_stub.cc @@ -148,6 +148,67 @@ DefaultSpecialistPoolServiceStub::UpdateSpecialistPool( return response; } +StatusOr +DefaultSpecialistPoolServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultSpecialistPoolServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultSpecialistPoolServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultSpecialistPoolServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultSpecialistPoolServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultSpecialistPoolServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/specialist_pool_stub.h b/google/cloud/aiplatform/v1/internal/specialist_pool_stub.h index d6c757716306a..32f34b5349517 100644 --- a/google/cloud/aiplatform/v1/internal/specialist_pool_stub.h +++ b/google/cloud/aiplatform/v1/internal/specialist_pool_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -89,6 +93,28 @@ class SpecialistPoolServiceStub { google::cloud::aiplatform::v1::UpdateSpecialistPoolRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -108,9 +134,15 @@ class DefaultSpecialistPoolServiceStub : public SpecialistPoolServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::SpecialistPoolService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateSpecialistPool( google::cloud::CompletionQueue& cq, @@ -159,6 +191,26 @@ class DefaultSpecialistPoolServiceStub : public SpecialistPoolServiceStub { google::cloud::aiplatform::v1::UpdateSpecialistPoolRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -175,6 +227,9 @@ class DefaultSpecialistPoolServiceStub : public SpecialistPoolServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::SpecialistPoolService::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/aiplatform/v1/internal/specialist_pool_stub_factory.cc b/google/cloud/aiplatform/v1/internal/specialist_pool_stub_factory.cc index 767d4889eb486..1c28afd86b311 100644 --- a/google/cloud/aiplatform/v1/internal/specialist_pool_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/specialist_pool_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -45,9 +47,13 @@ CreateDefaultSpecialistPoolServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::SpecialistPoolService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/aiplatform/v1/internal/specialist_pool_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/specialist_pool_tracing_connection.cc index 31e2946189a33..d908756949b44 100644 --- a/google/cloud/aiplatform/v1/internal/specialist_pool_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/specialist_pool_tracing_connection.cc @@ -147,6 +147,53 @@ SpecialistPoolServiceTracingConnection::UpdateSpecialistPool( child_->UpdateSpecialistPool(operation)); } +StreamRange +SpecialistPoolServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::SpecialistPoolServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SpecialistPoolServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::SpecialistPoolServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +SpecialistPoolServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::SpecialistPoolServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +SpecialistPoolServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::SpecialistPoolServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +SpecialistPoolServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::SpecialistPoolServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/specialist_pool_tracing_connection.h b/google/cloud/aiplatform/v1/internal/specialist_pool_tracing_connection.h index 113e98be0eca7..fe769649a67c0 100644 --- a/google/cloud/aiplatform/v1/internal/specialist_pool_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/specialist_pool_tracing_connection.h @@ -90,6 +90,21 @@ class SpecialistPoolServiceTracingConnection UpdateSpecialistPool( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/aiplatform/v1/internal/specialist_pool_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/specialist_pool_tracing_stub.cc index c31c512f65640..cafcc0fbda484 100644 --- a/google/cloud/aiplatform/v1/internal/specialist_pool_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/specialist_pool_tracing_stub.cc @@ -144,6 +144,66 @@ SpecialistPoolServiceTracingStub::UpdateSpecialistPool( context, *span, child_->UpdateSpecialistPool(context, options, request)); } +StatusOr +SpecialistPoolServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.SpecialistPoolService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +SpecialistPoolServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.SpecialistPoolService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr +SpecialistPoolServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.SpecialistPoolService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr +SpecialistPoolServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.SpecialistPoolService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +SpecialistPoolServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.SpecialistPoolService", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> SpecialistPoolServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/specialist_pool_tracing_stub.h b/google/cloud/aiplatform/v1/internal/specialist_pool_tracing_stub.h index db4398d3d26cc..6c62d52d75c6f 100644 --- a/google/cloud/aiplatform/v1/internal/specialist_pool_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/specialist_pool_tracing_stub.h @@ -86,6 +86,26 @@ class SpecialistPoolServiceTracingStub : public SpecialistPoolServiceStub { google::cloud::aiplatform::v1::UpdateSpecialistPoolRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/tensorboard_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/tensorboard_auth_decorator.cc index 3a6531bcf387f..3a7a13ce7ada9 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/tensorboard_auth_decorator.cc @@ -446,6 +446,48 @@ TensorboardServiceAuth::ExportTensorboardTimeSeriesData( return child_->ExportTensorboardTimeSeriesData(context, options, request); } +StatusOr +TensorboardServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr TensorboardServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr TensorboardServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr TensorboardServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +TensorboardServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> TensorboardServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/tensorboard_auth_decorator.h b/google/cloud/aiplatform/v1/internal/tensorboard_auth_decorator.h index 77984cbaf9e57..121c530f547cb 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/tensorboard_auth_decorator.h @@ -257,6 +257,26 @@ class TensorboardServiceAuth : public TensorboardServiceStub { google::cloud::aiplatform::v1:: ExportTensorboardTimeSeriesDataRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/tensorboard_connection_impl.cc b/google/cloud/aiplatform/v1/internal/tensorboard_connection_impl.cc index 73bbf52f7a5fd..39e77dc7ccf70 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/tensorboard_connection_impl.cc @@ -1132,6 +1132,96 @@ TensorboardServiceConnectionImpl::ExportTensorboardTimeSeriesData( }); } +StreamRange +TensorboardServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +TensorboardServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +TensorboardServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +TensorboardServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +TensorboardServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/tensorboard_connection_impl.h b/google/cloud/aiplatform/v1/internal/tensorboard_connection_impl.h index 130672fd731c0..6c34f15907015 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/tensorboard_connection_impl.h @@ -254,6 +254,21 @@ class TensorboardServiceConnectionImpl google::cloud::aiplatform::v1::ExportTensorboardTimeSeriesDataRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/aiplatform/v1/internal/tensorboard_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/tensorboard_logging_decorator.cc index 9c63def60e3da..462df93d120a2 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/tensorboard_logging_decorator.cc @@ -586,6 +586,64 @@ TensorboardServiceLogging::ExportTensorboardTimeSeriesData( context, options, request, __func__, tracing_options_); } +StatusOr +TensorboardServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +TensorboardServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr TensorboardServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr TensorboardServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +TensorboardServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> TensorboardServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/tensorboard_logging_decorator.h b/google/cloud/aiplatform/v1/internal/tensorboard_logging_decorator.h index a2b9f6a71de48..330d46f92495d 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/tensorboard_logging_decorator.h @@ -257,6 +257,26 @@ class TensorboardServiceLogging : public TensorboardServiceStub { google::cloud::aiplatform::v1:: ExportTensorboardTimeSeriesDataRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/tensorboard_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/tensorboard_metadata_decorator.cc index 69eb71689a1c5..1f2fad57ca0c9 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/tensorboard_metadata_decorator.cc @@ -428,6 +428,52 @@ TensorboardServiceMetadata::ExportTensorboardTimeSeriesData( return child_->ExportTensorboardTimeSeriesData(context, options, request); } +StatusOr +TensorboardServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +TensorboardServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr TensorboardServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr TensorboardServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +TensorboardServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> TensorboardServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/tensorboard_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/tensorboard_metadata_decorator.h index d2ddaaf9db523..6eea0d0b97a4a 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/tensorboard_metadata_decorator.h @@ -258,6 +258,26 @@ class TensorboardServiceMetadata : public TensorboardServiceStub { google::cloud::aiplatform::v1:: ExportTensorboardTimeSeriesDataRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/tensorboard_stub.cc b/google/cloud/aiplatform/v1/internal/tensorboard_stub.cc index 6631baf079436..68b9158dce6c7 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_stub.cc +++ b/google/cloud/aiplatform/v1/internal/tensorboard_stub.cc @@ -549,6 +549,65 @@ DefaultTensorboardServiceStub::ExportTensorboardTimeSeriesData( return response; } +StatusOr +DefaultTensorboardServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultTensorboardServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultTensorboardServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultTensorboardServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultTensorboardServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultTensorboardServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/tensorboard_stub.h b/google/cloud/aiplatform/v1/internal/tensorboard_stub.h index 24b2791f1e777..d02cb933aa82d 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_stub.h +++ b/google/cloud/aiplatform/v1/internal/tensorboard_stub.h @@ -26,6 +26,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -268,6 +272,28 @@ class TensorboardServiceStub { google::cloud::aiplatform::v1:: ExportTensorboardTimeSeriesDataRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -287,9 +313,15 @@ class DefaultTensorboardServiceStub : public TensorboardServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::TensorboardService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateTensorboard( google::cloud::CompletionQueue& cq, @@ -509,6 +541,26 @@ class DefaultTensorboardServiceStub : public TensorboardServiceStub { google::cloud::aiplatform::v1:: ExportTensorboardTimeSeriesDataRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -525,6 +577,9 @@ class DefaultTensorboardServiceStub : public TensorboardServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::TensorboardService::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/aiplatform/v1/internal/tensorboard_stub_factory.cc b/google/cloud/aiplatform/v1/internal/tensorboard_stub_factory.cc index a193c5652043d..e3b32947cce10 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/tensorboard_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultTensorboardServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::TensorboardService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/aiplatform/v1/internal/tensorboard_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/tensorboard_tracing_connection.cc index d8c5de3d7d1b7..7e484bdb9ffb6 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/tensorboard_tracing_connection.cc @@ -490,6 +490,53 @@ TensorboardServiceTracingConnection::ExportTensorboardTimeSeriesData( std::move(sr)); } +StreamRange +TensorboardServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::TensorboardServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +TensorboardServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::TensorboardServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +TensorboardServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::TensorboardServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +TensorboardServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::TensorboardServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +TensorboardServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::TensorboardServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/tensorboard_tracing_connection.h b/google/cloud/aiplatform/v1/internal/tensorboard_tracing_connection.h index 38d14580263f7..5f8bdb036d474 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/tensorboard_tracing_connection.h @@ -237,6 +237,21 @@ class TensorboardServiceTracingConnection google::cloud::aiplatform::v1::ExportTensorboardTimeSeriesDataRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/aiplatform/v1/internal/tensorboard_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/tensorboard_tracing_stub.cc index e1db183e53fcb..7c3f31b3acaf4 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/tensorboard_tracing_stub.cc @@ -545,6 +545,64 @@ TensorboardServiceTracingStub::ExportTensorboardTimeSeriesData( child_->ExportTensorboardTimeSeriesData(context, options, request)); } +StatusOr +TensorboardServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.TensorboardService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +TensorboardServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.TensorboardService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr TensorboardServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.TensorboardService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr TensorboardServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.TensorboardService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +TensorboardServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.aiplatform.v1.TensorboardService", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> TensorboardServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/tensorboard_tracing_stub.h b/google/cloud/aiplatform/v1/internal/tensorboard_tracing_stub.h index c7da8fe886992..ad96332e4236d 100644 --- a/google/cloud/aiplatform/v1/internal/tensorboard_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/tensorboard_tracing_stub.h @@ -257,6 +257,26 @@ class TensorboardServiceTracingStub : public TensorboardServiceStub { google::cloud::aiplatform::v1:: ExportTensorboardTimeSeriesDataRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/vizier_auth_decorator.cc b/google/cloud/aiplatform/v1/internal/vizier_auth_decorator.cc index 61bbc5b5366a1..7fbce1f3d3cc9 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_auth_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/vizier_auth_decorator.cc @@ -198,6 +198,48 @@ VizierServiceAuth::ListOptimalTrials( return child_->ListOptimalTrials(context, options, request); } +StatusOr +VizierServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr VizierServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr VizierServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr VizierServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +VizierServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> VizierServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/vizier_auth_decorator.h b/google/cloud/aiplatform/v1/internal/vizier_auth_decorator.h index 82c3202597169..debce5d1d754a 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_auth_decorator.h +++ b/google/cloud/aiplatform/v1/internal/vizier_auth_decorator.h @@ -124,6 +124,26 @@ class VizierServiceAuth : public VizierServiceStub { google::cloud::aiplatform::v1::ListOptimalTrialsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/vizier_connection_impl.cc b/google/cloud/aiplatform/v1/internal/vizier_connection_impl.cc index 6a35f8c70e7bb..8e310144cb345 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_connection_impl.cc +++ b/google/cloud/aiplatform/v1/internal/vizier_connection_impl.cc @@ -479,6 +479,94 @@ VizierServiceConnectionImpl::ListOptimalTrials( *current, request, __func__); } +StreamRange +VizierServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +VizierServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr VizierServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr VizierServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +VizierServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1_internal } // namespace cloud diff --git a/google/cloud/aiplatform/v1/internal/vizier_connection_impl.h b/google/cloud/aiplatform/v1/internal/vizier_connection_impl.h index fd8453a8d1c02..8b5e345b2cf7f 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_connection_impl.h +++ b/google/cloud/aiplatform/v1/internal/vizier_connection_impl.h @@ -126,6 +126,21 @@ class VizierServiceConnectionImpl google::cloud::aiplatform::v1::ListOptimalTrialsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/aiplatform/v1/internal/vizier_logging_decorator.cc b/google/cloud/aiplatform/v1/internal/vizier_logging_decorator.cc index dfe77ccc66f5f..86e6d4bed5ce7 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_logging_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/vizier_logging_decorator.cc @@ -254,6 +254,63 @@ VizierServiceLogging::ListOptimalTrials( context, options, request, __func__, tracing_options_); } +StatusOr +VizierServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr VizierServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr VizierServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr VizierServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +VizierServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> VizierServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/vizier_logging_decorator.h b/google/cloud/aiplatform/v1/internal/vizier_logging_decorator.h index 00bffaa2e139a..539bd2e92bd92 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_logging_decorator.h +++ b/google/cloud/aiplatform/v1/internal/vizier_logging_decorator.h @@ -124,6 +124,26 @@ class VizierServiceLogging : public VizierServiceStub { google::cloud::aiplatform::v1::ListOptimalTrialsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/vizier_metadata_decorator.cc b/google/cloud/aiplatform/v1/internal/vizier_metadata_decorator.cc index df93de5fc02eb..67d6d765fd048 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_metadata_decorator.cc +++ b/google/cloud/aiplatform/v1/internal/vizier_metadata_decorator.cc @@ -202,6 +202,51 @@ VizierServiceMetadata::ListOptimalTrials( return child_->ListOptimalTrials(context, options, request); } +StatusOr +VizierServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr VizierServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr VizierServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr VizierServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +VizierServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> VizierServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/vizier_metadata_decorator.h b/google/cloud/aiplatform/v1/internal/vizier_metadata_decorator.h index 9a17bcf174212..ce47b19b64d6e 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_metadata_decorator.h +++ b/google/cloud/aiplatform/v1/internal/vizier_metadata_decorator.h @@ -124,6 +124,26 @@ class VizierServiceMetadata : public VizierServiceStub { google::cloud::aiplatform::v1::ListOptimalTrialsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/internal/vizier_stub.cc b/google/cloud/aiplatform/v1/internal/vizier_stub.cc index 6ee8b65c5db96..35fd3e8956c63 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_stub.cc +++ b/google/cloud/aiplatform/v1/internal/vizier_stub.cc @@ -250,6 +250,65 @@ DefaultVizierServiceStub::ListOptimalTrials( return response; } +StatusOr +DefaultVizierServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultVizierServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultVizierServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultVizierServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultVizierServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultVizierServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/vizier_stub.h b/google/cloud/aiplatform/v1/internal/vizier_stub.h index 3b0e1a78d5f3e..cfa1da85273d1 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_stub.h +++ b/google/cloud/aiplatform/v1/internal/vizier_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -118,6 +122,28 @@ class VizierServiceStub { google::cloud::aiplatform::v1::ListOptimalTrialsRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -137,9 +163,15 @@ class DefaultVizierServiceStub : public VizierServiceStub { std::unique_ptr< google::cloud::aiplatform::v1::VizierService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr CreateStudy( grpc::ClientContext& context, Options const& options, @@ -226,6 +258,26 @@ class DefaultVizierServiceStub : public VizierServiceStub { google::cloud::aiplatform::v1::ListOptimalTrialsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -241,6 +293,9 @@ class DefaultVizierServiceStub : public VizierServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/aiplatform/v1/internal/vizier_stub_factory.cc b/google/cloud/aiplatform/v1/internal/vizier_stub_factory.cc index 39cd72537a125..25874e891e935 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_stub_factory.cc +++ b/google/cloud/aiplatform/v1/internal/vizier_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultVizierServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::aiplatform::v1::VizierService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/aiplatform/v1/internal/vizier_tracing_connection.cc b/google/cloud/aiplatform/v1/internal/vizier_tracing_connection.cc index e1cb829c7daa9..213c0b4ed5924 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_tracing_connection.cc +++ b/google/cloud/aiplatform/v1/internal/vizier_tracing_connection.cc @@ -215,6 +215,51 @@ VizierServiceTracingConnection::ListOptimalTrials( return internal::EndSpan(*span, child_->ListOptimalTrials(request)); } +StreamRange +VizierServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "aiplatform_v1::VizierServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +VizierServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("aiplatform_v1::VizierServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr VizierServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::VizierServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr VizierServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::VizierServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +VizierServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "aiplatform_v1::VizierServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/aiplatform/v1/internal/vizier_tracing_connection.h b/google/cloud/aiplatform/v1/internal/vizier_tracing_connection.h index 50bf9275a5c4a..d5b0a74a011ff 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_tracing_connection.h +++ b/google/cloud/aiplatform/v1/internal/vizier_tracing_connection.h @@ -114,6 +114,21 @@ class VizierServiceTracingConnection google::cloud::aiplatform::v1::ListOptimalTrialsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/aiplatform/v1/internal/vizier_tracing_stub.cc b/google/cloud/aiplatform/v1/internal/vizier_tracing_stub.cc index abb25ddc7492b..3ad4f7503f88d 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_tracing_stub.cc +++ b/google/cloud/aiplatform/v1/internal/vizier_tracing_stub.cc @@ -242,6 +242,64 @@ VizierServiceTracingStub::ListOptimalTrials( context, *span, child_->ListOptimalTrials(context, options, request)); } +StatusOr +VizierServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.VizierService", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +VizierServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.VizierService", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr VizierServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.VizierService", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr VizierServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.VizierService", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +VizierServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.aiplatform.v1.VizierService", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> VizierServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/aiplatform/v1/internal/vizier_tracing_stub.h b/google/cloud/aiplatform/v1/internal/vizier_tracing_stub.h index 652c223596c12..916fa74c39bb2 100644 --- a/google/cloud/aiplatform/v1/internal/vizier_tracing_stub.h +++ b/google/cloud/aiplatform/v1/internal/vizier_tracing_stub.h @@ -123,6 +123,26 @@ class VizierServiceTracingStub : public VizierServiceStub { google::cloud::aiplatform::v1::ListOptimalTrialsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/aiplatform/v1/job_client.cc b/google/cloud/aiplatform/v1/job_client.cc index 30836f8d78c95..d6dda0e6634b4 100644 --- a/google/cloud/aiplatform/v1/job_client.cc +++ b/google/cloud/aiplatform/v1/job_client.cc @@ -830,6 +830,37 @@ Status JobServiceClient::ResumeModelDeploymentMonitoringJob( return connection_->ResumeModelDeploymentMonitoringJob(request); } +StreamRange JobServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr JobServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr JobServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr JobServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +JobServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/job_client.h b/google/cloud/aiplatform/v1/job_client.h index 9e635efae738f..e2d5973203f35 100644 --- a/google/cloud/aiplatform/v1/job_client.h +++ b/google/cloud/aiplatform/v1/job_client.h @@ -2840,6 +2840,178 @@ class JobServiceClient { ResumeModelDeploymentMonitoringJobRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/job_connection.cc b/google/cloud/aiplatform/v1/job_connection.cc index 797660938e901..4ac6cf1b95320 100644 --- a/google/cloud/aiplatform/v1/job_connection.cc +++ b/google/cloud/aiplatform/v1/job_connection.cc @@ -385,6 +385,35 @@ Status JobServiceConnection::ResumeModelDeploymentMonitoringJob( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +JobServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr JobServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr JobServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr JobServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +JobServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeJobServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include +#include #include #include #include @@ -406,6 +408,21 @@ class JobServiceConnection { virtual Status ResumeModelDeploymentMonitoringJob( google::cloud::aiplatform::v1:: ResumeModelDeploymentMonitoringJobRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/job_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/job_connection_idempotency_policy.cc index 8877c800e34bd..816966bd700b2 100644 --- a/google/cloud/aiplatform/v1/job_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/job_connection_idempotency_policy.cc @@ -232,6 +232,32 @@ JobServiceConnectionIdempotencyPolicy::ResumeModelDeploymentMonitoringJob( return Idempotency::kNonIdempotent; } +Idempotency JobServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency JobServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency JobServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency JobServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency JobServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultJobServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/aiplatform/v1/job_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/job_connection_idempotency_policy.h index 6d6db34cfbc91..d8c4ebc5e293d 100644 --- a/google/cloud/aiplatform/v1/job_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/job_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -161,6 +163,21 @@ class JobServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ResumeModelDeploymentMonitoringJob( google::cloud::aiplatform::v1:: ResumeModelDeploymentMonitoringJobRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/aiplatform/v1/llm_utility_client.cc b/google/cloud/aiplatform/v1/llm_utility_client.cc index 5e1e6a7912355..93ceee837dab1 100644 --- a/google/cloud/aiplatform/v1/llm_utility_client.cc +++ b/google/cloud/aiplatform/v1/llm_utility_client.cc @@ -70,6 +70,39 @@ LlmUtilityServiceClient::ComputeTokens( return connection_->ComputeTokens(request); } +StreamRange +LlmUtilityServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +LlmUtilityServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr LlmUtilityServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr LlmUtilityServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +LlmUtilityServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/llm_utility_client.h b/google/cloud/aiplatform/v1/llm_utility_client.h index 45962864248d8..eb9dfbb01a9e1 100644 --- a/google/cloud/aiplatform/v1/llm_utility_client.h +++ b/google/cloud/aiplatform/v1/llm_utility_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -208,6 +209,178 @@ class LlmUtilityServiceClient { google::cloud::aiplatform::v1::ComputeTokensRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/llm_utility_connection.cc b/google/cloud/aiplatform/v1/llm_utility_connection.cc index 68dd226f9c536..2ef8f5149e00b 100644 --- a/google/cloud/aiplatform/v1/llm_utility_connection.cc +++ b/google/cloud/aiplatform/v1/llm_utility_connection.cc @@ -26,6 +26,7 @@ #include "google/cloud/common_options.h" #include "google/cloud/credentials.h" #include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/unified_grpc_credentials.h" #include #include @@ -49,6 +50,36 @@ LlmUtilityServiceConnection::ComputeTokens( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +LlmUtilityServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +LlmUtilityServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr LlmUtilityServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr LlmUtilityServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +LlmUtilityServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeLlmUtilityServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include +#include #include #include @@ -189,6 +192,21 @@ class LlmUtilityServiceConnection { virtual StatusOr ComputeTokens( google::cloud::aiplatform::v1::ComputeTokensRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/llm_utility_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/llm_utility_connection_idempotency_policy.cc index 16ee4a6c782e0..82d35d5df4a31 100644 --- a/google/cloud/aiplatform/v1/llm_utility_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/llm_utility_connection_idempotency_policy.cc @@ -44,6 +44,32 @@ Idempotency LlmUtilityServiceConnectionIdempotencyPolicy::ComputeTokens( return Idempotency::kNonIdempotent; } +Idempotency LlmUtilityServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency LlmUtilityServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency LlmUtilityServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency LlmUtilityServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency LlmUtilityServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultLlmUtilityServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/aiplatform/v1/llm_utility_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/llm_utility_connection_idempotency_policy.h index 1f4f2469f8a71..63395c57bac8f 100644 --- a/google/cloud/aiplatform/v1/llm_utility_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/llm_utility_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -42,6 +44,21 @@ class LlmUtilityServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ComputeTokens( google::cloud::aiplatform::v1::ComputeTokensRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/aiplatform/v1/match_client.cc b/google/cloud/aiplatform/v1/match_client.cc index 7065038ade2d2..4063a68ca5976 100644 --- a/google/cloud/aiplatform/v1/match_client.cc +++ b/google/cloud/aiplatform/v1/match_client.cc @@ -48,6 +48,38 @@ MatchServiceClient::ReadIndexDatapoints( return connection_->ReadIndexDatapoints(request); } +StreamRange +MatchServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr MatchServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr MatchServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr MatchServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +MatchServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/match_client.h b/google/cloud/aiplatform/v1/match_client.h index 7ad126a1b23ae..8f31dc8966f64 100644 --- a/google/cloud/aiplatform/v1/match_client.h +++ b/google/cloud/aiplatform/v1/match_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -150,6 +151,178 @@ class MatchServiceClient { google::cloud::aiplatform::v1::ReadIndexDatapointsRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/match_connection.cc b/google/cloud/aiplatform/v1/match_connection.cc index 29261c450d639..2445c124cbd86 100644 --- a/google/cloud/aiplatform/v1/match_connection.cc +++ b/google/cloud/aiplatform/v1/match_connection.cc @@ -26,6 +26,7 @@ #include "google/cloud/common_options.h" #include "google/cloud/credentials.h" #include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/unified_grpc_credentials.h" #include #include @@ -49,6 +50,35 @@ MatchServiceConnection::ReadIndexDatapoints( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +MatchServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr MatchServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr MatchServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr MatchServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +MatchServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeMatchServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include +#include #include #include @@ -189,6 +192,21 @@ class MatchServiceConnection { virtual StatusOr ReadIndexDatapoints( google::cloud::aiplatform::v1::ReadIndexDatapointsRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/match_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/match_connection_idempotency_policy.cc index 85eaae1cb55b1..a6f41c7c35b01 100644 --- a/google/cloud/aiplatform/v1/match_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/match_connection_idempotency_policy.cc @@ -44,6 +44,32 @@ Idempotency MatchServiceConnectionIdempotencyPolicy::ReadIndexDatapoints( return Idempotency::kNonIdempotent; } +Idempotency MatchServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency MatchServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency MatchServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency MatchServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency MatchServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultMatchServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/aiplatform/v1/match_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/match_connection_idempotency_policy.h index 2fcdbaca57ca1..fd114336638b2 100644 --- a/google/cloud/aiplatform/v1/match_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/match_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -42,6 +44,21 @@ class MatchServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ReadIndexDatapoints( google::cloud::aiplatform::v1::ReadIndexDatapointsRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/aiplatform/v1/metadata_client.cc b/google/cloud/aiplatform/v1/metadata_client.cc index 3dfe3926285a6..04fab85cedb48 100644 --- a/google/cloud/aiplatform/v1/metadata_client.cc +++ b/google/cloud/aiplatform/v1/metadata_client.cc @@ -802,6 +802,38 @@ MetadataServiceClient::QueryArtifactLineageSubgraph( return connection_->QueryArtifactLineageSubgraph(request); } +StreamRange +MetadataServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr MetadataServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr MetadataServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr MetadataServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +MetadataServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/metadata_client.h b/google/cloud/aiplatform/v1/metadata_client.h index ad7b40ae109d6..6c8df74c4d3e1 100644 --- a/google/cloud/aiplatform/v1/metadata_client.h +++ b/google/cloud/aiplatform/v1/metadata_client.h @@ -2653,6 +2653,178 @@ class MetadataServiceClient { request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/metadata_connection.cc b/google/cloud/aiplatform/v1/metadata_connection.cc index bec9f69bb14b9..641116f03025c 100644 --- a/google/cloud/aiplatform/v1/metadata_connection.cc +++ b/google/cloud/aiplatform/v1/metadata_connection.cc @@ -383,6 +383,36 @@ MetadataServiceConnection::QueryArtifactLineageSubgraph( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +MetadataServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +MetadataServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr MetadataServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr MetadataServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +MetadataServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeMetadataServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include +#include #include #include #include @@ -378,6 +380,21 @@ class MetadataServiceConnection { QueryArtifactLineageSubgraph( google::cloud::aiplatform::v1::QueryArtifactLineageSubgraphRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/metadata_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/metadata_connection_idempotency_policy.cc index 14e3b5cb9699d..549712fac9b3b 100644 --- a/google/cloud/aiplatform/v1/metadata_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/metadata_connection_idempotency_policy.cc @@ -200,6 +200,32 @@ MetadataServiceConnectionIdempotencyPolicy::QueryArtifactLineageSubgraph( return Idempotency::kIdempotent; } +Idempotency MetadataServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency MetadataServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency MetadataServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency MetadataServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency MetadataServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultMetadataServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/aiplatform/v1/metadata_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/metadata_connection_idempotency_policy.h index 02d96e8f07b5f..1fa99b87983d9 100644 --- a/google/cloud/aiplatform/v1/metadata_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/metadata_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -138,6 +140,21 @@ class MetadataServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency QueryArtifactLineageSubgraph( google::cloud::aiplatform::v1::QueryArtifactLineageSubgraphRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/aiplatform/v1/migration_client.cc b/google/cloud/aiplatform/v1/migration_client.cc index c5a2848dca3a5..abdb113ad3a9f 100644 --- a/google/cloud/aiplatform/v1/migration_client.cc +++ b/google/cloud/aiplatform/v1/migration_client.cc @@ -101,6 +101,38 @@ MigrationServiceClient::BatchMigrateResources( return connection_->BatchMigrateResources(operation); } +StreamRange +MigrationServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr MigrationServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr MigrationServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr MigrationServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +MigrationServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/migration_client.h b/google/cloud/aiplatform/v1/migration_client.h index 90dbc157a715c..5538e509c7d9a 100644 --- a/google/cloud/aiplatform/v1/migration_client.h +++ b/google/cloud/aiplatform/v1/migration_client.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -300,6 +301,178 @@ class MigrationServiceClient { BatchMigrateResources(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/migration_connection.cc b/google/cloud/aiplatform/v1/migration_connection.cc index 60b214690b3cc..6e3170287c9eb 100644 --- a/google/cloud/aiplatform/v1/migration_connection.cc +++ b/google/cloud/aiplatform/v1/migration_connection.cc @@ -70,6 +70,36 @@ MigrationServiceConnection::BatchMigrateResources( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +MigrationServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +MigrationServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr MigrationServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr MigrationServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +MigrationServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeMigrationServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include +#include #include #include #include @@ -206,6 +208,21 @@ class MigrationServiceConnection { virtual future< StatusOr> BatchMigrateResources(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/migration_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/migration_connection_idempotency_policy.cc index e3bdf7438d7e8..3508a686ae13e 100644 --- a/google/cloud/aiplatform/v1/migration_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/migration_connection_idempotency_policy.cc @@ -46,6 +46,32 @@ Idempotency MigrationServiceConnectionIdempotencyPolicy::BatchMigrateResources( return Idempotency::kNonIdempotent; } +Idempotency MigrationServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency MigrationServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency MigrationServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency MigrationServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency MigrationServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultMigrationServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/aiplatform/v1/migration_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/migration_connection_idempotency_policy.h index 637e8c066e91f..362c27a3ece07 100644 --- a/google/cloud/aiplatform/v1/migration_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/migration_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -43,6 +45,21 @@ class MigrationServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency BatchMigrateResources( google::cloud::aiplatform::v1::BatchMigrateResourcesRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/aiplatform/v1/mocks/mock_dataset_connection.h b/google/cloud/aiplatform/v1/mocks/mock_dataset_connection.h index 8190d778364c5..feae8f28b7f9c 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_dataset_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_dataset_connection.h @@ -421,6 +421,27 @@ class MockDatasetServiceConnection ListAnnotations, (google::cloud::aiplatform::v1::ListAnnotationsRequest request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/mocks/mock_deployment_resource_pool_connection.h b/google/cloud/aiplatform/v1/mocks/mock_deployment_resource_pool_connection.h index 671a5d4630371..4f8c10bf2bb61 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_deployment_resource_pool_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_deployment_resource_pool_connection.h @@ -189,6 +189,27 @@ class MockDeploymentResourcePoolServiceConnection future>, DeleteDeploymentResourcePool, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/mocks/mock_endpoint_connection.h b/google/cloud/aiplatform/v1/mocks/mock_endpoint_connection.h index 9d37d637e807c..a5c7571496a43 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_endpoint_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_endpoint_connection.h @@ -262,6 +262,27 @@ class MockEndpointServiceConnection StatusOr>, MutateDeployedModel, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/mocks/mock_feature_online_store_admin_connection.h b/google/cloud/aiplatform/v1/mocks/mock_feature_online_store_admin_connection.h index 0c951ab958968..791abd9ad1e5c 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_feature_online_store_admin_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_feature_online_store_admin_connection.h @@ -334,6 +334,27 @@ class MockFeatureOnlineStoreAdminServiceConnection ListFeatureViewSyncs, (google::cloud::aiplatform::v1::ListFeatureViewSyncsRequest request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/mocks/mock_feature_online_store_connection.h b/google/cloud/aiplatform/v1/mocks/mock_feature_online_store_connection.h index 44d081015abd4..0bf77994781ad 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_feature_online_store_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_feature_online_store_connection.h @@ -59,6 +59,27 @@ class MockFeatureOnlineStoreServiceConnection (google::cloud::aiplatform::v1::SearchNearestEntitiesRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/mocks/mock_feature_registry_connection.h b/google/cloud/aiplatform/v1/mocks/mock_feature_registry_connection.h index 278afd37ed095..db330d6ea404e 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_feature_registry_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_feature_registry_connection.h @@ -299,6 +299,27 @@ class MockFeatureRegistryServiceConnection future>, DeleteFeature, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/mocks/mock_featurestore_connection.h b/google/cloud/aiplatform/v1/mocks/mock_featurestore_connection.h index 38e073f9d2c62..323827e106167 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_featurestore_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_featurestore_connection.h @@ -581,6 +581,27 @@ class MockFeaturestoreServiceConnection SearchFeatures, (google::cloud::aiplatform::v1::SearchFeaturesRequest request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/mocks/mock_featurestore_online_serving_connection.h b/google/cloud/aiplatform/v1/mocks/mock_featurestore_online_serving_connection.h index f3da49b3b3a6d..1f4fdf5d0cd93 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_featurestore_online_serving_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_featurestore_online_serving_connection.h @@ -66,6 +66,27 @@ class MockFeaturestoreOnlineServingServiceConnection WriteFeatureValues, (google::cloud::aiplatform::v1::WriteFeatureValuesRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/mocks/mock_gen_ai_tuning_connection.h b/google/cloud/aiplatform/v1/mocks/mock_gen_ai_tuning_connection.h index b52591f61d209..7403377db1598 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_gen_ai_tuning_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_gen_ai_tuning_connection.h @@ -66,6 +66,27 @@ class MockGenAiTuningServiceConnection Status, CancelTuningJob, (google::cloud::aiplatform::v1::CancelTuningJobRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/mocks/mock_index_connection.h b/google/cloud/aiplatform/v1/mocks/mock_index_connection.h index a8938f5538b81..2086c8edc184b 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_index_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_index_connection.h @@ -182,6 +182,27 @@ class MockIndexServiceConnection RemoveDatapoints, (google::cloud::aiplatform::v1::RemoveDatapointsRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/mocks/mock_index_endpoint_connection.h b/google/cloud/aiplatform/v1/mocks/mock_index_endpoint_connection.h index 76695621e9b2c..ae07cf015e57c 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_index_endpoint_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_index_endpoint_connection.h @@ -266,6 +266,27 @@ class MockIndexEndpointServiceConnection StatusOr>, MutateDeployedIndex, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/mocks/mock_job_connection.h b/google/cloud/aiplatform/v1/mocks/mock_job_connection.h index 0ad4698001361..c97b93336be93 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_job_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_job_connection.h @@ -505,6 +505,27 @@ class MockJobServiceConnection : public aiplatform_v1::JobServiceConnection { (google::cloud::aiplatform::v1:: ResumeModelDeploymentMonitoringJobRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/mocks/mock_llm_utility_connection.h b/google/cloud/aiplatform/v1/mocks/mock_llm_utility_connection.h index fa437781def0a..6c161aa21d9c8 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_llm_utility_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_llm_utility_connection.h @@ -57,6 +57,27 @@ class MockLlmUtilityServiceConnection ComputeTokens, (google::cloud::aiplatform::v1::ComputeTokensRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/mocks/mock_match_connection.h b/google/cloud/aiplatform/v1/mocks/mock_match_connection.h index aad3e1b64c689..56cdd3a01b4cc 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_match_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_match_connection.h @@ -59,6 +59,27 @@ class MockMatchServiceConnection (google::cloud::aiplatform::v1::ReadIndexDatapointsRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/mocks/mock_metadata_connection.h b/google/cloud/aiplatform/v1/mocks/mock_metadata_connection.h index 5fd2dc70b3993..428ed7317f0ac 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_metadata_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_metadata_connection.h @@ -502,6 +502,27 @@ class MockMetadataServiceConnection (google::cloud::aiplatform::v1::QueryArtifactLineageSubgraphRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/mocks/mock_migration_connection.h b/google/cloud/aiplatform/v1/mocks/mock_migration_connection.h index 2e167f1c9f24a..2c3e65c1ca879 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_migration_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_migration_connection.h @@ -96,6 +96,27 @@ class MockMigrationServiceConnection google::cloud::aiplatform::v1::BatchMigrateResourcesResponse>>, BatchMigrateResources, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/mocks/mock_model_connection.h b/google/cloud/aiplatform/v1/mocks/mock_model_connection.h index 27012300c3ad3..34f5b45371b0e 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_model_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_model_connection.h @@ -359,6 +359,27 @@ class MockModelServiceConnection ListModelEvaluationSlices, (google::cloud::aiplatform::v1::ListModelEvaluationSlicesRequest request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/mocks/mock_model_garden_connection.h b/google/cloud/aiplatform/v1/mocks/mock_model_garden_connection.h index 7eab258900a4d..4bfb0dc6da7df 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_model_garden_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_model_garden_connection.h @@ -52,6 +52,27 @@ class MockModelGardenServiceConnection GetPublisherModel, (google::cloud::aiplatform::v1::GetPublisherModelRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/mocks/mock_notebook_connection.h b/google/cloud/aiplatform/v1/mocks/mock_notebook_connection.h index eb7681f3cb682..52de3a2bd66f9 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_notebook_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_notebook_connection.h @@ -431,6 +431,27 @@ class MockNotebookServiceConnection future>, DeleteNotebookExecutionJob, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/mocks/mock_persistent_resource_connection.h b/google/cloud/aiplatform/v1/mocks/mock_persistent_resource_connection.h index 0ef6a39464dbe..4be57085f3ba7 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_persistent_resource_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_persistent_resource_connection.h @@ -231,6 +231,27 @@ class MockPersistentResourceServiceConnection future>, RebootPersistentResource, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/mocks/mock_pipeline_connection.h b/google/cloud/aiplatform/v1/mocks/mock_pipeline_connection.h index de29a3a984bcb..0c5a8be4596ed 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_pipeline_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_pipeline_connection.h @@ -263,6 +263,27 @@ class MockPipelineServiceConnection google::cloud::aiplatform::v1::BatchCancelPipelineJobsResponse>>, BatchCancelPipelineJobs, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/mocks/mock_prediction_connection.h b/google/cloud/aiplatform/v1/mocks/mock_prediction_connection.h index 3519ccb392363..5c80c9db21404 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_prediction_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_prediction_connection.h @@ -116,6 +116,27 @@ class MockPredictionServiceConnection StreamGenerateContent, (google::cloud::aiplatform::v1::GenerateContentRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/mocks/mock_schedule_connection.h b/google/cloud/aiplatform/v1/mocks/mock_schedule_connection.h index 5f0a27ae4c675..7e8b59eda0b3a 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_schedule_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_schedule_connection.h @@ -116,6 +116,27 @@ class MockScheduleServiceConnection StatusOr, UpdateSchedule, (google::cloud::aiplatform::v1::UpdateScheduleRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/mocks/mock_specialist_pool_connection.h b/google/cloud/aiplatform/v1/mocks/mock_specialist_pool_connection.h index 21801c761f3f3..d0e7cb59a0ef8 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_specialist_pool_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_specialist_pool_connection.h @@ -177,6 +177,27 @@ class MockSpecialistPoolServiceConnection MOCK_METHOD(future>, UpdateSpecialistPool, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/mocks/mock_tensorboard_connection.h b/google/cloud/aiplatform/v1/mocks/mock_tensorboard_connection.h index d21343927166b..7f3d0af7bcee2 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_tensorboard_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_tensorboard_connection.h @@ -453,6 +453,27 @@ class MockTensorboardServiceConnection (google::cloud::aiplatform::v1::ExportTensorboardTimeSeriesDataRequest request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/mocks/mock_vizier_connection.h b/google/cloud/aiplatform/v1/mocks/mock_vizier_connection.h index 33bc98c731c03..7da1fda30f9dc 100644 --- a/google/cloud/aiplatform/v1/mocks/mock_vizier_connection.h +++ b/google/cloud/aiplatform/v1/mocks/mock_vizier_connection.h @@ -193,6 +193,27 @@ class MockVizierServiceConnection ListOptimalTrials, (google::cloud::aiplatform::v1::ListOptimalTrialsRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/aiplatform/v1/model_client.cc b/google/cloud/aiplatform/v1/model_client.cc index fef9cc6602526..e2a69cb3cea0d 100644 --- a/google/cloud/aiplatform/v1/model_client.cc +++ b/google/cloud/aiplatform/v1/model_client.cc @@ -512,6 +512,38 @@ ModelServiceClient::ListModelEvaluationSlices( return connection_->ListModelEvaluationSlices(std::move(request)); } +StreamRange +ModelServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr ModelServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr ModelServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr ModelServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +ModelServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/model_client.h b/google/cloud/aiplatform/v1/model_client.h index b9fd42d73740d..270ae71f88031 100644 --- a/google/cloud/aiplatform/v1/model_client.h +++ b/google/cloud/aiplatform/v1/model_client.h @@ -1681,6 +1681,178 @@ class ModelServiceClient { google::cloud::aiplatform::v1::ListModelEvaluationSlicesRequest request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/model_connection.cc b/google/cloud/aiplatform/v1/model_connection.cc index 1db61a52974dc..6c83e3ceff052 100644 --- a/google/cloud/aiplatform/v1/model_connection.cc +++ b/google/cloud/aiplatform/v1/model_connection.cc @@ -254,6 +254,35 @@ ModelServiceConnection::ListModelEvaluationSlices( StreamRange>(); } +StreamRange +ModelServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ModelServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr ModelServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr ModelServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +ModelServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeModelServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include +#include #include #include #include @@ -305,6 +307,21 @@ class ModelServiceConnection { virtual StreamRange ListModelEvaluationSlices( google::cloud::aiplatform::v1::ListModelEvaluationSlicesRequest request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/model_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/model_connection_idempotency_policy.cc index 1b087673a3ade..a8c8414419bbf 100644 --- a/google/cloud/aiplatform/v1/model_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/model_connection_idempotency_policy.cc @@ -129,6 +129,32 @@ Idempotency ModelServiceConnectionIdempotencyPolicy::ListModelEvaluationSlices( return Idempotency::kIdempotent; } +Idempotency ModelServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ModelServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ModelServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency ModelServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ModelServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultModelServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/aiplatform/v1/model_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/model_connection_idempotency_policy.h index 0645b0fe44b67..75a268bd148a3 100644 --- a/google/cloud/aiplatform/v1/model_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/model_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -95,6 +97,21 @@ class ModelServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListModelEvaluationSlices( google::cloud::aiplatform::v1::ListModelEvaluationSlicesRequest request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/aiplatform/v1/model_garden_client.cc b/google/cloud/aiplatform/v1/model_garden_client.cc index 731ad226dfa01..a5b8d1919b201 100644 --- a/google/cloud/aiplatform/v1/model_garden_client.cc +++ b/google/cloud/aiplatform/v1/model_garden_client.cc @@ -49,6 +49,39 @@ ModelGardenServiceClient::GetPublisherModel( return connection_->GetPublisherModel(request); } +StreamRange +ModelGardenServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +ModelGardenServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr ModelGardenServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr ModelGardenServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +ModelGardenServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/model_garden_client.h b/google/cloud/aiplatform/v1/model_garden_client.h index 3bb859768b1ed..e20bab5ab4a74 100644 --- a/google/cloud/aiplatform/v1/model_garden_client.h +++ b/google/cloud/aiplatform/v1/model_garden_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -145,6 +146,178 @@ class ModelGardenServiceClient { google::cloud::aiplatform::v1::GetPublisherModelRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/model_garden_connection.cc b/google/cloud/aiplatform/v1/model_garden_connection.cc index 817132ba964c6..6636d24ecb460 100644 --- a/google/cloud/aiplatform/v1/model_garden_connection.cc +++ b/google/cloud/aiplatform/v1/model_garden_connection.cc @@ -26,6 +26,7 @@ #include "google/cloud/common_options.h" #include "google/cloud/credentials.h" #include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/unified_grpc_credentials.h" #include #include @@ -43,6 +44,36 @@ ModelGardenServiceConnection::GetPublisherModel( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +ModelGardenServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +ModelGardenServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr ModelGardenServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr ModelGardenServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +ModelGardenServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeModelGardenServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include +#include #include #include @@ -188,6 +191,21 @@ class ModelGardenServiceConnection { virtual StatusOr GetPublisherModel( google::cloud::aiplatform::v1::GetPublisherModelRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/model_garden_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/model_garden_connection_idempotency_policy.cc index 0f15444986e02..826808740efe8 100644 --- a/google/cloud/aiplatform/v1/model_garden_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/model_garden_connection_idempotency_policy.cc @@ -39,6 +39,32 @@ Idempotency ModelGardenServiceConnectionIdempotencyPolicy::GetPublisherModel( return Idempotency::kIdempotent; } +Idempotency ModelGardenServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ModelGardenServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ModelGardenServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency ModelGardenServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ModelGardenServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultModelGardenServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/aiplatform/v1/model_garden_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/model_garden_connection_idempotency_policy.h index 7f87dda5faf83..293140b7f926f 100644 --- a/google/cloud/aiplatform/v1/model_garden_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/model_garden_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -39,6 +41,21 @@ class ModelGardenServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GetPublisherModel( google::cloud::aiplatform::v1::GetPublisherModelRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/aiplatform/v1/notebook_client.cc b/google/cloud/aiplatform/v1/notebook_client.cc index cfa7b12f6f02c..97b7aba469e8a 100644 --- a/google/cloud/aiplatform/v1/notebook_client.cc +++ b/google/cloud/aiplatform/v1/notebook_client.cc @@ -536,6 +536,38 @@ NotebookServiceClient::DeleteNotebookExecutionJob( return connection_->DeleteNotebookExecutionJob(operation); } +StreamRange +NotebookServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr NotebookServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr NotebookServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr NotebookServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +NotebookServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/notebook_client.h b/google/cloud/aiplatform/v1/notebook_client.h index 591146b427bc6..beda89995701c 100644 --- a/google/cloud/aiplatform/v1/notebook_client.h +++ b/google/cloud/aiplatform/v1/notebook_client.h @@ -1539,6 +1539,178 @@ class NotebookServiceClient { DeleteNotebookExecutionJob(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/notebook_connection.cc b/google/cloud/aiplatform/v1/notebook_connection.cc index 21305cbd5a12f..860c37d6ec75f 100644 --- a/google/cloud/aiplatform/v1/notebook_connection.cc +++ b/google/cloud/aiplatform/v1/notebook_connection.cc @@ -281,6 +281,36 @@ NotebookServiceConnection::DeleteNotebookExecutionJob( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +NotebookServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +NotebookServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr NotebookServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr NotebookServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +NotebookServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeNotebookServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include +#include #include #include #include @@ -339,6 +341,21 @@ class NotebookServiceConnection { virtual future< StatusOr> DeleteNotebookExecutionJob(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/notebook_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/notebook_connection_idempotency_policy.cc index 60969d2084969..05a647778b775 100644 --- a/google/cloud/aiplatform/v1/notebook_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/notebook_connection_idempotency_policy.cc @@ -122,6 +122,32 @@ NotebookServiceConnectionIdempotencyPolicy::DeleteNotebookExecutionJob( return Idempotency::kNonIdempotent; } +Idempotency NotebookServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency NotebookServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency NotebookServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency NotebookServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency NotebookServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultNotebookServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/aiplatform/v1/notebook_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/notebook_connection_idempotency_policy.h index 56db1e29d9eda..a0cdfc5bcdbe3 100644 --- a/google/cloud/aiplatform/v1/notebook_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/notebook_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -93,6 +95,21 @@ class NotebookServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteNotebookExecutionJob( google::cloud::aiplatform::v1::DeleteNotebookExecutionJobRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/aiplatform/v1/persistent_resource_client.cc b/google/cloud/aiplatform/v1/persistent_resource_client.cc index aee09e62d306b..d18296d19d1f4 100644 --- a/google/cloud/aiplatform/v1/persistent_resource_client.cc +++ b/google/cloud/aiplatform/v1/persistent_resource_client.cc @@ -260,6 +260,39 @@ PersistentResourceServiceClient::RebootPersistentResource( return connection_->RebootPersistentResource(operation); } +StreamRange +PersistentResourceServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +PersistentResourceServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr PersistentResourceServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr PersistentResourceServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +PersistentResourceServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/persistent_resource_client.h b/google/cloud/aiplatform/v1/persistent_resource_client.h index 19b0373f02df9..ac5691880b52b 100644 --- a/google/cloud/aiplatform/v1/persistent_resource_client.h +++ b/google/cloud/aiplatform/v1/persistent_resource_client.h @@ -722,6 +722,178 @@ class PersistentResourceServiceClient { RebootPersistentResource(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/persistent_resource_connection.cc b/google/cloud/aiplatform/v1/persistent_resource_connection.cc index c178c857c9937..44dd852cd2600 100644 --- a/google/cloud/aiplatform/v1/persistent_resource_connection.cc +++ b/google/cloud/aiplatform/v1/persistent_resource_connection.cc @@ -149,6 +149,38 @@ PersistentResourceServiceConnection::RebootPersistentResource( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +PersistentResourceServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +PersistentResourceServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +PersistentResourceServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +PersistentResourceServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +PersistentResourceServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakePersistentResourceServiceConnection(std::string const& location, Options options) { diff --git a/google/cloud/aiplatform/v1/persistent_resource_connection.h b/google/cloud/aiplatform/v1/persistent_resource_connection.h index 57a2d32db158c..e217dd6e21931 100644 --- a/google/cloud/aiplatform/v1/persistent_resource_connection.h +++ b/google/cloud/aiplatform/v1/persistent_resource_connection.h @@ -31,6 +31,8 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -263,6 +265,21 @@ class PersistentResourceServiceConnection { virtual future> RebootPersistentResource(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/persistent_resource_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/persistent_resource_connection_idempotency_policy.cc index 134f81c04f1fc..b0a6a2145c871 100644 --- a/google/cloud/aiplatform/v1/persistent_resource_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/persistent_resource_connection_idempotency_policy.cc @@ -71,6 +71,33 @@ PersistentResourceServiceConnectionIdempotencyPolicy::RebootPersistentResource( return Idempotency::kNonIdempotent; } +Idempotency PersistentResourceServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency PersistentResourceServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency PersistentResourceServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency PersistentResourceServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +PersistentResourceServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultPersistentResourceServiceConnectionIdempotencyPolicy() { return std::make_unique< diff --git a/google/cloud/aiplatform/v1/persistent_resource_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/persistent_resource_connection_idempotency_policy.h index b249df7c77114..913197df5f33b 100644 --- a/google/cloud/aiplatform/v1/persistent_resource_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/persistent_resource_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -59,6 +61,21 @@ class PersistentResourceServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency RebootPersistentResource( google::cloud::aiplatform::v1::RebootPersistentResourceRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/aiplatform/v1/pipeline_client.cc b/google/cloud/aiplatform/v1/pipeline_client.cc index c46d0ed1ec0bd..f7b42fb5b4f53 100644 --- a/google/cloud/aiplatform/v1/pipeline_client.cc +++ b/google/cloud/aiplatform/v1/pipeline_client.cc @@ -351,6 +351,38 @@ PipelineServiceClient::BatchCancelPipelineJobs( return connection_->BatchCancelPipelineJobs(operation); } +StreamRange +PipelineServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr PipelineServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr PipelineServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr PipelineServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +PipelineServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/pipeline_client.h b/google/cloud/aiplatform/v1/pipeline_client.h index f21bcf6cb6662..734caa4f402c2 100644 --- a/google/cloud/aiplatform/v1/pipeline_client.h +++ b/google/cloud/aiplatform/v1/pipeline_client.h @@ -1161,6 +1161,178 @@ class PipelineServiceClient { BatchCancelPipelineJobs(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/pipeline_connection.cc b/google/cloud/aiplatform/v1/pipeline_connection.cc index 6d0d913f7d75f..367c5a1d4b125 100644 --- a/google/cloud/aiplatform/v1/pipeline_connection.cc +++ b/google/cloud/aiplatform/v1/pipeline_connection.cc @@ -184,6 +184,36 @@ PipelineServiceConnection::BatchCancelPipelineJobs( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +PipelineServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +PipelineServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr PipelineServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr PipelineServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +PipelineServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakePipelineServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include +#include #include #include #include @@ -276,6 +278,21 @@ class PipelineServiceConnection { virtual future< StatusOr> BatchCancelPipelineJobs(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/pipeline_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/pipeline_connection_idempotency_policy.cc index 4467b16de1e9f..11524af0da25e 100644 --- a/google/cloud/aiplatform/v1/pipeline_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/pipeline_connection_idempotency_policy.cc @@ -94,6 +94,32 @@ Idempotency PipelineServiceConnectionIdempotencyPolicy::BatchCancelPipelineJobs( return Idempotency::kNonIdempotent; } +Idempotency PipelineServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency PipelineServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency PipelineServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency PipelineServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency PipelineServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultPipelineServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/aiplatform/v1/pipeline_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/pipeline_connection_idempotency_policy.h index 76363db53e258..eecae7335f860 100644 --- a/google/cloud/aiplatform/v1/pipeline_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/pipeline_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -77,6 +79,21 @@ class PipelineServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency BatchCancelPipelineJobs( google::cloud::aiplatform::v1::BatchCancelPipelineJobsRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/aiplatform/v1/prediction_client.cc b/google/cloud/aiplatform/v1/prediction_client.cc index 27d8a7e9681df..858792ff6f9d8 100644 --- a/google/cloud/aiplatform/v1/prediction_client.cc +++ b/google/cloud/aiplatform/v1/prediction_client.cc @@ -206,6 +206,39 @@ PredictionServiceClient::StreamGenerateContent( return connection_->StreamGenerateContent(request); } +StreamRange +PredictionServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +PredictionServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr PredictionServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr PredictionServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +PredictionServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/prediction_client.h b/google/cloud/aiplatform/v1/prediction_client.h index e43085bcc000c..30fa0bee9bad4 100644 --- a/google/cloud/aiplatform/v1/prediction_client.h +++ b/google/cloud/aiplatform/v1/prediction_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -770,6 +771,178 @@ class PredictionServiceClient { google::cloud::aiplatform::v1::GenerateContentRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/prediction_connection.cc b/google/cloud/aiplatform/v1/prediction_connection.cc index 9c257070b13bc..8fe34d4ed5dca 100644 --- a/google/cloud/aiplatform/v1/prediction_connection.cc +++ b/google/cloud/aiplatform/v1/prediction_connection.cc @@ -26,6 +26,7 @@ #include "google/cloud/common_options.h" #include "google/cloud/credentials.h" #include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/unified_grpc_credentials.h" #include #include @@ -148,6 +149,36 @@ PredictionServiceConnection::StreamGenerateContent( }); } +StreamRange +PredictionServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +PredictionServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr PredictionServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr PredictionServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +PredictionServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakePredictionServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include +#include #include #include @@ -236,6 +238,21 @@ class PredictionServiceConnection { virtual StreamRange StreamGenerateContent( google::cloud::aiplatform::v1::GenerateContentRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/prediction_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/prediction_connection_idempotency_policy.cc index 628480ccecba7..021b1d67c15bd 100644 --- a/google/cloud/aiplatform/v1/prediction_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/prediction_connection_idempotency_policy.cc @@ -64,6 +64,32 @@ Idempotency PredictionServiceConnectionIdempotencyPolicy::GenerateContent( return Idempotency::kNonIdempotent; } +Idempotency PredictionServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency PredictionServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency PredictionServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency PredictionServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency PredictionServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultPredictionServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/aiplatform/v1/prediction_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/prediction_connection_idempotency_policy.h index d350afb1fa07b..c21e5eb089cbc 100644 --- a/google/cloud/aiplatform/v1/prediction_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/prediction_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -54,6 +56,21 @@ class PredictionServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GenerateContent( google::cloud::aiplatform::v1::GenerateContentRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/aiplatform/v1/schedule_client.cc b/google/cloud/aiplatform/v1/schedule_client.cc index 2be2823ecc00d..4d29a9afa2236 100644 --- a/google/cloud/aiplatform/v1/schedule_client.cc +++ b/google/cloud/aiplatform/v1/schedule_client.cc @@ -179,6 +179,38 @@ ScheduleServiceClient::UpdateSchedule( return connection_->UpdateSchedule(request); } +StreamRange +ScheduleServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr ScheduleServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr ScheduleServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr ScheduleServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +ScheduleServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/schedule_client.h b/google/cloud/aiplatform/v1/schedule_client.h index 6bfd84d47c6bc..fa708fa176aa6 100644 --- a/google/cloud/aiplatform/v1/schedule_client.h +++ b/google/cloud/aiplatform/v1/schedule_client.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -638,6 +639,178 @@ class ScheduleServiceClient { google::cloud::aiplatform::v1::UpdateScheduleRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/schedule_connection.cc b/google/cloud/aiplatform/v1/schedule_connection.cc index 9b80596a1016d..e3dfad5435463 100644 --- a/google/cloud/aiplatform/v1/schedule_connection.cc +++ b/google/cloud/aiplatform/v1/schedule_connection.cc @@ -97,6 +97,36 @@ ScheduleServiceConnection::UpdateSchedule( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +ScheduleServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +ScheduleServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr ScheduleServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr ScheduleServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +ScheduleServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeScheduleServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include +#include #include #include #include @@ -218,6 +220,21 @@ class ScheduleServiceConnection { virtual StatusOr UpdateSchedule( google::cloud::aiplatform::v1::UpdateScheduleRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/schedule_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/schedule_connection_idempotency_policy.cc index d1012103db991..13f57755a7a27 100644 --- a/google/cloud/aiplatform/v1/schedule_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/schedule_connection_idempotency_policy.cc @@ -69,6 +69,32 @@ Idempotency ScheduleServiceConnectionIdempotencyPolicy::UpdateSchedule( return Idempotency::kNonIdempotent; } +Idempotency ScheduleServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ScheduleServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ScheduleServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency ScheduleServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ScheduleServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultScheduleServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/aiplatform/v1/schedule_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/schedule_connection_idempotency_policy.h index 0243bde608ee8..497bd713feb77 100644 --- a/google/cloud/aiplatform/v1/schedule_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/schedule_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -57,6 +59,21 @@ class ScheduleServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency UpdateSchedule( google::cloud::aiplatform::v1::UpdateScheduleRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/aiplatform/v1/specialist_pool_client.cc b/google/cloud/aiplatform/v1/specialist_pool_client.cc index 1464ef0c36776..42692b28fdfd9 100644 --- a/google/cloud/aiplatform/v1/specialist_pool_client.cc +++ b/google/cloud/aiplatform/v1/specialist_pool_client.cc @@ -204,6 +204,39 @@ SpecialistPoolServiceClient::UpdateSpecialistPool( return connection_->UpdateSpecialistPool(operation); } +StreamRange +SpecialistPoolServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +SpecialistPoolServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr SpecialistPoolServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr SpecialistPoolServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +SpecialistPoolServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/specialist_pool_client.h b/google/cloud/aiplatform/v1/specialist_pool_client.h index fd23827f88173..2ce22d99f7bdf 100644 --- a/google/cloud/aiplatform/v1/specialist_pool_client.h +++ b/google/cloud/aiplatform/v1/specialist_pool_client.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -584,6 +585,178 @@ class SpecialistPoolServiceClient { UpdateSpecialistPool(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/specialist_pool_connection.cc b/google/cloud/aiplatform/v1/specialist_pool_connection.cc index c579600213645..854d3c2b7a6c2 100644 --- a/google/cloud/aiplatform/v1/specialist_pool_connection.cc +++ b/google/cloud/aiplatform/v1/specialist_pool_connection.cc @@ -124,6 +124,36 @@ SpecialistPoolServiceConnection::UpdateSpecialistPool( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +SpecialistPoolServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +SpecialistPoolServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr SpecialistPoolServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr SpecialistPoolServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +SpecialistPoolServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSpecialistPoolServiceConnection(std::string const& location, Options options) { diff --git a/google/cloud/aiplatform/v1/specialist_pool_connection.h b/google/cloud/aiplatform/v1/specialist_pool_connection.h index 940568b99fde4..8ffddfcdf5d6f 100644 --- a/google/cloud/aiplatform/v1/specialist_pool_connection.h +++ b/google/cloud/aiplatform/v1/specialist_pool_connection.h @@ -31,6 +31,8 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -241,6 +243,21 @@ class SpecialistPoolServiceConnection { virtual future> UpdateSpecialistPool(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/specialist_pool_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/specialist_pool_connection_idempotency_policy.cc index f0d62e0e6a8c6..ff7eea06b7d82 100644 --- a/google/cloud/aiplatform/v1/specialist_pool_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/specialist_pool_connection_idempotency_policy.cc @@ -64,6 +64,33 @@ SpecialistPoolServiceConnectionIdempotencyPolicy::UpdateSpecialistPool( return Idempotency::kNonIdempotent; } +Idempotency SpecialistPoolServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SpecialistPoolServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency SpecialistPoolServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency SpecialistPoolServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +SpecialistPoolServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultSpecialistPoolServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/aiplatform/v1/specialist_pool_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/specialist_pool_connection_idempotency_policy.h index 6a7e0f61076a2..874209ad275e3 100644 --- a/google/cloud/aiplatform/v1/specialist_pool_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/specialist_pool_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -54,6 +56,21 @@ class SpecialistPoolServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency UpdateSpecialistPool( google::cloud::aiplatform::v1::UpdateSpecialistPoolRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/aiplatform/v1/tensorboard_client.cc b/google/cloud/aiplatform/v1/tensorboard_client.cc index 87965a2eb82ac..1ef0b03ba95b3 100644 --- a/google/cloud/aiplatform/v1/tensorboard_client.cc +++ b/google/cloud/aiplatform/v1/tensorboard_client.cc @@ -770,6 +770,39 @@ TensorboardServiceClient::ExportTensorboardTimeSeriesData( return connection_->ExportTensorboardTimeSeriesData(std::move(request)); } +StreamRange +TensorboardServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +TensorboardServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr TensorboardServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr TensorboardServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +TensorboardServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/tensorboard_client.h b/google/cloud/aiplatform/v1/tensorboard_client.h index b6d2536e6ec00..c8d51c2312611 100644 --- a/google/cloud/aiplatform/v1/tensorboard_client.h +++ b/google/cloud/aiplatform/v1/tensorboard_client.h @@ -2444,6 +2444,178 @@ class TensorboardServiceClient { request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/tensorboard_connection.cc b/google/cloud/aiplatform/v1/tensorboard_connection.cc index c34a2d65d0726..9bbd4e4f4bc0b 100644 --- a/google/cloud/aiplatform/v1/tensorboard_connection.cc +++ b/google/cloud/aiplatform/v1/tensorboard_connection.cc @@ -348,6 +348,36 @@ TensorboardServiceConnection::ExportTensorboardTimeSeriesData( StreamRange>(); } +StreamRange +TensorboardServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +TensorboardServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr TensorboardServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr TensorboardServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +TensorboardServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeTensorboardServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include +#include #include #include #include @@ -388,6 +390,21 @@ class TensorboardServiceConnection { ExportTensorboardTimeSeriesData( google::cloud::aiplatform::v1::ExportTensorboardTimeSeriesDataRequest request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/tensorboard_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/tensorboard_connection_idempotency_policy.cc index fec2afdff61ef..84d40eb0315a0 100644 --- a/google/cloud/aiplatform/v1/tensorboard_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/tensorboard_connection_idempotency_policy.cc @@ -203,6 +203,32 @@ TensorboardServiceConnectionIdempotencyPolicy::ExportTensorboardTimeSeriesData( return Idempotency::kNonIdempotent; } +Idempotency TensorboardServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency TensorboardServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency TensorboardServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency TensorboardServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency TensorboardServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultTensorboardServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/aiplatform/v1/tensorboard_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/tensorboard_connection_idempotency_policy.h index ab3dcfceae7a3..9ae33fffee93c 100644 --- a/google/cloud/aiplatform/v1/tensorboard_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/tensorboard_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -142,6 +144,21 @@ class TensorboardServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ExportTensorboardTimeSeriesData( google::cloud::aiplatform::v1::ExportTensorboardTimeSeriesDataRequest request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/aiplatform/v1/vizier_client.cc b/google/cloud/aiplatform/v1/vizier_client.cc index d6b71e085ee80..954616840f88e 100644 --- a/google/cloud/aiplatform/v1/vizier_client.cc +++ b/google/cloud/aiplatform/v1/vizier_client.cc @@ -260,6 +260,38 @@ VizierServiceClient::ListOptimalTrials( return connection_->ListOptimalTrials(request); } +StreamRange +VizierServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr VizierServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr VizierServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr VizierServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +VizierServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace aiplatform_v1 } // namespace cloud diff --git a/google/cloud/aiplatform/v1/vizier_client.h b/google/cloud/aiplatform/v1/vizier_client.h index 2c3ed2cd51bbf..10474db511fb0 100644 --- a/google/cloud/aiplatform/v1/vizier_client.h +++ b/google/cloud/aiplatform/v1/vizier_client.h @@ -942,6 +942,178 @@ class VizierServiceClient { google::cloud::aiplatform::v1::ListOptimalTrialsRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/aiplatform/v1/vizier_connection.cc b/google/cloud/aiplatform/v1/vizier_connection.cc index e1667a51d2a63..d83fe9591687d 100644 --- a/google/cloud/aiplatform/v1/vizier_connection.cc +++ b/google/cloud/aiplatform/v1/vizier_connection.cc @@ -165,6 +165,36 @@ VizierServiceConnection::ListOptimalTrials( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +VizierServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +VizierServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr VizierServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr VizierServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +VizierServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeVizierServiceConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include +#include #include #include #include @@ -252,6 +254,21 @@ class VizierServiceConnection { virtual StatusOr ListOptimalTrials( google::cloud::aiplatform::v1::ListOptimalTrialsRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/aiplatform/v1/vizier_connection_idempotency_policy.cc b/google/cloud/aiplatform/v1/vizier_connection_idempotency_policy.cc index 0fbf4021eea35..b9fc7097e4a97 100644 --- a/google/cloud/aiplatform/v1/vizier_connection_idempotency_policy.cc +++ b/google/cloud/aiplatform/v1/vizier_connection_idempotency_policy.cc @@ -110,6 +110,32 @@ Idempotency VizierServiceConnectionIdempotencyPolicy::ListOptimalTrials( return Idempotency::kNonIdempotent; } +Idempotency VizierServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency VizierServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency VizierServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency VizierServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency VizierServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultVizierServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/aiplatform/v1/vizier_connection_idempotency_policy.h b/google/cloud/aiplatform/v1/vizier_connection_idempotency_policy.h index de179f092701e..f4a2c6e00fd84 100644 --- a/google/cloud/aiplatform/v1/vizier_connection_idempotency_policy.h +++ b/google/cloud/aiplatform/v1/vizier_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -82,6 +84,21 @@ class VizierServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListOptimalTrials( google::cloud::aiplatform::v1::ListOptimalTrialsRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/alloydb/BUILD.bazel b/google/cloud/alloydb/BUILD.bazel index 9b90196e9337c..f0a61e7c65cb7 100644 --- a/google/cloud/alloydb/BUILD.bazel +++ b/google/cloud/alloydb/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/alloydb/v1:alloydb_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/alloydb/v1/alloy_db_admin_client.cc b/google/cloud/alloydb/v1/alloy_db_admin_client.cc index b94904944e72a..6d70b011c7bac 100644 --- a/google/cloud/alloydb/v1/alloy_db_admin_client.cc +++ b/google/cloud/alloydb/v1/alloy_db_admin_client.cc @@ -941,6 +941,19 @@ Status AlloyDBAdminClient::DeleteUser( return connection_->DeleteUser(request); } +StreamRange +AlloyDBAdminClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr AlloyDBAdminClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace alloydb_v1 } // namespace cloud diff --git a/google/cloud/alloydb/v1/alloy_db_admin_client.h b/google/cloud/alloydb/v1/alloy_db_admin_client.h index bc928df7364a7..17b2400dd6ad9 100644 --- a/google/cloud/alloydb/v1/alloy_db_admin_client.h +++ b/google/cloud/alloydb/v1/alloy_db_admin_client.h @@ -2905,6 +2905,76 @@ class AlloyDBAdminClient { google::cloud::alloydb::v1::DeleteUserRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/alloydb/v1/alloy_db_admin_connection.cc b/google/cloud/alloydb/v1/alloy_db_admin_connection.cc index 3962a85894738..71e5192e29284 100644 --- a/google/cloud/alloydb/v1/alloy_db_admin_connection.cc +++ b/google/cloud/alloydb/v1/alloy_db_admin_connection.cc @@ -495,6 +495,19 @@ Status AlloyDBAdminConnection::DeleteUser( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +AlloyDBAdminConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr AlloyDBAdminConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAlloyDBAdminConnection( Options options) { internal::CheckExpectedOptions +#include +#include #include #include @@ -413,6 +415,12 @@ class AlloyDBAdminConnection { virtual Status DeleteUser( google::cloud::alloydb::v1::DeleteUserRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/alloydb/v1/alloy_db_admin_connection_idempotency_policy.cc b/google/cloud/alloydb/v1/alloy_db_admin_connection_idempotency_policy.cc index 9a0a6e424f7a8..d2060f6bb01cd 100644 --- a/google/cloud/alloydb/v1/alloy_db_admin_connection_idempotency_policy.cc +++ b/google/cloud/alloydb/v1/alloy_db_admin_connection_idempotency_policy.cc @@ -189,6 +189,16 @@ Idempotency AlloyDBAdminConnectionIdempotencyPolicy::DeleteUser( return Idempotency::kNonIdempotent; } +Idempotency AlloyDBAdminConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AlloyDBAdminConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultAlloyDBAdminConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/alloydb/v1/alloy_db_admin_connection_idempotency_policy.h b/google/cloud/alloydb/v1/alloy_db_admin_connection_idempotency_policy.h index e2dcf393f0b58..b0fc386741433 100644 --- a/google/cloud/alloydb/v1/alloy_db_admin_connection_idempotency_policy.h +++ b/google/cloud/alloydb/v1/alloy_db_admin_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -131,6 +132,12 @@ class AlloyDBAdminConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteUser( google::cloud::alloydb::v1::DeleteUserRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/alloydb/v1/internal/alloy_db_admin_auth_decorator.cc b/google/cloud/alloydb/v1/internal/alloy_db_admin_auth_decorator.cc index 744ea1eda58d0..115d2f3248c05 100644 --- a/google/cloud/alloydb/v1/internal/alloy_db_admin_auth_decorator.cc +++ b/google/cloud/alloydb/v1/internal/alloy_db_admin_auth_decorator.cc @@ -630,6 +630,23 @@ Status AlloyDBAdminAuth::DeleteUser( return child_->DeleteUser(context, options, request); } +StatusOr +AlloyDBAdminAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr AlloyDBAdminAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> AlloyDBAdminAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/alloydb/v1/internal/alloy_db_admin_auth_decorator.h b/google/cloud/alloydb/v1/internal/alloy_db_admin_auth_decorator.h index e5fca1dad10cf..50e044f71bc81 100644 --- a/google/cloud/alloydb/v1/internal/alloy_db_admin_auth_decorator.h +++ b/google/cloud/alloydb/v1/internal/alloy_db_admin_auth_decorator.h @@ -290,6 +290,14 @@ class AlloyDBAdminAuth : public AlloyDBAdminStub { grpc::ClientContext& context, Options const& options, google::cloud::alloydb::v1::DeleteUserRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/alloydb/v1/internal/alloy_db_admin_connection_impl.cc b/google/cloud/alloydb/v1/internal/alloy_db_admin_connection_impl.cc index 0892e6a19ce84..f8de6461d80cf 100644 --- a/google/cloud/alloydb/v1/internal/alloy_db_admin_connection_impl.cc +++ b/google/cloud/alloydb/v1/internal/alloy_db_admin_connection_impl.cc @@ -1904,6 +1904,54 @@ Status AlloyDBAdminConnectionImpl::DeleteUser( *current, request, __func__); } +StreamRange +AlloyDBAdminConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AlloyDBAdminConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace alloydb_v1_internal } // namespace cloud diff --git a/google/cloud/alloydb/v1/internal/alloy_db_admin_connection_impl.h b/google/cloud/alloydb/v1/internal/alloy_db_admin_connection_impl.h index 0badd381dce95..9e2cfbbe7e624 100644 --- a/google/cloud/alloydb/v1/internal/alloy_db_admin_connection_impl.h +++ b/google/cloud/alloydb/v1/internal/alloy_db_admin_connection_impl.h @@ -292,6 +292,12 @@ class AlloyDBAdminConnectionImpl : public alloydb_v1::AlloyDBAdminConnection { Status DeleteUser( google::cloud::alloydb::v1::DeleteUserRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/alloydb/v1/internal/alloy_db_admin_logging_decorator.cc b/google/cloud/alloydb/v1/internal/alloy_db_admin_logging_decorator.cc index ea5f835b08954..e06769fe0e522 100644 --- a/google/cloud/alloydb/v1/internal/alloy_db_admin_logging_decorator.cc +++ b/google/cloud/alloydb/v1/internal/alloy_db_admin_logging_decorator.cc @@ -708,6 +708,29 @@ Status AlloyDBAdminLogging::DeleteUser( context, options, request, __func__, tracing_options_); } +StatusOr +AlloyDBAdminLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AlloyDBAdminLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> AlloyDBAdminLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/alloydb/v1/internal/alloy_db_admin_logging_decorator.h b/google/cloud/alloydb/v1/internal/alloy_db_admin_logging_decorator.h index 2d7c4a9cbb321..6dba86b0a4633 100644 --- a/google/cloud/alloydb/v1/internal/alloy_db_admin_logging_decorator.h +++ b/google/cloud/alloydb/v1/internal/alloy_db_admin_logging_decorator.h @@ -290,6 +290,14 @@ class AlloyDBAdminLogging : public AlloyDBAdminStub { grpc::ClientContext& context, Options const& options, google::cloud::alloydb::v1::DeleteUserRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/alloydb/v1/internal/alloy_db_admin_metadata_decorator.cc b/google/cloud/alloydb/v1/internal/alloy_db_admin_metadata_decorator.cc index 0eb75fc55d2b6..d0dbf5ace5244 100644 --- a/google/cloud/alloydb/v1/internal/alloy_db_admin_metadata_decorator.cc +++ b/google/cloud/alloydb/v1/internal/alloy_db_admin_metadata_decorator.cc @@ -516,6 +516,23 @@ Status AlloyDBAdminMetadata::DeleteUser( return child_->DeleteUser(context, options, request); } +StatusOr +AlloyDBAdminMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr AlloyDBAdminMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> AlloyDBAdminMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/alloydb/v1/internal/alloy_db_admin_metadata_decorator.h b/google/cloud/alloydb/v1/internal/alloy_db_admin_metadata_decorator.h index 1083988c14d23..1f9c8a0993214 100644 --- a/google/cloud/alloydb/v1/internal/alloy_db_admin_metadata_decorator.h +++ b/google/cloud/alloydb/v1/internal/alloy_db_admin_metadata_decorator.h @@ -290,6 +290,14 @@ class AlloyDBAdminMetadata : public AlloyDBAdminStub { grpc::ClientContext& context, Options const& options, google::cloud::alloydb::v1::DeleteUserRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/alloydb/v1/internal/alloy_db_admin_stub.cc b/google/cloud/alloydb/v1/internal/alloy_db_admin_stub.cc index a78cc58a4935d..a3d7b60ac2782 100644 --- a/google/cloud/alloydb/v1/internal/alloy_db_admin_stub.cc +++ b/google/cloud/alloydb/v1/internal/alloy_db_admin_stub.cc @@ -706,6 +706,30 @@ Status DefaultAlloyDBAdminStub::DeleteUser( return google::cloud::Status(); } +StatusOr +DefaultAlloyDBAdminStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAlloyDBAdminStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultAlloyDBAdminStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/alloydb/v1/internal/alloy_db_admin_stub.h b/google/cloud/alloydb/v1/internal/alloy_db_admin_stub.h index d6185eef61427..4ac84f13509e4 100644 --- a/google/cloud/alloydb/v1/internal/alloy_db_admin_stub.h +++ b/google/cloud/alloydb/v1/internal/alloy_db_admin_stub.h @@ -25,6 +25,9 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include #include #include #include @@ -283,6 +286,15 @@ class AlloyDBAdminStub { grpc::ClientContext& context, Options const& options, google::cloud::alloydb::v1::DeleteUserRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -301,9 +313,13 @@ class DefaultAlloyDBAdminStub : public AlloyDBAdminStub { DefaultAlloyDBAdminStub( std::unique_ptr grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListClusters( grpc::ClientContext& context, Options const& options, @@ -556,6 +572,14 @@ class DefaultAlloyDBAdminStub : public AlloyDBAdminStub { grpc::ClientContext& context, Options const& options, google::cloud::alloydb::v1::DeleteUserRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -571,6 +595,8 @@ class DefaultAlloyDBAdminStub : public AlloyDBAdminStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/alloydb/v1/internal/alloy_db_admin_stub_factory.cc b/google/cloud/alloydb/v1/internal/alloy_db_admin_stub_factory.cc index 237657d0379e0..b276d285b550b 100644 --- a/google/cloud/alloydb/v1/internal/alloy_db_admin_stub_factory.cc +++ b/google/cloud/alloydb/v1/internal/alloy_db_admin_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultAlloyDBAdminStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::alloydb::v1::AlloyDBAdmin::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/alloydb/v1/internal/alloy_db_admin_tracing_connection.cc b/google/cloud/alloydb/v1/internal/alloy_db_admin_tracing_connection.cc index f97de25132a21..0a88d847968f6 100644 --- a/google/cloud/alloydb/v1/internal/alloy_db_admin_tracing_connection.cc +++ b/google/cloud/alloydb/v1/internal/alloy_db_admin_tracing_connection.cc @@ -661,6 +661,26 @@ Status AlloyDBAdminTracingConnection::DeleteUser( return internal::EndSpan(*span, child_->DeleteUser(request)); } +StreamRange +AlloyDBAdminTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("alloydb_v1::AlloyDBAdminConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AlloyDBAdminTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("alloydb_v1::AlloyDBAdminConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/alloydb/v1/internal/alloy_db_admin_tracing_connection.h b/google/cloud/alloydb/v1/internal/alloy_db_admin_tracing_connection.h index 7e7655ca83a99..bcf90e1017e87 100644 --- a/google/cloud/alloydb/v1/internal/alloy_db_admin_tracing_connection.h +++ b/google/cloud/alloydb/v1/internal/alloy_db_admin_tracing_connection.h @@ -281,6 +281,12 @@ class AlloyDBAdminTracingConnection Status DeleteUser( google::cloud::alloydb::v1::DeleteUserRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/alloydb/v1/internal/alloy_db_admin_tracing_stub.cc b/google/cloud/alloydb/v1/internal/alloy_db_admin_tracing_stub.cc index 26565fa90b9b5..7d73c98dc7ce6 100644 --- a/google/cloud/alloydb/v1/internal/alloy_db_admin_tracing_stub.cc +++ b/google/cloud/alloydb/v1/internal/alloy_db_admin_tracing_stub.cc @@ -646,6 +646,30 @@ Status AlloyDBAdminTracingStub::DeleteUser( child_->DeleteUser(context, options, request)); } +StatusOr +AlloyDBAdminTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.alloydb.v1.AlloyDBAdmin", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +AlloyDBAdminTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.alloydb.v1.AlloyDBAdmin", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> AlloyDBAdminTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/alloydb/v1/internal/alloy_db_admin_tracing_stub.h b/google/cloud/alloydb/v1/internal/alloy_db_admin_tracing_stub.h index 8898d906766b5..3ccd371a8e63f 100644 --- a/google/cloud/alloydb/v1/internal/alloy_db_admin_tracing_stub.h +++ b/google/cloud/alloydb/v1/internal/alloy_db_admin_tracing_stub.h @@ -289,6 +289,14 @@ class AlloyDBAdminTracingStub : public AlloyDBAdminStub { grpc::ClientContext& context, Options const& options, google::cloud::alloydb::v1::DeleteUserRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/alloydb/v1/mocks/mock_alloy_db_admin_connection.h b/google/cloud/alloydb/v1/mocks/mock_alloy_db_admin_connection.h index efd8f84665539..67416b933d3e0 100644 --- a/google/cloud/alloydb/v1/mocks/mock_alloy_db_admin_connection.h +++ b/google/cloud/alloydb/v1/mocks/mock_alloy_db_admin_connection.h @@ -755,6 +755,14 @@ class MockAlloyDBAdminConnection : public alloydb_v1::AlloyDBAdminConnection { MOCK_METHOD(Status, DeleteUser, (google::cloud::alloydb::v1::DeleteUserRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/apphub/BUILD.bazel b/google/cloud/apphub/BUILD.bazel index 61ab437e885b4..23a391f61480d 100644 --- a/google/cloud/apphub/BUILD.bazel +++ b/google/cloud/apphub/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/apphub/v1:apphub_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/apphub/v1/app_hub_client.cc b/google/cloud/apphub/v1/app_hub_client.cc index c4d9d24624dec..9fb48d304fcb3 100644 --- a/google/cloud/apphub/v1/app_hub_client.cc +++ b/google/cloud/apphub/v1/app_hub_client.cc @@ -775,6 +775,37 @@ AppHubClient::DeleteApplication(google::longrunning::Operation const& operation, return connection_->DeleteApplication(operation); } +StreamRange AppHubClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr AppHubClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr AppHubClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr AppHubClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +AppHubClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace apphub_v1 } // namespace cloud diff --git a/google/cloud/apphub/v1/app_hub_client.h b/google/cloud/apphub/v1/app_hub_client.h index d21b4b92f987d..4eaccd6e24f30 100644 --- a/google/cloud/apphub/v1/app_hub_client.h +++ b/google/cloud/apphub/v1/app_hub_client.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -2477,6 +2478,178 @@ class AppHubClient { DeleteApplication(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/apphub/v1/app_hub_connection.cc b/google/cloud/apphub/v1/app_hub_connection.cc index 9cb9d4e11c0d4..47ae569edc0ab 100644 --- a/google/cloud/apphub/v1/app_hub_connection.cc +++ b/google/cloud/apphub/v1/app_hub_connection.cc @@ -380,6 +380,34 @@ AppHubConnection::DeleteApplication(google::longrunning::Operation const&) { Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange AppHubConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr AppHubConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr AppHubConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr AppHubConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +AppHubConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAppHubConnection(Options options) { internal::CheckExpectedOptions +#include +#include #include #include @@ -369,6 +371,21 @@ class AppHubConnection { virtual future> DeleteApplication(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/apphub/v1/app_hub_connection_idempotency_policy.cc b/google/cloud/apphub/v1/app_hub_connection_idempotency_policy.cc index 804c1e15bd417..8b0eb7654485f 100644 --- a/google/cloud/apphub/v1/app_hub_connection_idempotency_policy.cc +++ b/google/cloud/apphub/v1/app_hub_connection_idempotency_policy.cc @@ -170,6 +170,32 @@ Idempotency AppHubConnectionIdempotencyPolicy::DeleteApplication( return Idempotency::kNonIdempotent; } +Idempotency AppHubConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AppHubConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AppHubConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency AppHubConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AppHubConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultAppHubConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/apphub/v1/app_hub_connection_idempotency_policy.h b/google/cloud/apphub/v1/app_hub_connection_idempotency_policy.h index 9ff2c91ed9213..ef63c569fb3c2 100644 --- a/google/cloud/apphub/v1/app_hub_connection_idempotency_policy.h +++ b/google/cloud/apphub/v1/app_hub_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -122,6 +124,21 @@ class AppHubConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteApplication( google::cloud::apphub::v1::DeleteApplicationRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/apphub/v1/internal/app_hub_auth_decorator.cc b/google/cloud/apphub/v1/internal/app_hub_auth_decorator.cc index fcbe3d9fe3347..aee9854c94f8b 100644 --- a/google/cloud/apphub/v1/internal/app_hub_auth_decorator.cc +++ b/google/cloud/apphub/v1/internal/app_hub_auth_decorator.cc @@ -487,6 +487,48 @@ StatusOr AppHubAuth::DeleteApplication( return child_->DeleteApplication(context, options, request); } +StatusOr +AppHubAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr AppHubAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr AppHubAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr AppHubAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +AppHubAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> AppHubAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/apphub/v1/internal/app_hub_auth_decorator.h b/google/cloud/apphub/v1/internal/app_hub_auth_decorator.h index 20049afa97c03..fb578fa738519 100644 --- a/google/cloud/apphub/v1/internal/app_hub_auth_decorator.h +++ b/google/cloud/apphub/v1/internal/app_hub_auth_decorator.h @@ -244,6 +244,26 @@ class AppHubAuth : public AppHubStub { google::cloud::apphub::v1::DeleteApplicationRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/apphub/v1/internal/app_hub_connection_impl.cc b/google/cloud/apphub/v1/internal/app_hub_connection_impl.cc index fe34c1a3b29d1..417e43871d6c0 100644 --- a/google/cloud/apphub/v1/internal/app_hub_connection_impl.cc +++ b/google/cloud/apphub/v1/internal/app_hub_connection_impl.cc @@ -1422,6 +1422,93 @@ AppHubConnectionImpl::DeleteApplication( polling_policy(*current), __func__); } +StreamRange +AppHubConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr AppHubConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr AppHubConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr AppHubConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +AppHubConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace apphub_v1_internal } // namespace cloud diff --git a/google/cloud/apphub/v1/internal/app_hub_connection_impl.h b/google/cloud/apphub/v1/internal/app_hub_connection_impl.h index 5ea10cec1207f..3d3d7d310b528 100644 --- a/google/cloud/apphub/v1/internal/app_hub_connection_impl.h +++ b/google/cloud/apphub/v1/internal/app_hub_connection_impl.h @@ -240,6 +240,21 @@ class AppHubConnectionImpl : public apphub_v1::AppHubConnection { future> DeleteApplication(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/apphub/v1/internal/app_hub_logging_decorator.cc b/google/cloud/apphub/v1/internal/app_hub_logging_decorator.cc index 0004c4190afe2..71440762516bb 100644 --- a/google/cloud/apphub/v1/internal/app_hub_logging_decorator.cc +++ b/google/cloud/apphub/v1/internal/app_hub_logging_decorator.cc @@ -580,6 +580,63 @@ StatusOr AppHubLogging::DeleteApplication( context, options, request, __func__, tracing_options_); } +StatusOr +AppHubLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AppHubLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AppHubLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AppHubLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AppHubLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> AppHubLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/apphub/v1/internal/app_hub_logging_decorator.h b/google/cloud/apphub/v1/internal/app_hub_logging_decorator.h index 5c9e10ee8cb91..49756e3d00d53 100644 --- a/google/cloud/apphub/v1/internal/app_hub_logging_decorator.h +++ b/google/cloud/apphub/v1/internal/app_hub_logging_decorator.h @@ -244,6 +244,26 @@ class AppHubLogging : public AppHubStub { google::cloud::apphub::v1::DeleteApplicationRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/apphub/v1/internal/app_hub_metadata_decorator.cc b/google/cloud/apphub/v1/internal/app_hub_metadata_decorator.cc index 4b73f04bc5525..786945c8838cb 100644 --- a/google/cloud/apphub/v1/internal/app_hub_metadata_decorator.cc +++ b/google/cloud/apphub/v1/internal/app_hub_metadata_decorator.cc @@ -421,6 +421,51 @@ StatusOr AppHubMetadata::DeleteApplication( return child_->DeleteApplication(context, options, request); } +StatusOr +AppHubMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr AppHubMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr AppHubMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr AppHubMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +AppHubMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> AppHubMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/apphub/v1/internal/app_hub_metadata_decorator.h b/google/cloud/apphub/v1/internal/app_hub_metadata_decorator.h index e01f5ce4da7d5..485f1b020eebb 100644 --- a/google/cloud/apphub/v1/internal/app_hub_metadata_decorator.h +++ b/google/cloud/apphub/v1/internal/app_hub_metadata_decorator.h @@ -244,6 +244,26 @@ class AppHubMetadata : public AppHubStub { google::cloud::apphub::v1::DeleteApplicationRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/apphub/v1/internal/app_hub_stub.cc b/google/cloud/apphub/v1/internal/app_hub_stub.cc index 11c879a938863..cab85b0b571d6 100644 --- a/google/cloud/apphub/v1/internal/app_hub_stub.cc +++ b/google/cloud/apphub/v1/internal/app_hub_stub.cc @@ -564,6 +564,64 @@ StatusOr DefaultAppHubStub::DeleteApplication( return response; } +StatusOr +DefaultAppHubStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAppHubStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAppHubStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAppHubStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAppHubStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultAppHubStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/apphub/v1/internal/app_hub_stub.h b/google/cloud/apphub/v1/internal/app_hub_stub.h index d31d47cff65c4..6e79176e7bc25 100644 --- a/google/cloud/apphub/v1/internal/app_hub_stub.h +++ b/google/cloud/apphub/v1/internal/app_hub_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -249,6 +253,28 @@ class AppHubStub { grpc::ClientContext& context, Options options, google::cloud::apphub::v1::DeleteApplicationRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -267,9 +293,15 @@ class DefaultAppHubStub : public AppHubStub { DefaultAppHubStub( std::unique_ptr grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr LookupServiceProjectAttachment( @@ -476,6 +508,26 @@ class DefaultAppHubStub : public AppHubStub { google::cloud::apphub::v1::DeleteApplicationRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -490,6 +542,9 @@ class DefaultAppHubStub : public AppHubStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/apphub/v1/internal/app_hub_stub_factory.cc b/google/cloud/apphub/v1/internal/app_hub_stub_factory.cc index 0424fb9fd2fc7..5627be9c16b4e 100644 --- a/google/cloud/apphub/v1/internal/app_hub_stub_factory.cc +++ b/google/cloud/apphub/v1/internal/app_hub_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -43,8 +45,12 @@ std::shared_ptr CreateDefaultAppHubStub( auto channel = auth->CreateChannel(options.get(), internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::apphub::v1::AppHub::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/apphub/v1/internal/app_hub_tracing_connection.cc b/google/cloud/apphub/v1/internal/app_hub_tracing_connection.cc index ce0662be0865c..8e3679e9af906 100644 --- a/google/cloud/apphub/v1/internal/app_hub_tracing_connection.cc +++ b/google/cloud/apphub/v1/internal/app_hub_tracing_connection.cc @@ -498,6 +498,47 @@ AppHubTracingConnection::DeleteApplication( child_->DeleteApplication(operation)); } +StreamRange +AppHubTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan("apphub_v1::AppHubConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AppHubTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan("apphub_v1::AppHubConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr AppHubTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan("apphub_v1::AppHubConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr AppHubTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan("apphub_v1::AppHubConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +AppHubTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = + internal::MakeSpan("apphub_v1::AppHubConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeAppHubTracingConnection( diff --git a/google/cloud/apphub/v1/internal/app_hub_tracing_connection.h b/google/cloud/apphub/v1/internal/app_hub_tracing_connection.h index 8613f623fa6a4..d2fa7af4b7e46 100644 --- a/google/cloud/apphub/v1/internal/app_hub_tracing_connection.h +++ b/google/cloud/apphub/v1/internal/app_hub_tracing_connection.h @@ -229,6 +229,21 @@ class AppHubTracingConnection : public apphub_v1::AppHubConnection { future> DeleteApplication(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/apphub/v1/internal/app_hub_tracing_stub.cc b/google/cloud/apphub/v1/internal/app_hub_tracing_stub.cc index 9f7cd5f87ae30..99513e455027b 100644 --- a/google/cloud/apphub/v1/internal/app_hub_tracing_stub.cc +++ b/google/cloud/apphub/v1/internal/app_hub_tracing_stub.cc @@ -524,6 +524,63 @@ StatusOr AppHubTracingStub::DeleteApplication( context, *span, child_->DeleteApplication(context, options, request)); } +StatusOr +AppHubTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.apphub.v1.AppHub", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr AppHubTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.apphub.v1.AppHub", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr AppHubTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.apphub.v1.AppHub", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr AppHubTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.apphub.v1.AppHub", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +AppHubTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.apphub.v1.AppHub", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> AppHubTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/apphub/v1/internal/app_hub_tracing_stub.h b/google/cloud/apphub/v1/internal/app_hub_tracing_stub.h index 73c75d1253dfc..bd4c8b403e38e 100644 --- a/google/cloud/apphub/v1/internal/app_hub_tracing_stub.h +++ b/google/cloud/apphub/v1/internal/app_hub_tracing_stub.h @@ -243,6 +243,26 @@ class AppHubTracingStub : public AppHubStub { google::cloud::apphub::v1::DeleteApplicationRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/apphub/v1/mocks/mock_app_hub_connection.h b/google/cloud/apphub/v1/mocks/mock_app_hub_connection.h index 32192d8be8085..86328632dc501 100644 --- a/google/cloud/apphub/v1/mocks/mock_app_hub_connection.h +++ b/google/cloud/apphub/v1/mocks/mock_app_hub_connection.h @@ -561,6 +561,27 @@ class MockAppHubConnection : public apphub_v1::AppHubConnection { MOCK_METHOD(future>, DeleteApplication, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/artifactregistry/BUILD.bazel b/google/cloud/artifactregistry/BUILD.bazel index 9d4f9177dd000..238350f2b3081 100644 --- a/google/cloud/artifactregistry/BUILD.bazel +++ b/google/cloud/artifactregistry/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/devtools/artifactregistry/v1:artifactregistry_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/artifactregistry/v1/artifact_registry_client.cc b/google/cloud/artifactregistry/v1/artifact_registry_client.cc index 12ded181125cd..53b6a93119e21 100644 --- a/google/cloud/artifactregistry/v1/artifact_registry_client.cc +++ b/google/cloud/artifactregistry/v1/artifact_registry_client.cc @@ -781,6 +781,19 @@ ArtifactRegistryClient::UpdateVPCSCConfig( return connection_->UpdateVPCSCConfig(request); } +StreamRange +ArtifactRegistryClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr ArtifactRegistryClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace artifactregistry_v1 } // namespace cloud diff --git a/google/cloud/artifactregistry/v1/artifact_registry_client.h b/google/cloud/artifactregistry/v1/artifact_registry_client.h index 11f8fb194da67..22ec1a12e4d81 100644 --- a/google/cloud/artifactregistry/v1/artifact_registry_client.h +++ b/google/cloud/artifactregistry/v1/artifact_registry_client.h @@ -2606,6 +2606,76 @@ class ArtifactRegistryClient { request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/artifactregistry/v1/artifact_registry_connection.cc b/google/cloud/artifactregistry/v1/artifact_registry_connection.cc index 27f645d8b780a..11bce298027d9 100644 --- a/google/cloud/artifactregistry/v1/artifact_registry_connection.cc +++ b/google/cloud/artifactregistry/v1/artifact_registry_connection.cc @@ -402,6 +402,20 @@ ArtifactRegistryConnection::UpdateVPCSCConfig( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +ArtifactRegistryConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +ArtifactRegistryConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeArtifactRegistryConnection( Options options) { internal::CheckExpectedOptions #include #include #include @@ -404,6 +405,12 @@ class ArtifactRegistryConnection { UpdateVPCSCConfig( google::devtools::artifactregistry::v1::UpdateVPCSCConfigRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/artifactregistry/v1/artifact_registry_connection_idempotency_policy.cc b/google/cloud/artifactregistry/v1/artifact_registry_connection_idempotency_policy.cc index b09e1cf2f1193..a0931c72d66b1 100644 --- a/google/cloud/artifactregistry/v1/artifact_registry_connection_idempotency_policy.cc +++ b/google/cloud/artifactregistry/v1/artifact_registry_connection_idempotency_policy.cc @@ -220,6 +220,16 @@ Idempotency ArtifactRegistryConnectionIdempotencyPolicy::UpdateVPCSCConfig( return Idempotency::kNonIdempotent; } +Idempotency ArtifactRegistryConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ArtifactRegistryConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultArtifactRegistryConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/artifactregistry/v1/artifact_registry_connection_idempotency_policy.h b/google/cloud/artifactregistry/v1/artifact_registry_connection_idempotency_policy.h index be33f7bdcc7d7..251238093cb32 100644 --- a/google/cloud/artifactregistry/v1/artifact_registry_connection_idempotency_policy.h +++ b/google/cloud/artifactregistry/v1/artifact_registry_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -163,6 +164,12 @@ class ArtifactRegistryConnectionIdempotencyPolicy { virtual google::cloud::Idempotency UpdateVPCSCConfig( google::devtools::artifactregistry::v1::UpdateVPCSCConfigRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/artifactregistry/v1/internal/artifact_registry_auth_decorator.cc b/google/cloud/artifactregistry/v1/internal/artifact_registry_auth_decorator.cc index 1a11848156afa..3c675a85ad8eb 100644 --- a/google/cloud/artifactregistry/v1/internal/artifact_registry_auth_decorator.cc +++ b/google/cloud/artifactregistry/v1/internal/artifact_registry_auth_decorator.cc @@ -519,6 +519,23 @@ ArtifactRegistryAuth::UpdateVPCSCConfig( return child_->UpdateVPCSCConfig(context, options, request); } +StatusOr +ArtifactRegistryAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr ArtifactRegistryAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> ArtifactRegistryAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/artifactregistry/v1/internal/artifact_registry_auth_decorator.h b/google/cloud/artifactregistry/v1/internal/artifact_registry_auth_decorator.h index d668f406d5460..48895261b59b0 100644 --- a/google/cloud/artifactregistry/v1/internal/artifact_registry_auth_decorator.h +++ b/google/cloud/artifactregistry/v1/internal/artifact_registry_auth_decorator.h @@ -277,6 +277,14 @@ class ArtifactRegistryAuth : public ArtifactRegistryStub { google::devtools::artifactregistry::v1::UpdateVPCSCConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/artifactregistry/v1/internal/artifact_registry_connection_impl.cc b/google/cloud/artifactregistry/v1/internal/artifact_registry_connection_impl.cc index ea34380a2ec96..128269ad83034 100644 --- a/google/cloud/artifactregistry/v1/internal/artifact_registry_connection_impl.cc +++ b/google/cloud/artifactregistry/v1/internal/artifact_registry_connection_impl.cc @@ -1375,6 +1375,55 @@ ArtifactRegistryConnectionImpl::UpdateVPCSCConfig( *current, request, __func__); } +StreamRange +ArtifactRegistryConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = + std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ArtifactRegistryConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace artifactregistry_v1_internal } // namespace cloud diff --git a/google/cloud/artifactregistry/v1/internal/artifact_registry_connection_impl.h b/google/cloud/artifactregistry/v1/internal/artifact_registry_connection_impl.h index 11cc11c07cc3d..2ccebe5f0e0e2 100644 --- a/google/cloud/artifactregistry/v1/internal/artifact_registry_connection_impl.h +++ b/google/cloud/artifactregistry/v1/internal/artifact_registry_connection_impl.h @@ -270,6 +270,12 @@ class ArtifactRegistryConnectionImpl google::devtools::artifactregistry::v1::UpdateVPCSCConfigRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/artifactregistry/v1/internal/artifact_registry_logging_decorator.cc b/google/cloud/artifactregistry/v1/internal/artifact_registry_logging_decorator.cc index 21e1bd01e0a4d..fa07debdbe92d 100644 --- a/google/cloud/artifactregistry/v1/internal/artifact_registry_logging_decorator.cc +++ b/google/cloud/artifactregistry/v1/internal/artifact_registry_logging_decorator.cc @@ -669,6 +669,30 @@ ArtifactRegistryLogging::UpdateVPCSCConfig( context, options, request, __func__, tracing_options_); } +StatusOr +ArtifactRegistryLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ArtifactRegistryLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ArtifactRegistryLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/artifactregistry/v1/internal/artifact_registry_logging_decorator.h b/google/cloud/artifactregistry/v1/internal/artifact_registry_logging_decorator.h index c93559e8d65fb..64872a81a2d7c 100644 --- a/google/cloud/artifactregistry/v1/internal/artifact_registry_logging_decorator.h +++ b/google/cloud/artifactregistry/v1/internal/artifact_registry_logging_decorator.h @@ -277,6 +277,14 @@ class ArtifactRegistryLogging : public ArtifactRegistryStub { google::devtools::artifactregistry::v1::UpdateVPCSCConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/artifactregistry/v1/internal/artifact_registry_metadata_decorator.cc b/google/cloud/artifactregistry/v1/internal/artifact_registry_metadata_decorator.cc index 2a32002cb2e6a..2fbbfecbc0cfa 100644 --- a/google/cloud/artifactregistry/v1/internal/artifact_registry_metadata_decorator.cc +++ b/google/cloud/artifactregistry/v1/internal/artifact_registry_metadata_decorator.cc @@ -488,6 +488,24 @@ ArtifactRegistryMetadata::UpdateVPCSCConfig( return child_->UpdateVPCSCConfig(context, options, request); } +StatusOr +ArtifactRegistryMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +ArtifactRegistryMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> ArtifactRegistryMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/artifactregistry/v1/internal/artifact_registry_metadata_decorator.h b/google/cloud/artifactregistry/v1/internal/artifact_registry_metadata_decorator.h index 11ce366a5c8e1..747f2e222dd9a 100644 --- a/google/cloud/artifactregistry/v1/internal/artifact_registry_metadata_decorator.h +++ b/google/cloud/artifactregistry/v1/internal/artifact_registry_metadata_decorator.h @@ -278,6 +278,14 @@ class ArtifactRegistryMetadata : public ArtifactRegistryStub { google::devtools::artifactregistry::v1::UpdateVPCSCConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/artifactregistry/v1/internal/artifact_registry_stub.cc b/google/cloud/artifactregistry/v1/internal/artifact_registry_stub.cc index db0ece648912c..1231470a9ea0c 100644 --- a/google/cloud/artifactregistry/v1/internal/artifact_registry_stub.cc +++ b/google/cloud/artifactregistry/v1/internal/artifact_registry_stub.cc @@ -626,6 +626,30 @@ DefaultArtifactRegistryStub::UpdateVPCSCConfig( return response; } +StatusOr +DefaultArtifactRegistryStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultArtifactRegistryStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultArtifactRegistryStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/artifactregistry/v1/internal/artifact_registry_stub.h b/google/cloud/artifactregistry/v1/internal/artifact_registry_stub.h index 7d50098b40417..b3cd8843e3499 100644 --- a/google/cloud/artifactregistry/v1/internal/artifact_registry_stub.h +++ b/google/cloud/artifactregistry/v1/internal/artifact_registry_stub.h @@ -24,6 +24,8 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include #include @@ -290,6 +292,15 @@ class ArtifactRegistryStub { google::devtools::artifactregistry::v1::UpdateVPCSCConfigRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -309,9 +320,13 @@ class DefaultArtifactRegistryStub : public ArtifactRegistryStub { std::unique_ptr grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListDockerImages( @@ -551,6 +566,14 @@ class DefaultArtifactRegistryStub : public ArtifactRegistryStub { google::devtools::artifactregistry::v1::UpdateVPCSCConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -567,6 +590,8 @@ class DefaultArtifactRegistryStub : public ArtifactRegistryStub { std::unique_ptr< google::devtools::artifactregistry::v1::ArtifactRegistry::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/artifactregistry/v1/internal/artifact_registry_stub_factory.cc b/google/cloud/artifactregistry/v1/internal/artifact_registry_stub_factory.cc index 70b0150ffe6b7..11c7ec1b1e498 100644 --- a/google/cloud/artifactregistry/v1/internal/artifact_registry_stub_factory.cc +++ b/google/cloud/artifactregistry/v1/internal/artifact_registry_stub_factory.cc @@ -28,6 +28,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -45,9 +46,11 @@ std::shared_ptr CreateDefaultArtifactRegistryStub( auto service_grpc_stub = google::devtools::artifactregistry::v1::ArtifactRegistry::NewStub( channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/artifactregistry/v1/internal/artifact_registry_tracing_connection.cc b/google/cloud/artifactregistry/v1/internal/artifact_registry_tracing_connection.cc index 3ca94d6bc7fd4..8341e3a7f8248 100644 --- a/google/cloud/artifactregistry/v1/internal/artifact_registry_tracing_connection.cc +++ b/google/cloud/artifactregistry/v1/internal/artifact_registry_tracing_connection.cc @@ -559,6 +559,26 @@ ArtifactRegistryTracingConnection::UpdateVPCSCConfig( return internal::EndSpan(*span, child_->UpdateVPCSCConfig(request)); } +StreamRange +ArtifactRegistryTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "artifactregistry_v1::ArtifactRegistryConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ArtifactRegistryTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "artifactregistry_v1::ArtifactRegistryConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/artifactregistry/v1/internal/artifact_registry_tracing_connection.h b/google/cloud/artifactregistry/v1/internal/artifact_registry_tracing_connection.h index eefc534c0430b..a1fb4cfca4a27 100644 --- a/google/cloud/artifactregistry/v1/internal/artifact_registry_tracing_connection.h +++ b/google/cloud/artifactregistry/v1/internal/artifact_registry_tracing_connection.h @@ -258,6 +258,12 @@ class ArtifactRegistryTracingConnection google::devtools::artifactregistry::v1::UpdateVPCSCConfigRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/artifactregistry/v1/internal/artifact_registry_tracing_stub.cc b/google/cloud/artifactregistry/v1/internal/artifact_registry_tracing_stub.cc index 862165a7cdc2a..d67d48a07ec92 100644 --- a/google/cloud/artifactregistry/v1/internal/artifact_registry_tracing_stub.cc +++ b/google/cloud/artifactregistry/v1/internal/artifact_registry_tracing_stub.cc @@ -617,6 +617,30 @@ ArtifactRegistryTracingStub::UpdateVPCSCConfig( context, *span, child_->UpdateVPCSCConfig(context, options, request)); } +StatusOr +ArtifactRegistryTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.devtools.artifactregistry.v1.ArtifactRegistry", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +ArtifactRegistryTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.devtools.artifactregistry.v1.ArtifactRegistry", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> ArtifactRegistryTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/artifactregistry/v1/internal/artifact_registry_tracing_stub.h b/google/cloud/artifactregistry/v1/internal/artifact_registry_tracing_stub.h index 09f7d2abad5cf..20315266e2ed7 100644 --- a/google/cloud/artifactregistry/v1/internal/artifact_registry_tracing_stub.h +++ b/google/cloud/artifactregistry/v1/internal/artifact_registry_tracing_stub.h @@ -277,6 +277,14 @@ class ArtifactRegistryTracingStub : public ArtifactRegistryStub { google::devtools::artifactregistry::v1::UpdateVPCSCConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/artifactregistry/v1/mocks/mock_artifact_registry_connection.h b/google/cloud/artifactregistry/v1/mocks/mock_artifact_registry_connection.h index 584b7463119b2..3d50d6de04c7b 100644 --- a/google/cloud/artifactregistry/v1/mocks/mock_artifact_registry_connection.h +++ b/google/cloud/artifactregistry/v1/mocks/mock_artifact_registry_connection.h @@ -525,6 +525,14 @@ class MockArtifactRegistryConnection (google::devtools::artifactregistry::v1::UpdateVPCSCConfigRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/backupdr/BUILD.bazel b/google/cloud/backupdr/BUILD.bazel index 3376b9ace5870..1c9489d3231f9 100644 --- a/google/cloud/backupdr/BUILD.bazel +++ b/google/cloud/backupdr/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/backupdr/v1:backupdr_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/backupdr/v1/backup_dr_client.cc b/google/cloud/backupdr/v1/backup_dr_client.cc index bd0fd593c93a5..817d8c4910a35 100644 --- a/google/cloud/backupdr/v1/backup_dr_client.cc +++ b/google/cloud/backupdr/v1/backup_dr_client.cc @@ -151,6 +151,37 @@ BackupDRClient::DeleteManagementServer( return connection_->DeleteManagementServer(operation); } +StreamRange BackupDRClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr BackupDRClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr BackupDRClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr BackupDRClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +BackupDRClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace backupdr_v1 } // namespace cloud diff --git a/google/cloud/backupdr/v1/backup_dr_client.h b/google/cloud/backupdr/v1/backup_dr_client.h index 0e304acba7b88..71ab449014630 100644 --- a/google/cloud/backupdr/v1/backup_dr_client.h +++ b/google/cloud/backupdr/v1/backup_dr_client.h @@ -461,6 +461,178 @@ class BackupDRClient { DeleteManagementServer(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/backupdr/v1/backup_dr_connection.cc b/google/cloud/backupdr/v1/backup_dr_connection.cc index efe832af435bc..43e43dbf30a6e 100644 --- a/google/cloud/backupdr/v1/backup_dr_connection.cc +++ b/google/cloud/backupdr/v1/backup_dr_connection.cc @@ -100,6 +100,35 @@ BackupDRConnection::DeleteManagementServer( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +BackupDRConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr BackupDRConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr BackupDRConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr BackupDRConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +BackupDRConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeBackupDRConnection(Options options) { internal::CheckExpectedOptions +#include +#include #include #include @@ -216,6 +218,21 @@ class BackupDRConnection { virtual future> DeleteManagementServer(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/backupdr/v1/backup_dr_connection_idempotency_policy.cc b/google/cloud/backupdr/v1/backup_dr_connection_idempotency_policy.cc index be7d6612409c2..7a922151cb4bf 100644 --- a/google/cloud/backupdr/v1/backup_dr_connection_idempotency_policy.cc +++ b/google/cloud/backupdr/v1/backup_dr_connection_idempotency_policy.cc @@ -54,6 +54,32 @@ Idempotency BackupDRConnectionIdempotencyPolicy::DeleteManagementServer( return Idempotency::kNonIdempotent; } +Idempotency BackupDRConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency BackupDRConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency BackupDRConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency BackupDRConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency BackupDRConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultBackupDRConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/backupdr/v1/backup_dr_connection_idempotency_policy.h b/google/cloud/backupdr/v1/backup_dr_connection_idempotency_policy.h index 53d9f9c33d69a..2c965a1a362b7 100644 --- a/google/cloud/backupdr/v1/backup_dr_connection_idempotency_policy.h +++ b/google/cloud/backupdr/v1/backup_dr_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -49,6 +51,21 @@ class BackupDRConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteManagementServer( google::cloud::backupdr::v1::DeleteManagementServerRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/backupdr/v1/internal/backup_dr_auth_decorator.cc b/google/cloud/backupdr/v1/internal/backup_dr_auth_decorator.cc index 62c7ec3b8b3b4..f0a9b9c71fbed 100644 --- a/google/cloud/backupdr/v1/internal/backup_dr_auth_decorator.cc +++ b/google/cloud/backupdr/v1/internal/backup_dr_auth_decorator.cc @@ -105,6 +105,48 @@ StatusOr BackupDRAuth::DeleteManagementServer( return child_->DeleteManagementServer(context, options, request); } +StatusOr +BackupDRAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr BackupDRAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr BackupDRAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr BackupDRAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +BackupDRAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> BackupDRAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/backupdr/v1/internal/backup_dr_auth_decorator.h b/google/cloud/backupdr/v1/internal/backup_dr_auth_decorator.h index 4cade373002d4..782070ce5c092 100644 --- a/google/cloud/backupdr/v1/internal/backup_dr_auth_decorator.h +++ b/google/cloud/backupdr/v1/internal/backup_dr_auth_decorator.h @@ -74,6 +74,26 @@ class BackupDRAuth : public BackupDRStub { google::cloud::backupdr::v1::DeleteManagementServerRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/backupdr/v1/internal/backup_dr_connection_impl.cc b/google/cloud/backupdr/v1/internal/backup_dr_connection_impl.cc index e20f3e4b0753d..2c55f5383c678 100644 --- a/google/cloud/backupdr/v1/internal/backup_dr_connection_impl.cc +++ b/google/cloud/backupdr/v1/internal/backup_dr_connection_impl.cc @@ -299,6 +299,93 @@ BackupDRConnectionImpl::DeleteManagementServer( polling_policy(*current), __func__); } +StreamRange +BackupDRConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr BackupDRConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr BackupDRConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr BackupDRConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +BackupDRConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace backupdr_v1_internal } // namespace cloud diff --git a/google/cloud/backupdr/v1/internal/backup_dr_connection_impl.h b/google/cloud/backupdr/v1/internal/backup_dr_connection_impl.h index cda06f215cae9..78bb27988103a 100644 --- a/google/cloud/backupdr/v1/internal/backup_dr_connection_impl.h +++ b/google/cloud/backupdr/v1/internal/backup_dr_connection_impl.h @@ -88,6 +88,21 @@ class BackupDRConnectionImpl : public backupdr_v1::BackupDRConnection { DeleteManagementServer( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/backupdr/v1/internal/backup_dr_logging_decorator.cc b/google/cloud/backupdr/v1/internal/backup_dr_logging_decorator.cc index 9e762abcd802d..38a3134cde9b9 100644 --- a/google/cloud/backupdr/v1/internal/backup_dr_logging_decorator.cc +++ b/google/cloud/backupdr/v1/internal/backup_dr_logging_decorator.cc @@ -125,6 +125,63 @@ BackupDRLogging::DeleteManagementServer( context, options, request, __func__, tracing_options_); } +StatusOr +BackupDRLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr BackupDRLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr BackupDRLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr BackupDRLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +BackupDRLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> BackupDRLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/backupdr/v1/internal/backup_dr_logging_decorator.h b/google/cloud/backupdr/v1/internal/backup_dr_logging_decorator.h index 7a3b5cf81bd52..2eb43772bb3a8 100644 --- a/google/cloud/backupdr/v1/internal/backup_dr_logging_decorator.h +++ b/google/cloud/backupdr/v1/internal/backup_dr_logging_decorator.h @@ -74,6 +74,26 @@ class BackupDRLogging : public BackupDRStub { google::cloud::backupdr::v1::DeleteManagementServerRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/backupdr/v1/internal/backup_dr_metadata_decorator.cc b/google/cloud/backupdr/v1/internal/backup_dr_metadata_decorator.cc index 8ab128679353f..4de7e128232b1 100644 --- a/google/cloud/backupdr/v1/internal/backup_dr_metadata_decorator.cc +++ b/google/cloud/backupdr/v1/internal/backup_dr_metadata_decorator.cc @@ -104,6 +104,51 @@ BackupDRMetadata::DeleteManagementServer( return child_->DeleteManagementServer(context, options, request); } +StatusOr +BackupDRMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr BackupDRMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr BackupDRMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr BackupDRMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +BackupDRMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> BackupDRMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/backupdr/v1/internal/backup_dr_metadata_decorator.h b/google/cloud/backupdr/v1/internal/backup_dr_metadata_decorator.h index 29017d1e67372..1ecc43e17c435 100644 --- a/google/cloud/backupdr/v1/internal/backup_dr_metadata_decorator.h +++ b/google/cloud/backupdr/v1/internal/backup_dr_metadata_decorator.h @@ -74,6 +74,26 @@ class BackupDRMetadata : public BackupDRStub { google::cloud::backupdr::v1::DeleteManagementServerRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/backupdr/v1/internal/backup_dr_stub.cc b/google/cloud/backupdr/v1/internal/backup_dr_stub.cc index 400080a0400ca..23dd77ddb5a3b 100644 --- a/google/cloud/backupdr/v1/internal/backup_dr_stub.cc +++ b/google/cloud/backupdr/v1/internal/backup_dr_stub.cc @@ -119,6 +119,64 @@ DefaultBackupDRStub::DeleteManagementServer( return response; } +StatusOr +DefaultBackupDRStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultBackupDRStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultBackupDRStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultBackupDRStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultBackupDRStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultBackupDRStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/backupdr/v1/internal/backup_dr_stub.h b/google/cloud/backupdr/v1/internal/backup_dr_stub.h index 53ed77e9c9c9e..a819487a061b6 100644 --- a/google/cloud/backupdr/v1/internal/backup_dr_stub.h +++ b/google/cloud/backupdr/v1/internal/backup_dr_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -76,6 +80,28 @@ class BackupDRStub { google::cloud::backupdr::v1::DeleteManagementServerRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -94,9 +120,15 @@ class DefaultBackupDRStub : public BackupDRStub { DefaultBackupDRStub( std::unique_ptr grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListManagementServers( @@ -133,6 +165,26 @@ class DefaultBackupDRStub : public BackupDRStub { google::cloud::backupdr::v1::DeleteManagementServerRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -148,6 +200,9 @@ class DefaultBackupDRStub : public BackupDRStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/backupdr/v1/internal/backup_dr_stub_factory.cc b/google/cloud/backupdr/v1/internal/backup_dr_stub_factory.cc index b70cde8fb6ae1..63419a8a6c454 100644 --- a/google/cloud/backupdr/v1/internal/backup_dr_stub_factory.cc +++ b/google/cloud/backupdr/v1/internal/backup_dr_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,8 +46,12 @@ std::shared_ptr CreateDefaultBackupDRStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::backupdr::v1::BackupDR::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/backupdr/v1/internal/backup_dr_tracing_connection.cc b/google/cloud/backupdr/v1/internal/backup_dr_tracing_connection.cc index 8a6203db11453..6d9cfebe0fb40 100644 --- a/google/cloud/backupdr/v1/internal/backup_dr_tracing_connection.cc +++ b/google/cloud/backupdr/v1/internal/backup_dr_tracing_connection.cc @@ -116,6 +116,51 @@ BackupDRTracingConnection::DeleteManagementServer( child_->DeleteManagementServer(operation)); } +StreamRange +BackupDRTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("backupdr_v1::BackupDRConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +BackupDRTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("backupdr_v1::BackupDRConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr BackupDRTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("backupdr_v1::BackupDRConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr BackupDRTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("backupdr_v1::BackupDRConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +BackupDRTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = + internal::MakeSpan("backupdr_v1::BackupDRConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeBackupDRTracingConnection( diff --git a/google/cloud/backupdr/v1/internal/backup_dr_tracing_connection.h b/google/cloud/backupdr/v1/internal/backup_dr_tracing_connection.h index 0628c8b8fbae5..7fd2448cc6794 100644 --- a/google/cloud/backupdr/v1/internal/backup_dr_tracing_connection.h +++ b/google/cloud/backupdr/v1/internal/backup_dr_tracing_connection.h @@ -76,6 +76,21 @@ class BackupDRTracingConnection : public backupdr_v1::BackupDRConnection { DeleteManagementServer( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/backupdr/v1/internal/backup_dr_tracing_stub.cc b/google/cloud/backupdr/v1/internal/backup_dr_tracing_stub.cc index 88790b81f4d37..dbc9804588c63 100644 --- a/google/cloud/backupdr/v1/internal/backup_dr_tracing_stub.cc +++ b/google/cloud/backupdr/v1/internal/backup_dr_tracing_stub.cc @@ -111,6 +111,63 @@ BackupDRTracingStub::DeleteManagementServer( child_->DeleteManagementServer(context, options, request)); } +StatusOr +BackupDRTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.backupdr.v1.BackupDR", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr BackupDRTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.backupdr.v1.BackupDR", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr BackupDRTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.backupdr.v1.BackupDR", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr BackupDRTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.backupdr.v1.BackupDR", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +BackupDRTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.backupdr.v1.BackupDR", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> BackupDRTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/backupdr/v1/internal/backup_dr_tracing_stub.h b/google/cloud/backupdr/v1/internal/backup_dr_tracing_stub.h index 672ea6699dd9c..5c17829f6265a 100644 --- a/google/cloud/backupdr/v1/internal/backup_dr_tracing_stub.h +++ b/google/cloud/backupdr/v1/internal/backup_dr_tracing_stub.h @@ -73,6 +73,26 @@ class BackupDRTracingStub : public BackupDRStub { google::cloud::backupdr::v1::DeleteManagementServerRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/backupdr/v1/mocks/mock_backup_dr_connection.h b/google/cloud/backupdr/v1/mocks/mock_backup_dr_connection.h index 6530e2c245d01..53938df42b536 100644 --- a/google/cloud/backupdr/v1/mocks/mock_backup_dr_connection.h +++ b/google/cloud/backupdr/v1/mocks/mock_backup_dr_connection.h @@ -135,6 +135,27 @@ class MockBackupDRConnection : public backupdr_v1::BackupDRConnection { MOCK_METHOD(future>, DeleteManagementServer, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/baremetalsolution/BUILD.bazel b/google/cloud/baremetalsolution/BUILD.bazel index d716d05083e07..48cbf5c248857 100644 --- a/google/cloud/baremetalsolution/BUILD.bazel +++ b/google/cloud/baremetalsolution/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/baremetalsolution/v2:baremetalsolution_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/baremetalsolution/v2/bare_metal_solution_client.cc b/google/cloud/baremetalsolution/v2/bare_metal_solution_client.cc index 989721ac9f129..30691e8b893d0 100644 --- a/google/cloud/baremetalsolution/v2/bare_metal_solution_client.cc +++ b/google/cloud/baremetalsolution/v2/bare_metal_solution_client.cc @@ -1221,6 +1221,20 @@ BareMetalSolutionClient::ListOSImages( return connection_->ListOSImages(std::move(request)); } +StreamRange +BareMetalSolutionClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +BareMetalSolutionClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace baremetalsolution_v2 } // namespace cloud diff --git a/google/cloud/baremetalsolution/v2/bare_metal_solution_client.h b/google/cloud/baremetalsolution/v2/bare_metal_solution_client.h index 79974c28f9f5a..39b35d15feee9 100644 --- a/google/cloud/baremetalsolution/v2/bare_metal_solution_client.h +++ b/google/cloud/baremetalsolution/v2/bare_metal_solution_client.h @@ -3793,6 +3793,76 @@ class BareMetalSolutionClient { google::cloud::baremetalsolution::v2::ListOSImagesRequest request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/baremetalsolution/v2/bare_metal_solution_connection.cc b/google/cloud/baremetalsolution/v2/bare_metal_solution_connection.cc index 8432f5fdc97a3..048387ab0cccf 100644 --- a/google/cloud/baremetalsolution/v2/bare_metal_solution_connection.cc +++ b/google/cloud/baremetalsolution/v2/bare_metal_solution_connection.cc @@ -613,6 +613,20 @@ BareMetalSolutionConnection::ListOSImages( StreamRange>(); } +StreamRange +BareMetalSolutionConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +BareMetalSolutionConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeBareMetalSolutionConnection( Options options) { internal::CheckExpectedOptions +#include +#include #include #include @@ -511,6 +513,12 @@ class BareMetalSolutionConnection { virtual StreamRange ListOSImages( google::cloud::baremetalsolution::v2::ListOSImagesRequest request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/baremetalsolution/v2/bare_metal_solution_connection_idempotency_policy.cc b/google/cloud/baremetalsolution/v2/bare_metal_solution_connection_idempotency_policy.cc index ca2edc1a52c64..e3981d6c37752 100644 --- a/google/cloud/baremetalsolution/v2/bare_metal_solution_connection_idempotency_policy.cc +++ b/google/cloud/baremetalsolution/v2/bare_metal_solution_connection_idempotency_policy.cc @@ -267,6 +267,16 @@ Idempotency BareMetalSolutionConnectionIdempotencyPolicy::ListOSImages( return Idempotency::kIdempotent; } +Idempotency BareMetalSolutionConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency BareMetalSolutionConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultBareMetalSolutionConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/baremetalsolution/v2/bare_metal_solution_connection_idempotency_policy.h b/google/cloud/baremetalsolution/v2/bare_metal_solution_connection_idempotency_policy.h index 8608ae5963a33..acbb0d4e5581d 100644 --- a/google/cloud/baremetalsolution/v2/bare_metal_solution_connection_idempotency_policy.h +++ b/google/cloud/baremetalsolution/v2/bare_metal_solution_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -190,6 +191,12 @@ class BareMetalSolutionConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListOSImages( google::cloud::baremetalsolution::v2::ListOSImagesRequest request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_auth_decorator.cc b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_auth_decorator.cc index 73e42f6affd7f..939b5d383e175 100644 --- a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_auth_decorator.cc +++ b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_auth_decorator.cc @@ -758,6 +758,23 @@ BareMetalSolutionAuth::ListOSImages( return child_->ListOSImages(context, options, request); } +StatusOr +BareMetalSolutionAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr BareMetalSolutionAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> BareMetalSolutionAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_auth_decorator.h b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_auth_decorator.h index 29cd5d6db3619..6588653dd4740 100644 --- a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_auth_decorator.h +++ b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_auth_decorator.h @@ -385,6 +385,14 @@ class BareMetalSolutionAuth : public BareMetalSolutionStub { google::cloud::baremetalsolution::v2::ListOSImagesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_connection_impl.cc b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_connection_impl.cc index 8961b7df2f8f6..357509c895735 100644 --- a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_connection_impl.cc +++ b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_connection_impl.cc @@ -2218,6 +2218,55 @@ BareMetalSolutionConnectionImpl::ListOSImages( }); } +StreamRange +BareMetalSolutionConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = + std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +BareMetalSolutionConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace baremetalsolution_v2_internal } // namespace cloud diff --git a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_connection_impl.h b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_connection_impl.h index a93e4c7b18372..8ef115e2a414f 100644 --- a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_connection_impl.h +++ b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_connection_impl.h @@ -382,6 +382,12 @@ class BareMetalSolutionConnectionImpl google::cloud::baremetalsolution::v2::ListOSImagesRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_logging_decorator.cc b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_logging_decorator.cc index ba40b8e5f90c5..6907cf41d8522 100644 --- a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_logging_decorator.cc +++ b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_logging_decorator.cc @@ -933,6 +933,30 @@ BareMetalSolutionLogging::ListOSImages( context, options, request, __func__, tracing_options_); } +StatusOr +BareMetalSolutionLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +BareMetalSolutionLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> BareMetalSolutionLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_logging_decorator.h b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_logging_decorator.h index c6c17d9543797..598d103e6eaa4 100644 --- a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_logging_decorator.h +++ b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_logging_decorator.h @@ -385,6 +385,14 @@ class BareMetalSolutionLogging : public BareMetalSolutionStub { google::cloud::baremetalsolution::v2::ListOSImagesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_metadata_decorator.cc b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_metadata_decorator.cc index b945a21f3449c..1c83cad6e1500 100644 --- a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_metadata_decorator.cc +++ b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_metadata_decorator.cc @@ -668,6 +668,24 @@ BareMetalSolutionMetadata::ListOSImages( return child_->ListOSImages(context, options, request); } +StatusOr +BareMetalSolutionMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +BareMetalSolutionMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> BareMetalSolutionMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_metadata_decorator.h b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_metadata_decorator.h index 4098a82ce0282..981c882851e8d 100644 --- a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_metadata_decorator.h +++ b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_metadata_decorator.h @@ -386,6 +386,14 @@ class BareMetalSolutionMetadata : public BareMetalSolutionStub { google::cloud::baremetalsolution::v2::ListOSImagesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_stub.cc b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_stub.cc index 38ecaee707ec8..98a5b7242fe3e 100644 --- a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_stub.cc +++ b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_stub.cc @@ -895,6 +895,30 @@ DefaultBareMetalSolutionStub::ListOSImages( return response; } +StatusOr +DefaultBareMetalSolutionStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultBareMetalSolutionStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultBareMetalSolutionStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_stub.h b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_stub.h index 12a0769467b4b..43ffe361a45e4 100644 --- a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_stub.h +++ b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_stub.h @@ -25,6 +25,9 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include #include #include #include @@ -389,6 +392,15 @@ class BareMetalSolutionStub { google::cloud::baremetalsolution::v2::ListOSImagesRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -408,9 +420,13 @@ class DefaultBareMetalSolutionStub : public BareMetalSolutionStub { std::unique_ptr grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListInstances( @@ -758,6 +774,14 @@ class DefaultBareMetalSolutionStub : public BareMetalSolutionStub { google::cloud::baremetalsolution::v2::ListOSImagesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -774,6 +798,8 @@ class DefaultBareMetalSolutionStub : public BareMetalSolutionStub { std::unique_ptr< google::cloud::baremetalsolution::v2::BareMetalSolution::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_stub_factory.cc b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_stub_factory.cc index 76af4613f12f9..5154b14bf2ae9 100644 --- a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_stub_factory.cc +++ b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultBareMetalSolutionStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::baremetalsolution::v2::BareMetalSolution::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_tracing_connection.cc b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_tracing_connection.cc index 380a35da2e0a4..76f390f6fb1f3 100644 --- a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_tracing_connection.cc +++ b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_tracing_connection.cc @@ -814,6 +814,26 @@ BareMetalSolutionTracingConnection::ListOSImages( std::move(sr)); } +StreamRange +BareMetalSolutionTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "baremetalsolution_v2::BareMetalSolutionConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +BareMetalSolutionTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "baremetalsolution_v2::BareMetalSolutionConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_tracing_connection.h b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_tracing_connection.h index 5b2fe4bc2494d..f65c5fb6482db 100644 --- a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_tracing_connection.h +++ b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_tracing_connection.h @@ -369,6 +369,12 @@ class BareMetalSolutionTracingConnection google::cloud::baremetalsolution::v2::ListOSImagesRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_tracing_stub.cc b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_tracing_stub.cc index 7b98aaab9b241..ef74fcc5602a1 100644 --- a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_tracing_stub.cc +++ b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_tracing_stub.cc @@ -836,6 +836,30 @@ BareMetalSolutionTracingStub::ListOSImages( child_->ListOSImages(context, options, request)); } +StatusOr +BareMetalSolutionTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.baremetalsolution.v2.BareMetalSolution", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +BareMetalSolutionTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.baremetalsolution.v2.BareMetalSolution", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> BareMetalSolutionTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_tracing_stub.h b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_tracing_stub.h index 17411cc50706f..8bd6f4ddbbd6a 100644 --- a/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_tracing_stub.h +++ b/google/cloud/baremetalsolution/v2/internal/bare_metal_solution_tracing_stub.h @@ -385,6 +385,14 @@ class BareMetalSolutionTracingStub : public BareMetalSolutionStub { google::cloud::baremetalsolution::v2::ListOSImagesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/baremetalsolution/v2/mocks/mock_bare_metal_solution_connection.h b/google/cloud/baremetalsolution/v2/mocks/mock_bare_metal_solution_connection.h index a23ebea8da8c6..a3fc4c98a0a8a 100644 --- a/google/cloud/baremetalsolution/v2/mocks/mock_bare_metal_solution_connection.h +++ b/google/cloud/baremetalsolution/v2/mocks/mock_bare_metal_solution_connection.h @@ -867,6 +867,14 @@ class MockBareMetalSolutionConnection ListOSImages, (google::cloud::baremetalsolution::v2::ListOSImagesRequest request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/batch/BUILD.bazel b/google/cloud/batch/BUILD.bazel index 9592453d25621..d3f52cb88f72b 100644 --- a/google/cloud/batch/BUILD.bazel +++ b/google/cloud/batch/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/batch/v1:batch_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/batch/v1/batch_client.cc b/google/cloud/batch/v1/batch_client.cc index 81079a8d91b41..f76828edc3f7a 100644 --- a/google/cloud/batch/v1/batch_client.cc +++ b/google/cloud/batch/v1/batch_client.cc @@ -142,6 +142,19 @@ StreamRange BatchServiceClient::ListTasks( return connection_->ListTasks(std::move(request)); } +StreamRange +BatchServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr BatchServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace batch_v1 } // namespace cloud diff --git a/google/cloud/batch/v1/batch_client.h b/google/cloud/batch/v1/batch_client.h index 41b999cc9f71e..222c0f24cc81b 100644 --- a/google/cloud/batch/v1/batch_client.h +++ b/google/cloud/batch/v1/batch_client.h @@ -530,6 +530,76 @@ class BatchServiceClient { StreamRange ListTasks( google::cloud::batch::v1::ListTasksRequest request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/batch/v1/batch_connection.cc b/google/cloud/batch/v1/batch_connection.cc index c1394c2321014..8e64fa336a012 100644 --- a/google/cloud/batch/v1/batch_connection.cc +++ b/google/cloud/batch/v1/batch_connection.cc @@ -88,6 +88,19 @@ StreamRange BatchServiceConnection::ListTasks( StreamRange>(); } +StreamRange +BatchServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr BatchServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeBatchServiceConnection( Options options) { internal::CheckExpectedOptions +#include #include #include @@ -209,6 +210,12 @@ class BatchServiceConnection { virtual StreamRange ListTasks( google::cloud::batch::v1::ListTasksRequest request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/batch/v1/batch_connection_idempotency_policy.cc b/google/cloud/batch/v1/batch_connection_idempotency_policy.cc index 3cb3db40c591b..c5b935748d5eb 100644 --- a/google/cloud/batch/v1/batch_connection_idempotency_policy.cc +++ b/google/cloud/batch/v1/batch_connection_idempotency_policy.cc @@ -64,6 +64,16 @@ Idempotency BatchServiceConnectionIdempotencyPolicy::ListTasks( return Idempotency::kIdempotent; } +Idempotency BatchServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency BatchServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultBatchServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/batch/v1/batch_connection_idempotency_policy.h b/google/cloud/batch/v1/batch_connection_idempotency_policy.h index b56d25347a6ed..09878840df105 100644 --- a/google/cloud/batch/v1/batch_connection_idempotency_policy.h +++ b/google/cloud/batch/v1/batch_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -54,6 +55,12 @@ class BatchServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListTasks( google::cloud::batch::v1::ListTasksRequest request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/batch/v1/internal/batch_auth_decorator.cc b/google/cloud/batch/v1/internal/batch_auth_decorator.cc index 88811e9c06db8..8262cfd5accbc 100644 --- a/google/cloud/batch/v1/internal/batch_auth_decorator.cc +++ b/google/cloud/batch/v1/internal/batch_auth_decorator.cc @@ -100,6 +100,23 @@ BatchServiceAuth::ListTasks( return child_->ListTasks(context, options, request); } +StatusOr +BatchServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr BatchServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> BatchServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/batch/v1/internal/batch_auth_decorator.h b/google/cloud/batch/v1/internal/batch_auth_decorator.h index decd8e0e34440..707f8b4b63e5e 100644 --- a/google/cloud/batch/v1/internal/batch_auth_decorator.h +++ b/google/cloud/batch/v1/internal/batch_auth_decorator.h @@ -69,6 +69,14 @@ class BatchServiceAuth : public BatchServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::batch::v1::ListTasksRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/batch/v1/internal/batch_connection_impl.cc b/google/cloud/batch/v1/internal/batch_connection_impl.cc index f7e58f4d52b45..c3f4713277442 100644 --- a/google/cloud/batch/v1/internal/batch_connection_impl.cc +++ b/google/cloud/batch/v1/internal/batch_connection_impl.cc @@ -252,6 +252,54 @@ BatchServiceConnectionImpl::ListTasks( }); } +StreamRange +BatchServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +BatchServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace batch_v1_internal } // namespace cloud diff --git a/google/cloud/batch/v1/internal/batch_connection_impl.h b/google/cloud/batch/v1/internal/batch_connection_impl.h index ac7b8a263c715..405438c9b2f37 100644 --- a/google/cloud/batch/v1/internal/batch_connection_impl.h +++ b/google/cloud/batch/v1/internal/batch_connection_impl.h @@ -76,6 +76,12 @@ class BatchServiceConnectionImpl : public batch_v1::BatchServiceConnection { StreamRange ListTasks( google::cloud::batch::v1::ListTasksRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/batch/v1/internal/batch_logging_decorator.cc b/google/cloud/batch/v1/internal/batch_logging_decorator.cc index d45315a21e408..8f985d54884aa 100644 --- a/google/cloud/batch/v1/internal/batch_logging_decorator.cc +++ b/google/cloud/batch/v1/internal/batch_logging_decorator.cc @@ -121,6 +121,29 @@ BatchServiceLogging::ListTasks( context, options, request, __func__, tracing_options_); } +StatusOr +BatchServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr BatchServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> BatchServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/batch/v1/internal/batch_logging_decorator.h b/google/cloud/batch/v1/internal/batch_logging_decorator.h index 5bfc766cdb9d2..7d63c81e46403 100644 --- a/google/cloud/batch/v1/internal/batch_logging_decorator.h +++ b/google/cloud/batch/v1/internal/batch_logging_decorator.h @@ -69,6 +69,14 @@ class BatchServiceLogging : public BatchServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::batch::v1::ListTasksRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/batch/v1/internal/batch_metadata_decorator.cc b/google/cloud/batch/v1/internal/batch_metadata_decorator.cc index 0b1b22c46b617..6c733d26191ea 100644 --- a/google/cloud/batch/v1/internal/batch_metadata_decorator.cc +++ b/google/cloud/batch/v1/internal/batch_metadata_decorator.cc @@ -106,6 +106,23 @@ BatchServiceMetadata::ListTasks( return child_->ListTasks(context, options, request); } +StatusOr +BatchServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr BatchServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> BatchServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/batch/v1/internal/batch_metadata_decorator.h b/google/cloud/batch/v1/internal/batch_metadata_decorator.h index 95c0bc76d638d..734daf8ed1801 100644 --- a/google/cloud/batch/v1/internal/batch_metadata_decorator.h +++ b/google/cloud/batch/v1/internal/batch_metadata_decorator.h @@ -69,6 +69,14 @@ class BatchServiceMetadata : public BatchServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::batch::v1::ListTasksRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/batch/v1/internal/batch_stub.cc b/google/cloud/batch/v1/internal/batch_stub.cc index 18b4265d4fc67..58c349e502994 100644 --- a/google/cloud/batch/v1/internal/batch_stub.cc +++ b/google/cloud/batch/v1/internal/batch_stub.cc @@ -116,6 +116,30 @@ DefaultBatchServiceStub::ListTasks( return response; } +StatusOr +DefaultBatchServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultBatchServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultBatchServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/batch/v1/internal/batch_stub.h b/google/cloud/batch/v1/internal/batch_stub.h index 4c7d603ffb24c..fc458408a6bc5 100644 --- a/google/cloud/batch/v1/internal/batch_stub.h +++ b/google/cloud/batch/v1/internal/batch_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -68,6 +70,15 @@ class BatchServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::batch::v1::ListTasksRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -86,9 +97,13 @@ class DefaultBatchServiceStub : public BatchServiceStub { DefaultBatchServiceStub( std::unique_ptr grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr CreateJob( grpc::ClientContext& context, Options const& options, @@ -120,6 +135,14 @@ class DefaultBatchServiceStub : public BatchServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::batch::v1::ListTasksRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -135,6 +158,8 @@ class DefaultBatchServiceStub : public BatchServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/batch/v1/internal/batch_stub_factory.cc b/google/cloud/batch/v1/internal/batch_stub_factory.cc index c06534a5f8287..3121a2a794792 100644 --- a/google/cloud/batch/v1/internal/batch_stub_factory.cc +++ b/google/cloud/batch/v1/internal/batch_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultBatchServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::batch::v1::BatchService::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/batch/v1/internal/batch_tracing_connection.cc b/google/cloud/batch/v1/internal/batch_tracing_connection.cc index bf088f6128dc8..2d56bafb83830 100644 --- a/google/cloud/batch/v1/internal/batch_tracing_connection.cc +++ b/google/cloud/batch/v1/internal/batch_tracing_connection.cc @@ -99,6 +99,26 @@ BatchServiceTracingConnection::ListTasks( std::move(span), std::move(sr)); } +StreamRange +BatchServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("batch_v1::BatchServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +BatchServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("batch_v1::BatchServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/batch/v1/internal/batch_tracing_connection.h b/google/cloud/batch/v1/internal/batch_tracing_connection.h index da72619097584..f17afb9472901 100644 --- a/google/cloud/batch/v1/internal/batch_tracing_connection.h +++ b/google/cloud/batch/v1/internal/batch_tracing_connection.h @@ -64,6 +64,12 @@ class BatchServiceTracingConnection : public batch_v1::BatchServiceConnection { StreamRange ListTasks( google::cloud::batch::v1::ListTasksRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/batch/v1/internal/batch_tracing_stub.cc b/google/cloud/batch/v1/internal/batch_tracing_stub.cc index 2ed1428f1c2e5..5990f44e49eac 100644 --- a/google/cloud/batch/v1/internal/batch_tracing_stub.cc +++ b/google/cloud/batch/v1/internal/batch_tracing_stub.cc @@ -114,6 +114,30 @@ BatchServiceTracingStub::ListTasks( child_->ListTasks(context, options, request)); } +StatusOr +BatchServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.batch.v1.BatchService", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +BatchServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.batch.v1.BatchService", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> BatchServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/batch/v1/internal/batch_tracing_stub.h b/google/cloud/batch/v1/internal/batch_tracing_stub.h index d934d56bd314b..decadf8ad5b00 100644 --- a/google/cloud/batch/v1/internal/batch_tracing_stub.h +++ b/google/cloud/batch/v1/internal/batch_tracing_stub.h @@ -68,6 +68,14 @@ class BatchServiceTracingStub : public BatchServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::batch::v1::ListTasksRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/batch/v1/mocks/mock_batch_connection.h b/google/cloud/batch/v1/mocks/mock_batch_connection.h index a1322d1bcf677..c8aad27a9fbfd 100644 --- a/google/cloud/batch/v1/mocks/mock_batch_connection.h +++ b/google/cloud/batch/v1/mocks/mock_batch_connection.h @@ -99,6 +99,14 @@ class MockBatchServiceConnection : public batch_v1::BatchServiceConnection { MOCK_METHOD((StreamRange), ListTasks, (google::cloud::batch::v1::ListTasksRequest request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/beyondcorp/BUILD.bazel b/google/cloud/beyondcorp/BUILD.bazel index 46b948e8bd841..646e134ca4268 100644 --- a/google/cloud/beyondcorp/BUILD.bazel +++ b/google/cloud/beyondcorp/BUILD.bazel @@ -29,6 +29,8 @@ googleapis_deps = [ "@com_google_googleapis//google/cloud/beyondcorp/appconnections/v1:appconnections_cc_grpc", "@com_google_googleapis//google/cloud/beyondcorp/appconnectors/v1:appconnectors_cc_grpc", "@com_google_googleapis//google/cloud/beyondcorp/appgateways/v1:appgateways_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/beyondcorp/appconnections/v1/app_connections_client.cc b/google/cloud/beyondcorp/appconnections/v1/app_connections_client.cc index 0906da190eaea..d3f936155efbf 100644 --- a/google/cloud/beyondcorp/appconnections/v1/app_connections_client.cc +++ b/google/cloud/beyondcorp/appconnections/v1/app_connections_client.cc @@ -251,6 +251,39 @@ AppConnectionsServiceClient::ResolveAppConnections( return connection_->ResolveAppConnections(std::move(request)); } +StreamRange +AppConnectionsServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +AppConnectionsServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr AppConnectionsServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr AppConnectionsServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +AppConnectionsServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace beyondcorp_appconnections_v1 } // namespace cloud diff --git a/google/cloud/beyondcorp/appconnections/v1/app_connections_client.h b/google/cloud/beyondcorp/appconnections/v1/app_connections_client.h index eb4dc049ab24d..b8cbc24f96a85 100644 --- a/google/cloud/beyondcorp/appconnections/v1/app_connections_client.h +++ b/google/cloud/beyondcorp/appconnections/v1/app_connections_client.h @@ -698,6 +698,178 @@ class AppConnectionsServiceClient { ResolveAppConnectionsRequest request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/beyondcorp/appconnections/v1/app_connections_connection.cc b/google/cloud/beyondcorp/appconnections/v1/app_connections_connection.cc index 900c588ffd8be..a4fc684bcf45c 100644 --- a/google/cloud/beyondcorp/appconnections/v1/app_connections_connection.cc +++ b/google/cloud/beyondcorp/appconnections/v1/app_connections_connection.cc @@ -143,6 +143,36 @@ AppConnectionsServiceConnection::ResolveAppConnections( ResolveAppConnectionsResponse::AppConnectionDetails>>(); } +StreamRange +AppConnectionsServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +AppConnectionsServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr AppConnectionsServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr AppConnectionsServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +AppConnectionsServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAppConnectionsServiceConnection(Options options) { internal::CheckExpectedOptions +#include +#include #include #include @@ -247,6 +249,21 @@ class AppConnectionsServiceConnection { ResolveAppConnectionsResponse::AppConnectionDetails> ResolveAppConnections(google::cloud::beyondcorp::appconnections::v1:: ResolveAppConnectionsRequest request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/beyondcorp/appconnections/v1/app_connections_connection_idempotency_policy.cc b/google/cloud/beyondcorp/appconnections/v1/app_connections_connection_idempotency_policy.cc index b6136f5760bed..3ba88cb7c428a 100644 --- a/google/cloud/beyondcorp/appconnections/v1/app_connections_connection_idempotency_policy.cc +++ b/google/cloud/beyondcorp/appconnections/v1/app_connections_connection_idempotency_policy.cc @@ -77,6 +77,33 @@ AppConnectionsServiceConnectionIdempotencyPolicy::ResolveAppConnections( return Idempotency::kIdempotent; } +Idempotency AppConnectionsServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AppConnectionsServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AppConnectionsServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency AppConnectionsServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +AppConnectionsServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultAppConnectionsServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/beyondcorp/appconnections/v1/app_connections_connection_idempotency_policy.h b/google/cloud/beyondcorp/appconnections/v1/app_connections_connection_idempotency_policy.h index 91a3947ec9a3b..9f1985cb99aae 100644 --- a/google/cloud/beyondcorp/appconnections/v1/app_connections_connection_idempotency_policy.h +++ b/google/cloud/beyondcorp/appconnections/v1/app_connections_connection_idempotency_policy.h @@ -23,6 +23,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -61,6 +63,21 @@ class AppConnectionsServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ResolveAppConnections( google::cloud::beyondcorp::appconnections::v1:: ResolveAppConnectionsRequest request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_auth_decorator.cc b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_auth_decorator.cc index 117eebb13962d..775289595ce15 100644 --- a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_auth_decorator.cc +++ b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_auth_decorator.cc @@ -157,6 +157,49 @@ AppConnectionsServiceAuth::ResolveAppConnections( return child_->ResolveAppConnections(context, options, request); } +StatusOr +AppConnectionsServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +AppConnectionsServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr AppConnectionsServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr AppConnectionsServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +AppConnectionsServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> AppConnectionsServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_auth_decorator.h b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_auth_decorator.h index 13f5eb6378dce..d213eabe864d5 100644 --- a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_auth_decorator.h +++ b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_auth_decorator.h @@ -94,6 +94,26 @@ class AppConnectionsServiceAuth : public AppConnectionsServiceStub { google::cloud::beyondcorp::appconnections::v1:: ResolveAppConnectionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_connection_impl.cc b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_connection_impl.cc index 6669da241d169..7178db6feac93 100644 --- a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_connection_impl.cc +++ b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_connection_impl.cc @@ -463,6 +463,97 @@ AppConnectionsServiceConnectionImpl::ResolveAppConnections( }); } +StreamRange +AppConnectionsServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr< + beyondcorp_appconnections_v1::AppConnectionsServiceRetryPolicy>( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AppConnectionsServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +AppConnectionsServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +AppConnectionsServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +AppConnectionsServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace beyondcorp_appconnections_v1_internal } // namespace cloud diff --git a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_connection_impl.h b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_connection_impl.h index 0d8492975c9fa..76bc522792908 100644 --- a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_connection_impl.h +++ b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_connection_impl.h @@ -104,6 +104,21 @@ class AppConnectionsServiceConnectionImpl ResolveAppConnections(google::cloud::beyondcorp::appconnections::v1:: ResolveAppConnectionsRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr< diff --git a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_logging_decorator.cc b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_logging_decorator.cc index 5da5ffb0417ae..4768592bc04c9 100644 --- a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_logging_decorator.cc +++ b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_logging_decorator.cc @@ -182,6 +182,64 @@ AppConnectionsServiceLogging::ResolveAppConnections( context, options, request, __func__, tracing_options_); } +StatusOr +AppConnectionsServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AppConnectionsServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AppConnectionsServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AppConnectionsServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AppConnectionsServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> AppConnectionsServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_logging_decorator.h b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_logging_decorator.h index c0ed210840743..02fb767b9e03d 100644 --- a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_logging_decorator.h +++ b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_logging_decorator.h @@ -94,6 +94,26 @@ class AppConnectionsServiceLogging : public AppConnectionsServiceStub { google::cloud::beyondcorp::appconnections::v1:: ResolveAppConnectionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_metadata_decorator.cc b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_metadata_decorator.cc index de91fdcd44216..f9228d59e8ee0 100644 --- a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_metadata_decorator.cc +++ b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_metadata_decorator.cc @@ -150,6 +150,52 @@ AppConnectionsServiceMetadata::ResolveAppConnections( return child_->ResolveAppConnections(context, options, request); } +StatusOr +AppConnectionsServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +AppConnectionsServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr AppConnectionsServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr AppConnectionsServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +AppConnectionsServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> AppConnectionsServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_metadata_decorator.h b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_metadata_decorator.h index 6c7738f96a467..dd46e6b60af6c 100644 --- a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_metadata_decorator.h +++ b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_metadata_decorator.h @@ -95,6 +95,26 @@ class AppConnectionsServiceMetadata : public AppConnectionsServiceStub { google::cloud::beyondcorp::appconnections::v1:: ResolveAppConnectionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_stub.cc b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_stub.cc index daffaae999c13..bc43f9e6a0f84 100644 --- a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_stub.cc +++ b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_stub.cc @@ -174,6 +174,67 @@ DefaultAppConnectionsServiceStub::ResolveAppConnections( return response; } +StatusOr +DefaultAppConnectionsServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAppConnectionsServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAppConnectionsServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAppConnectionsServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAppConnectionsServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultAppConnectionsServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_stub.h b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_stub.h index 7af1a9f45b72a..18d49cb1f0dd3 100644 --- a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_stub.h +++ b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_stub.h @@ -26,6 +26,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -92,6 +96,28 @@ class AppConnectionsServiceStub { google::cloud::beyondcorp::appconnections::v1:: ResolveAppConnectionsRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -111,9 +137,15 @@ class DefaultAppConnectionsServiceStub : public AppConnectionsServiceStub { std::unique_ptr grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr< google::cloud::beyondcorp::appconnections::v1::ListAppConnectionsResponse> @@ -169,6 +201,26 @@ class DefaultAppConnectionsServiceStub : public AppConnectionsServiceStub { google::cloud::beyondcorp::appconnections::v1:: ResolveAppConnectionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -185,6 +237,9 @@ class DefaultAppConnectionsServiceStub : public AppConnectionsServiceStub { std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_stub_factory.cc b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_stub_factory.cc index 27a847d3be15d..89928913d94d1 100644 --- a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_stub_factory.cc +++ b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_stub_factory.cc @@ -30,6 +30,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -46,9 +48,13 @@ CreateDefaultAppConnectionsServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::beyondcorp::appconnections::v1:: AppConnectionsService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_tracing_connection.cc b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_tracing_connection.cc index f3aeb33b0b479..db2d12da736dd 100644 --- a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_tracing_connection.cc +++ b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_tracing_connection.cc @@ -184,6 +184,58 @@ AppConnectionsServiceTracingConnection::ResolveAppConnections( std::move(sr)); } +StreamRange +AppConnectionsServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "beyondcorp_appconnections_v1::AppConnectionsServiceConnection::" + "ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AppConnectionsServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "beyondcorp_appconnections_v1::AppConnectionsServiceConnection::" + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +AppConnectionsServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "beyondcorp_appconnections_v1::AppConnectionsServiceConnection::" + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +AppConnectionsServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "beyondcorp_appconnections_v1::AppConnectionsServiceConnection::" + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +AppConnectionsServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "beyondcorp_appconnections_v1::AppConnectionsServiceConnection::" + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_tracing_connection.h b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_tracing_connection.h index 0a76165c71188..f550856f64507 100644 --- a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_tracing_connection.h +++ b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_tracing_connection.h @@ -92,6 +92,21 @@ class AppConnectionsServiceTracingConnection ResolveAppConnections(google::cloud::beyondcorp::appconnections::v1:: ResolveAppConnectionsRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; diff --git a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_tracing_stub.cc b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_tracing_stub.cc index 2114b7a385a78..91d0cc0158c31 100644 --- a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_tracing_stub.cc +++ b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_tracing_stub.cc @@ -170,6 +170,71 @@ AppConnectionsServiceTracingStub::ResolveAppConnections( context, *span, child_->ResolveAppConnections(context, options, request)); } +StatusOr +AppConnectionsServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +AppConnectionsServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr +AppConnectionsServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr +AppConnectionsServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +AppConnectionsServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> AppConnectionsServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_tracing_stub.h b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_tracing_stub.h index 5542bf461a061..84c89f5da8c47 100644 --- a/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_tracing_stub.h +++ b/google/cloud/beyondcorp/appconnections/v1/internal/app_connections_tracing_stub.h @@ -94,6 +94,26 @@ class AppConnectionsServiceTracingStub : public AppConnectionsServiceStub { google::cloud::beyondcorp::appconnections::v1:: ResolveAppConnectionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/beyondcorp/appconnections/v1/mocks/mock_app_connections_connection.h b/google/cloud/beyondcorp/appconnections/v1/mocks/mock_app_connections_connection.h index 8052665d00db5..eb89c820915c6 100644 --- a/google/cloud/beyondcorp/appconnections/v1/mocks/mock_app_connections_connection.h +++ b/google/cloud/beyondcorp/appconnections/v1/mocks/mock_app_connections_connection.h @@ -194,6 +194,27 @@ class MockAppConnectionsServiceConnection (google::cloud::beyondcorp::appconnections::v1:: ResolveAppConnectionsRequest request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/beyondcorp/appconnectors/v1/app_connectors_client.cc b/google/cloud/beyondcorp/appconnectors/v1/app_connectors_client.cc index 726671bffe581..5712144f4ac7d 100644 --- a/google/cloud/beyondcorp/appconnectors/v1/app_connectors_client.cc +++ b/google/cloud/beyondcorp/appconnectors/v1/app_connectors_client.cc @@ -280,6 +280,39 @@ AppConnectorsServiceClient::ReportStatus( return connection_->ReportStatus(operation); } +StreamRange +AppConnectorsServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +AppConnectorsServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr AppConnectorsServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr AppConnectorsServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +AppConnectorsServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace beyondcorp_appconnectors_v1 } // namespace cloud diff --git a/google/cloud/beyondcorp/appconnectors/v1/app_connectors_client.h b/google/cloud/beyondcorp/appconnectors/v1/app_connectors_client.h index 9db90c6549217..73eb0615b8f56 100644 --- a/google/cloud/beyondcorp/appconnectors/v1/app_connectors_client.h +++ b/google/cloud/beyondcorp/appconnectors/v1/app_connectors_client.h @@ -737,6 +737,178 @@ class AppConnectorsServiceClient { ReportStatus(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/beyondcorp/appconnectors/v1/app_connectors_connection.cc b/google/cloud/beyondcorp/appconnectors/v1/app_connectors_connection.cc index fd85af6c7223a..bd6d33e255fb3 100644 --- a/google/cloud/beyondcorp/appconnectors/v1/app_connectors_connection.cc +++ b/google/cloud/beyondcorp/appconnectors/v1/app_connectors_connection.cc @@ -156,6 +156,36 @@ AppConnectorsServiceConnection::ReportStatus( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +AppConnectorsServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +AppConnectorsServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr AppConnectorsServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr AppConnectorsServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +AppConnectorsServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAppConnectorsServiceConnection(Options options) { internal::CheckExpectedOptions +#include +#include #include #include @@ -254,6 +256,21 @@ class AppConnectorsServiceConnection { virtual future< StatusOr> ReportStatus(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/beyondcorp/appconnectors/v1/app_connectors_connection_idempotency_policy.cc b/google/cloud/beyondcorp/appconnectors/v1/app_connectors_connection_idempotency_policy.cc index b77bee41a7bbb..5491e720a0611 100644 --- a/google/cloud/beyondcorp/appconnectors/v1/app_connectors_connection_idempotency_policy.cc +++ b/google/cloud/beyondcorp/appconnectors/v1/app_connectors_connection_idempotency_policy.cc @@ -70,6 +70,32 @@ Idempotency AppConnectorsServiceConnectionIdempotencyPolicy::ReportStatus( return Idempotency::kNonIdempotent; } +Idempotency AppConnectorsServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AppConnectorsServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AppConnectorsServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency AppConnectorsServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AppConnectorsServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultAppConnectorsServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/beyondcorp/appconnectors/v1/app_connectors_connection_idempotency_policy.h b/google/cloud/beyondcorp/appconnectors/v1/app_connectors_connection_idempotency_policy.h index 7e892f395d415..0007d65c4a22f 100644 --- a/google/cloud/beyondcorp/appconnectors/v1/app_connectors_connection_idempotency_policy.h +++ b/google/cloud/beyondcorp/appconnectors/v1/app_connectors_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -60,6 +62,21 @@ class AppConnectorsServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ReportStatus( google::cloud::beyondcorp::appconnectors::v1::ReportStatusRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_auth_decorator.cc b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_auth_decorator.cc index 6e8800334621b..e9bcebd923682 100644 --- a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_auth_decorator.cc +++ b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_auth_decorator.cc @@ -175,6 +175,49 @@ StatusOr AppConnectorsServiceAuth::ReportStatus( return child_->ReportStatus(context, options, request); } +StatusOr +AppConnectorsServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +AppConnectorsServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr AppConnectorsServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr AppConnectorsServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +AppConnectorsServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> AppConnectorsServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_auth_decorator.h b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_auth_decorator.h index d0e33505df976..570acc7c65532 100644 --- a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_auth_decorator.h +++ b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_auth_decorator.h @@ -98,6 +98,26 @@ class AppConnectorsServiceAuth : public AppConnectorsServiceStub { google::cloud::beyondcorp::appconnectors::v1::ReportStatusRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_connection_impl.cc b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_connection_impl.cc index 4f2e4a97812f1..9f347fad84a0b 100644 --- a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_connection_impl.cc +++ b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_connection_impl.cc @@ -512,6 +512,97 @@ AppConnectorsServiceConnectionImpl::ReportStatus( polling_policy(*current), __func__); } +StreamRange +AppConnectorsServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr< + beyondcorp_appconnectors_v1::AppConnectorsServiceRetryPolicy>( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AppConnectorsServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +AppConnectorsServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +AppConnectorsServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +AppConnectorsServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace beyondcorp_appconnectors_v1_internal } // namespace cloud diff --git a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_connection_impl.h b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_connection_impl.h index 22efe98c33bc2..94c9f8452eaa9 100644 --- a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_connection_impl.h +++ b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_connection_impl.h @@ -111,6 +111,21 @@ class AppConnectorsServiceConnectionImpl future> ReportStatus(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr< diff --git a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_logging_decorator.cc b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_logging_decorator.cc index 18288cbfd69f4..b09c5f407fe51 100644 --- a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_logging_decorator.cc +++ b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_logging_decorator.cc @@ -200,6 +200,64 @@ AppConnectorsServiceLogging::ReportStatus( context, options, request, __func__, tracing_options_); } +StatusOr +AppConnectorsServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AppConnectorsServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AppConnectorsServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AppConnectorsServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AppConnectorsServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> AppConnectorsServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_logging_decorator.h b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_logging_decorator.h index 29d14b623383a..c3f101ca60644 100644 --- a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_logging_decorator.h +++ b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_logging_decorator.h @@ -98,6 +98,26 @@ class AppConnectorsServiceLogging : public AppConnectorsServiceStub { google::cloud::beyondcorp::appconnectors::v1::ReportStatusRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_metadata_decorator.cc b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_metadata_decorator.cc index a66b80451df1a..570be1981ac56 100644 --- a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_metadata_decorator.cc +++ b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_metadata_decorator.cc @@ -163,6 +163,52 @@ AppConnectorsServiceMetadata::ReportStatus( return child_->ReportStatus(context, options, request); } +StatusOr +AppConnectorsServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +AppConnectorsServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr AppConnectorsServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr AppConnectorsServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +AppConnectorsServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> AppConnectorsServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_metadata_decorator.h b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_metadata_decorator.h index 12b74570bc567..1ac90a125cf0a 100644 --- a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_metadata_decorator.h +++ b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_metadata_decorator.h @@ -99,6 +99,26 @@ class AppConnectorsServiceMetadata : public AppConnectorsServiceStub { google::cloud::beyondcorp::appconnectors::v1::ReportStatusRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_stub.cc b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_stub.cc index c0db33c87703d..bf13128b468fa 100644 --- a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_stub.cc +++ b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_stub.cc @@ -191,6 +191,65 @@ DefaultAppConnectorsServiceStub::ReportStatus( return response; } +StatusOr +DefaultAppConnectorsServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAppConnectorsServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAppConnectorsServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAppConnectorsServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAppConnectorsServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultAppConnectorsServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_stub.h b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_stub.h index f2d4b5358bf9f..73fd22a1b8edf 100644 --- a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_stub.h +++ b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -97,6 +101,28 @@ class AppConnectorsServiceStub { google::cloud::beyondcorp::appconnectors::v1::ReportStatusRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -116,9 +142,15 @@ class DefaultAppConnectorsServiceStub : public AppConnectorsServiceStub { std::unique_ptr grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr< google::cloud::beyondcorp::appconnectors::v1::ListAppConnectorsResponse> @@ -179,6 +211,26 @@ class DefaultAppConnectorsServiceStub : public AppConnectorsServiceStub { google::cloud::beyondcorp::appconnectors::v1::ReportStatusRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -195,6 +247,9 @@ class DefaultAppConnectorsServiceStub : public AppConnectorsServiceStub { std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_stub_factory.cc b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_stub_factory.cc index 526b5a47ec801..66a9b1a26bede 100644 --- a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_stub_factory.cc +++ b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultAppConnectorsServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::beyondcorp::appconnectors::v1:: AppConnectorsService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_tracing_connection.cc b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_tracing_connection.cc index 662855bc3da7a..85d0fd5ade0f6 100644 --- a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_tracing_connection.cc +++ b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_tracing_connection.cc @@ -199,6 +199,58 @@ AppConnectorsServiceTracingConnection::ReportStatus( return internal::EndSpan(std::move(span), child_->ReportStatus(operation)); } +StreamRange +AppConnectorsServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "beyondcorp_appconnectors_v1::AppConnectorsServiceConnection::" + "ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AppConnectorsServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "beyondcorp_appconnectors_v1::AppConnectorsServiceConnection::" + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +AppConnectorsServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "beyondcorp_appconnectors_v1::AppConnectorsServiceConnection::" + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +AppConnectorsServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "beyondcorp_appconnectors_v1::AppConnectorsServiceConnection::" + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +AppConnectorsServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "beyondcorp_appconnectors_v1::AppConnectorsServiceConnection::" + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_tracing_connection.h b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_tracing_connection.h index f73587801487d..1f68be1227112 100644 --- a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_tracing_connection.h +++ b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_tracing_connection.h @@ -99,6 +99,21 @@ class AppConnectorsServiceTracingConnection future> ReportStatus(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; diff --git a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_tracing_stub.cc b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_tracing_stub.cc index 0875fffa0b5cd..c0bf36d4f4f7e 100644 --- a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_tracing_stub.cc +++ b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_tracing_stub.cc @@ -184,6 +184,69 @@ AppConnectorsServiceTracingStub::ReportStatus( child_->ReportStatus(context, options, request)); } +StatusOr +AppConnectorsServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +AppConnectorsServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr AppConnectorsServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr AppConnectorsServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +AppConnectorsServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> AppConnectorsServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_tracing_stub.h b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_tracing_stub.h index f368f0fff8fc1..113e5df344b68 100644 --- a/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_tracing_stub.h +++ b/google/cloud/beyondcorp/appconnectors/v1/internal/app_connectors_tracing_stub.h @@ -98,6 +98,26 @@ class AppConnectorsServiceTracingStub : public AppConnectorsServiceStub { google::cloud::beyondcorp::appconnectors::v1::ReportStatusRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/beyondcorp/appconnectors/v1/mocks/mock_app_connectors_connection.h b/google/cloud/beyondcorp/appconnectors/v1/mocks/mock_app_connectors_connection.h index a0f711d1b7268..853dce2fa8fdf 100644 --- a/google/cloud/beyondcorp/appconnectors/v1/mocks/mock_app_connectors_connection.h +++ b/google/cloud/beyondcorp/appconnectors/v1/mocks/mock_app_connectors_connection.h @@ -228,6 +228,27 @@ class MockAppConnectorsServiceConnection StatusOr>, ReportStatus, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/beyondcorp/appgateways/v1/app_gateways_client.cc b/google/cloud/beyondcorp/appgateways/v1/app_gateways_client.cc index 160096f160e6c..371921926c3fe 100644 --- a/google/cloud/beyondcorp/appgateways/v1/app_gateways_client.cc +++ b/google/cloud/beyondcorp/appgateways/v1/app_gateways_client.cc @@ -165,6 +165,39 @@ AppGatewaysServiceClient::DeleteAppGateway( return connection_->DeleteAppGateway(operation); } +StreamRange +AppGatewaysServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +AppGatewaysServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr AppGatewaysServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr AppGatewaysServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +AppGatewaysServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace beyondcorp_appgateways_v1 } // namespace cloud diff --git a/google/cloud/beyondcorp/appgateways/v1/app_gateways_client.h b/google/cloud/beyondcorp/appgateways/v1/app_gateways_client.h index 51c8fc1d276f1..aef62075f307a 100644 --- a/google/cloud/beyondcorp/appgateways/v1/app_gateways_client.h +++ b/google/cloud/beyondcorp/appgateways/v1/app_gateways_client.h @@ -486,6 +486,178 @@ class AppGatewaysServiceClient { DeleteAppGateway(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/beyondcorp/appgateways/v1/app_gateways_connection.cc b/google/cloud/beyondcorp/appgateways/v1/app_gateways_connection.cc index 8ec35dc410a0f..b0eead550f812 100644 --- a/google/cloud/beyondcorp/appgateways/v1/app_gateways_connection.cc +++ b/google/cloud/beyondcorp/appgateways/v1/app_gateways_connection.cc @@ -104,6 +104,36 @@ AppGatewaysServiceConnection::DeleteAppGateway( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +AppGatewaysServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +AppGatewaysServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr AppGatewaysServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr AppGatewaysServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +AppGatewaysServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAppGatewaysServiceConnection( Options options) { internal::CheckExpectedOptions +#include +#include #include #include @@ -229,6 +231,21 @@ class AppGatewaysServiceConnection { virtual future> DeleteAppGateway(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/beyondcorp/appgateways/v1/app_gateways_connection_idempotency_policy.cc b/google/cloud/beyondcorp/appgateways/v1/app_gateways_connection_idempotency_policy.cc index 8999ce0415f98..ac977739493f7 100644 --- a/google/cloud/beyondcorp/appgateways/v1/app_gateways_connection_idempotency_policy.cc +++ b/google/cloud/beyondcorp/appgateways/v1/app_gateways_connection_idempotency_policy.cc @@ -57,6 +57,32 @@ Idempotency AppGatewaysServiceConnectionIdempotencyPolicy::DeleteAppGateway( return Idempotency::kNonIdempotent; } +Idempotency AppGatewaysServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AppGatewaysServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AppGatewaysServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency AppGatewaysServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AppGatewaysServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultAppGatewaysServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/beyondcorp/appgateways/v1/app_gateways_connection_idempotency_policy.h b/google/cloud/beyondcorp/appgateways/v1/app_gateways_connection_idempotency_policy.h index dea1ae9a75ac6..a78af74a33626 100644 --- a/google/cloud/beyondcorp/appgateways/v1/app_gateways_connection_idempotency_policy.h +++ b/google/cloud/beyondcorp/appgateways/v1/app_gateways_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -52,6 +54,21 @@ class AppGatewaysServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteAppGateway( google::cloud::beyondcorp::appgateways::v1::DeleteAppGatewayRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_auth_decorator.cc b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_auth_decorator.cc index ecf1332075539..3153776e43051 100644 --- a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_auth_decorator.cc +++ b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_auth_decorator.cc @@ -113,6 +113,48 @@ AppGatewaysServiceAuth::DeleteAppGateway( return child_->DeleteAppGateway(context, options, request); } +StatusOr +AppGatewaysServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr AppGatewaysServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr AppGatewaysServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr AppGatewaysServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +AppGatewaysServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> AppGatewaysServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_auth_decorator.h b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_auth_decorator.h index 8a6667a21c6be..ef0fab9f04eaf 100644 --- a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_auth_decorator.h +++ b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_auth_decorator.h @@ -75,6 +75,26 @@ class AppGatewaysServiceAuth : public AppGatewaysServiceStub { google::cloud::beyondcorp::appgateways::v1::DeleteAppGatewayRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_connection_impl.cc b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_connection_impl.cc index e7274dad51b75..147149db7095a 100644 --- a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_connection_impl.cc +++ b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_connection_impl.cc @@ -320,6 +320,97 @@ AppGatewaysServiceConnectionImpl::DeleteAppGateway( polling_policy(*current), __func__); } +StreamRange +AppGatewaysServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr< + beyondcorp_appgateways_v1::AppGatewaysServiceRetryPolicy>( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AppGatewaysServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +AppGatewaysServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +AppGatewaysServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +AppGatewaysServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace beyondcorp_appgateways_v1_internal } // namespace cloud diff --git a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_connection_impl.h b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_connection_impl.h index 48e6091b0c518..6f48134cfc583 100644 --- a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_connection_impl.h +++ b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_connection_impl.h @@ -92,6 +92,21 @@ class AppGatewaysServiceConnectionImpl google::cloud::beyondcorp::appgateways::v1::AppGatewayOperationMetadata>> DeleteAppGateway(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr diff --git a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_logging_decorator.cc b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_logging_decorator.cc index 9e5375c0fba17..f69fc49782b73 100644 --- a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_logging_decorator.cc +++ b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_logging_decorator.cc @@ -131,6 +131,64 @@ AppGatewaysServiceLogging::DeleteAppGateway( context, options, request, __func__, tracing_options_); } +StatusOr +AppGatewaysServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AppGatewaysServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AppGatewaysServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AppGatewaysServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AppGatewaysServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> AppGatewaysServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_logging_decorator.h b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_logging_decorator.h index b6dd16f6e2f34..7a3f430d9e3bc 100644 --- a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_logging_decorator.h +++ b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_logging_decorator.h @@ -75,6 +75,26 @@ class AppGatewaysServiceLogging : public AppGatewaysServiceStub { google::cloud::beyondcorp::appgateways::v1::DeleteAppGatewayRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_metadata_decorator.cc b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_metadata_decorator.cc index 715badd72f57a..bf6ce03e68552 100644 --- a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_metadata_decorator.cc +++ b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_metadata_decorator.cc @@ -110,6 +110,52 @@ AppGatewaysServiceMetadata::DeleteAppGateway( return child_->DeleteAppGateway(context, options, request); } +StatusOr +AppGatewaysServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +AppGatewaysServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr AppGatewaysServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr AppGatewaysServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +AppGatewaysServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> AppGatewaysServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_metadata_decorator.h b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_metadata_decorator.h index d0858fa180036..1fcc0bb115fcf 100644 --- a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_metadata_decorator.h +++ b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_metadata_decorator.h @@ -76,6 +76,26 @@ class AppGatewaysServiceMetadata : public AppGatewaysServiceStub { google::cloud::beyondcorp::appgateways::v1::DeleteAppGatewayRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_stub.cc b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_stub.cc index ceb83c7571c8b..f66728f1a35b4 100644 --- a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_stub.cc +++ b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_stub.cc @@ -123,6 +123,65 @@ DefaultAppGatewaysServiceStub::DeleteAppGateway( return response; } +StatusOr +DefaultAppGatewaysServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAppGatewaysServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAppGatewaysServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAppGatewaysServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAppGatewaysServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultAppGatewaysServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_stub.h b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_stub.h index 4d21dc0582981..0b9f3a21d3119 100644 --- a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_stub.h +++ b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -77,6 +81,28 @@ class AppGatewaysServiceStub { google::cloud::beyondcorp::appgateways::v1::DeleteAppGatewayRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -96,9 +122,15 @@ class DefaultAppGatewaysServiceStub : public AppGatewaysServiceStub { std::unique_ptr grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListAppGateways( @@ -136,6 +168,26 @@ class DefaultAppGatewaysServiceStub : public AppGatewaysServiceStub { google::cloud::beyondcorp::appgateways::v1::DeleteAppGatewayRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -152,6 +204,9 @@ class DefaultAppGatewaysServiceStub : public AppGatewaysServiceStub { std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_stub_factory.cc b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_stub_factory.cc index a2c7ac2bc4f65..e71aaacfb15aa 100644 --- a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_stub_factory.cc +++ b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -45,9 +47,13 @@ std::shared_ptr CreateDefaultAppGatewaysServiceStub( auto service_grpc_stub = google::cloud::beyondcorp::appgateways::v1::AppGatewaysService::NewStub( channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_tracing_connection.cc b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_tracing_connection.cc index 727b1f4c750b4..3ceea7d42d3a8 100644 --- a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_tracing_connection.cc +++ b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_tracing_connection.cc @@ -130,6 +130,54 @@ AppGatewaysServiceTracingConnection::DeleteAppGateway( child_->DeleteAppGateway(operation)); } +StreamRange +AppGatewaysServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "beyondcorp_appgateways_v1::AppGatewaysServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AppGatewaysServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "beyondcorp_appgateways_v1::AppGatewaysServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +AppGatewaysServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "beyondcorp_appgateways_v1::AppGatewaysServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +AppGatewaysServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "beyondcorp_appgateways_v1::AppGatewaysServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +AppGatewaysServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "beyondcorp_appgateways_v1::AppGatewaysServiceConnection::" + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_tracing_connection.h b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_tracing_connection.h index 490c7102a8e31..45e212f341884 100644 --- a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_tracing_connection.h +++ b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_tracing_connection.h @@ -79,6 +79,21 @@ class AppGatewaysServiceTracingConnection google::cloud::beyondcorp::appgateways::v1::AppGatewayOperationMetadata>> DeleteAppGateway(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; diff --git a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_tracing_stub.cc b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_tracing_stub.cc index 77a1c9c1d219a..16f5eafc8b8e2 100644 --- a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_tracing_stub.cc +++ b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_tracing_stub.cc @@ -122,6 +122,69 @@ AppGatewaysServiceTracingStub::DeleteAppGateway( child_->DeleteAppGateway(context, options, request)); } +StatusOr +AppGatewaysServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +AppGatewaysServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr AppGatewaysServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr AppGatewaysServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +AppGatewaysServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> AppGatewaysServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_tracing_stub.h b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_tracing_stub.h index a06161b2f42a5..2ea40dfe0c2d6 100644 --- a/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_tracing_stub.h +++ b/google/cloud/beyondcorp/appgateways/v1/internal/app_gateways_tracing_stub.h @@ -75,6 +75,26 @@ class AppGatewaysServiceTracingStub : public AppGatewaysServiceStub { google::cloud::beyondcorp::appgateways::v1::DeleteAppGatewayRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/beyondcorp/appgateways/v1/mocks/mock_app_gateways_connection.h b/google/cloud/beyondcorp/appgateways/v1/mocks/mock_app_gateways_connection.h index a63cf465366ae..880bf0f7710c5 100644 --- a/google/cloud/beyondcorp/appgateways/v1/mocks/mock_app_gateways_connection.h +++ b/google/cloud/beyondcorp/appgateways/v1/mocks/mock_app_gateways_connection.h @@ -140,6 +140,27 @@ class MockAppGatewaysServiceConnection AppGatewayOperationMetadata>>, DeleteAppGateway, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/bigquery/BUILD.bazel b/google/cloud/bigquery/BUILD.bazel index 93876335f8980..94295f6515d70 100644 --- a/google/cloud/bigquery/BUILD.bazel +++ b/google/cloud/bigquery/BUILD.bazel @@ -46,6 +46,8 @@ googleapis_deps = [ "@com_google_googleapis//google/cloud/bigquery/migration/v2:migration_cc_grpc", "@com_google_googleapis//google/cloud/bigquery/reservation/v1:reservation_cc_grpc", "@com_google_googleapis//google/cloud/bigquery/storage/v1:storage_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/bigquery/datatransfer/v1/data_transfer_client.cc b/google/cloud/bigquery/datatransfer/v1/data_transfer_client.cc index 0d9660642f373..d5f73f1079ad6 100644 --- a/google/cloud/bigquery/datatransfer/v1/data_transfer_client.cc +++ b/google/cloud/bigquery/datatransfer/v1/data_transfer_client.cc @@ -301,6 +301,20 @@ Status DataTransferServiceClient::UnenrollDataSources( return connection_->UnenrollDataSources(request); } +StreamRange +DataTransferServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +DataTransferServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace bigquery_datatransfer_v1 } // namespace cloud diff --git a/google/cloud/bigquery/datatransfer/v1/data_transfer_client.h b/google/cloud/bigquery/datatransfer/v1/data_transfer_client.h index ccdbbb2ae624e..c57655134ec2d 100644 --- a/google/cloud/bigquery/datatransfer/v1/data_transfer_client.h +++ b/google/cloud/bigquery/datatransfer/v1/data_transfer_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -1064,6 +1065,76 @@ class DataTransferServiceClient { UnenrollDataSourcesRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/bigquery/datatransfer/v1/data_transfer_connection.cc b/google/cloud/bigquery/datatransfer/v1/data_transfer_connection.cc index 12c90e2760300..7c58ff402a884 100644 --- a/google/cloud/bigquery/datatransfer/v1/data_transfer_connection.cc +++ b/google/cloud/bigquery/datatransfer/v1/data_transfer_connection.cc @@ -149,6 +149,20 @@ Status DataTransferServiceConnection::UnenrollDataSources( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +DataTransferServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DataTransferServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDataTransferServiceConnection(Options options) { internal::CheckExpectedOptions +#include #include namespace google { @@ -261,6 +262,12 @@ class DataTransferServiceConnection { virtual Status UnenrollDataSources( google::cloud::bigquery::datatransfer::v1:: UnenrollDataSourcesRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/bigquery/datatransfer/v1/data_transfer_connection_idempotency_policy.cc b/google/cloud/bigquery/datatransfer/v1/data_transfer_connection_idempotency_policy.cc index 0337e1140374a..37d81dfb6fbc5 100644 --- a/google/cloud/bigquery/datatransfer/v1/data_transfer_connection_idempotency_policy.cc +++ b/google/cloud/bigquery/datatransfer/v1/data_transfer_connection_idempotency_policy.cc @@ -133,6 +133,16 @@ Idempotency DataTransferServiceConnectionIdempotencyPolicy::UnenrollDataSources( return Idempotency::kNonIdempotent; } +Idempotency DataTransferServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DataTransferServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultDataTransferServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/bigquery/datatransfer/v1/data_transfer_connection_idempotency_policy.h b/google/cloud/bigquery/datatransfer/v1/data_transfer_connection_idempotency_policy.h index 5964861c3fe01..6264d14802dd7 100644 --- a/google/cloud/bigquery/datatransfer/v1/data_transfer_connection_idempotency_policy.h +++ b/google/cloud/bigquery/datatransfer/v1/data_transfer_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -100,6 +101,12 @@ class DataTransferServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency UnenrollDataSources( google::cloud::bigquery::datatransfer::v1:: UnenrollDataSourcesRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_auth_decorator.cc b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_auth_decorator.cc index 9fd618fb5faa9..80f1228b847fe 100644 --- a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_auth_decorator.cc +++ b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_auth_decorator.cc @@ -189,6 +189,24 @@ Status DataTransferServiceAuth::UnenrollDataSources( return child_->UnenrollDataSources(context, options, request); } +StatusOr +DataTransferServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +DataTransferServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace bigquery_datatransfer_v1_internal } // namespace cloud diff --git a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_auth_decorator.h b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_auth_decorator.h index 0b753a14a1170..01bf27dbad0a9 100644 --- a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_auth_decorator.h +++ b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_auth_decorator.h @@ -128,6 +128,14 @@ class DataTransferServiceAuth : public DataTransferServiceStub { google::cloud::bigquery::datatransfer::v1:: UnenrollDataSourcesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_connection_impl.cc b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_connection_impl.cc index 2107fadd841e0..41f677bed02dd 100644 --- a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_connection_impl.cc +++ b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_connection_impl.cc @@ -403,6 +403,55 @@ Status DataTransferServiceConnectionImpl::UnenrollDataSources( *current, request, __func__); } +StreamRange +DataTransferServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr< + bigquery_datatransfer_v1::DataTransferServiceRetryPolicy>( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DataTransferServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace bigquery_datatransfer_v1_internal } // namespace cloud diff --git a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_connection_impl.h b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_connection_impl.h index 89e9bdc869289..940dc57bf84a4 100644 --- a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_connection_impl.h +++ b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_connection_impl.h @@ -125,6 +125,12 @@ class DataTransferServiceConnectionImpl google::cloud::bigquery::datatransfer::v1:: UnenrollDataSourcesRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr diff --git a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_logging_decorator.cc b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_logging_decorator.cc index 80d1d6e1090f0..2990548cad3da 100644 --- a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_logging_decorator.cc +++ b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_logging_decorator.cc @@ -258,6 +258,30 @@ Status DataTransferServiceLogging::UnenrollDataSources( context, options, request, __func__, tracing_options_); } +StatusOr +DataTransferServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataTransferServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace bigquery_datatransfer_v1_internal } // namespace cloud diff --git a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_logging_decorator.h b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_logging_decorator.h index 4fddf777ea83d..bced4fc54d6bf 100644 --- a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_logging_decorator.h +++ b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_logging_decorator.h @@ -128,6 +128,14 @@ class DataTransferServiceLogging : public DataTransferServiceStub { google::cloud::bigquery::datatransfer::v1:: UnenrollDataSourcesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_metadata_decorator.cc b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_metadata_decorator.cc index 4a65c63330285..86f97235fd5dd 100644 --- a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_metadata_decorator.cc +++ b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_metadata_decorator.cc @@ -204,6 +204,24 @@ Status DataTransferServiceMetadata::UnenrollDataSources( return child_->UnenrollDataSources(context, options, request); } +StatusOr +DataTransferServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +DataTransferServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void DataTransferServiceMetadata::SetMetadata( grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_metadata_decorator.h b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_metadata_decorator.h index f0d51f6f8f51b..d9d3239a1a552 100644 --- a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_metadata_decorator.h +++ b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_metadata_decorator.h @@ -129,6 +129,14 @@ class DataTransferServiceMetadata : public DataTransferServiceStub { google::cloud::bigquery::datatransfer::v1:: UnenrollDataSourcesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_stub.cc b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_stub.cc index 3d7fa4f2c4ec3..97ff410cf160a 100644 --- a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_stub.cc +++ b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_stub.cc @@ -240,6 +240,30 @@ Status DefaultDataTransferServiceStub::UnenrollDataSources( return google::cloud::Status(); } +StatusOr +DefaultDataTransferServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataTransferServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace bigquery_datatransfer_v1_internal } // namespace cloud diff --git a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_stub.h b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_stub.h index 7f7c1cc748584..1fbb66e9fd7ca 100644 --- a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_stub.h +++ b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_stub.h @@ -23,6 +23,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -129,6 +131,15 @@ class DataTransferServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::bigquery::datatransfer::v1:: UnenrollDataSourcesRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultDataTransferServiceStub : public DataTransferServiceStub { @@ -136,8 +147,11 @@ class DefaultDataTransferServiceStub : public DataTransferServiceStub { explicit DefaultDataTransferServiceStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr GetDataSource( grpc::ClientContext& context, Options const& options, @@ -229,10 +243,20 @@ class DefaultDataTransferServiceStub : public DataTransferServiceStub { google::cloud::bigquery::datatransfer::v1:: UnenrollDataSourcesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_stub_factory.cc b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_stub_factory.cc index 170459db225c0..9b7f2a0858651 100644 --- a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_stub_factory.cc +++ b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -45,9 +46,11 @@ std::shared_ptr CreateDefaultDataTransferServiceStub( auto service_grpc_stub = google::cloud::bigquery::datatransfer::v1::DataTransferService::NewStub( channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_tracing_connection.cc b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_tracing_connection.cc index 6dc16862731a8..af3bd81d0053a 100644 --- a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_tracing_connection.cc +++ b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_tracing_connection.cc @@ -218,6 +218,26 @@ Status DataTransferServiceTracingConnection::UnenrollDataSources( return internal::EndSpan(*span, child_->UnenrollDataSources(request)); } +StreamRange +DataTransferServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "bigquery_datatransfer_v1::DataTransferServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DataTransferServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "bigquery_datatransfer_v1::DataTransferServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_tracing_connection.h b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_tracing_connection.h index 199f1b50ceb66..d9841e928c3e2 100644 --- a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_tracing_connection.h +++ b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_tracing_connection.h @@ -115,6 +115,12 @@ class DataTransferServiceTracingConnection google::cloud::bigquery::datatransfer::v1:: UnenrollDataSourcesRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; diff --git a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_tracing_stub.cc b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_tracing_stub.cc index 0bba0c6d56af8..41b65665dc9a0 100644 --- a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_tracing_stub.cc +++ b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_tracing_stub.cc @@ -255,6 +255,32 @@ Status DataTransferServiceTracingStub::UnenrollDataSources( context, *span, child_->UnenrollDataSources(context, options, request)); } +StatusOr +DataTransferServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +DataTransferServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeDataTransferServiceTracingStub( diff --git a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_tracing_stub.h b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_tracing_stub.h index 251990a9f36db..6bc13abef5ea1 100644 --- a/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_tracing_stub.h +++ b/google/cloud/bigquery/datatransfer/v1/internal/data_transfer_tracing_stub.h @@ -129,6 +129,14 @@ class DataTransferServiceTracingStub : public DataTransferServiceStub { google::cloud::bigquery::datatransfer::v1:: UnenrollDataSourcesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/bigquery/datatransfer/v1/mocks/mock_data_transfer_connection.h b/google/cloud/bigquery/datatransfer/v1/mocks/mock_data_transfer_connection.h index 8625b8eedd33b..f32902e98254e 100644 --- a/google/cloud/bigquery/datatransfer/v1/mocks/mock_data_transfer_connection.h +++ b/google/cloud/bigquery/datatransfer/v1/mocks/mock_data_transfer_connection.h @@ -151,6 +151,14 @@ class MockDataTransferServiceConnection (google::cloud::bigquery::datatransfer::v1:: UnenrollDataSourcesRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/certificatemanager/BUILD.bazel b/google/cloud/certificatemanager/BUILD.bazel index 9057ab9ec38a4..ed8a11cd2b6cd 100644 --- a/google/cloud/certificatemanager/BUILD.bazel +++ b/google/cloud/certificatemanager/BUILD.bazel @@ -26,6 +26,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/certificatemanager/logging/v1:logging_cc_grpc", "@com_google_googleapis//google/cloud/certificatemanager/v1:certificatemanager_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/certificatemanager/v1/certificate_manager_client.cc b/google/cloud/certificatemanager/v1/certificate_manager_client.cc index 6a086acafd965..3a45f40340902 100644 --- a/google/cloud/certificatemanager/v1/certificate_manager_client.cc +++ b/google/cloud/certificatemanager/v1/certificate_manager_client.cc @@ -1096,6 +1096,20 @@ CertificateManagerClient::DeleteTrustConfig( return connection_->DeleteTrustConfig(operation); } +StreamRange +CertificateManagerClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +CertificateManagerClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace certificatemanager_v1 } // namespace cloud diff --git a/google/cloud/certificatemanager/v1/certificate_manager_client.h b/google/cloud/certificatemanager/v1/certificate_manager_client.h index 183d10b6715eb..b6c31fdb60c50 100644 --- a/google/cloud/certificatemanager/v1/certificate_manager_client.h +++ b/google/cloud/certificatemanager/v1/certificate_manager_client.h @@ -3003,6 +3003,76 @@ class CertificateManagerClient { DeleteTrustConfig(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/certificatemanager/v1/certificate_manager_connection.cc b/google/cloud/certificatemanager/v1/certificate_manager_connection.cc index 7113d9bbb09fa..a2bd293e93616 100644 --- a/google/cloud/certificatemanager/v1/certificate_manager_connection.cc +++ b/google/cloud/certificatemanager/v1/certificate_manager_connection.cc @@ -542,6 +542,20 @@ CertificateManagerConnection::DeleteTrustConfig( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +CertificateManagerConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +CertificateManagerConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCertificateManagerConnection( Options options) { internal::CheckExpectedOptions +#include #include #include @@ -489,6 +490,12 @@ class CertificateManagerConnection { virtual future< StatusOr> DeleteTrustConfig(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/certificatemanager/v1/certificate_manager_connection_idempotency_policy.cc b/google/cloud/certificatemanager/v1/certificate_manager_connection_idempotency_policy.cc index 23f467971be24..849003fa553fe 100644 --- a/google/cloud/certificatemanager/v1/certificate_manager_connection_idempotency_policy.cc +++ b/google/cloud/certificatemanager/v1/certificate_manager_connection_idempotency_policy.cc @@ -206,6 +206,16 @@ Idempotency CertificateManagerConnectionIdempotencyPolicy::DeleteTrustConfig( return Idempotency::kNonIdempotent; } +Idempotency CertificateManagerConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CertificateManagerConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultCertificateManagerConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/certificatemanager/v1/certificate_manager_connection_idempotency_policy.h b/google/cloud/certificatemanager/v1/certificate_manager_connection_idempotency_policy.h index 2c2546e669507..2f8f9092b021d 100644 --- a/google/cloud/certificatemanager/v1/certificate_manager_connection_idempotency_policy.h +++ b/google/cloud/certificatemanager/v1/certificate_manager_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -150,6 +151,12 @@ class CertificateManagerConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteTrustConfig( google::cloud::certificatemanager::v1::DeleteTrustConfigRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/certificatemanager/v1/internal/certificate_manager_auth_decorator.cc b/google/cloud/certificatemanager/v1/internal/certificate_manager_auth_decorator.cc index 6fb0e65a67654..1f5967d95700c 100644 --- a/google/cloud/certificatemanager/v1/internal/certificate_manager_auth_decorator.cc +++ b/google/cloud/certificatemanager/v1/internal/certificate_manager_auth_decorator.cc @@ -680,6 +680,23 @@ CertificateManagerAuth::DeleteTrustConfig( return child_->DeleteTrustConfig(context, options, request); } +StatusOr +CertificateManagerAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr CertificateManagerAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> CertificateManagerAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/certificatemanager/v1/internal/certificate_manager_auth_decorator.h b/google/cloud/certificatemanager/v1/internal/certificate_manager_auth_decorator.h index 099ccad89b131..775c6e5a05da5 100644 --- a/google/cloud/certificatemanager/v1/internal/certificate_manager_auth_decorator.h +++ b/google/cloud/certificatemanager/v1/internal/certificate_manager_auth_decorator.h @@ -320,6 +320,14 @@ class CertificateManagerAuth : public CertificateManagerStub { google::cloud::certificatemanager::v1::DeleteTrustConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/certificatemanager/v1/internal/certificate_manager_connection_impl.cc b/google/cloud/certificatemanager/v1/internal/certificate_manager_connection_impl.cc index c989f816328ec..7c9f86aa70573 100644 --- a/google/cloud/certificatemanager/v1/internal/certificate_manager_connection_impl.cc +++ b/google/cloud/certificatemanager/v1/internal/certificate_manager_connection_impl.cc @@ -2025,6 +2025,55 @@ CertificateManagerConnectionImpl::DeleteTrustConfig( polling_policy(*current), __func__); } +StreamRange +CertificateManagerConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr< + certificatemanager_v1::CertificateManagerRetryPolicy>( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +CertificateManagerConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace certificatemanager_v1_internal } // namespace cloud diff --git a/google/cloud/certificatemanager/v1/internal/certificate_manager_connection_impl.h b/google/cloud/certificatemanager/v1/internal/certificate_manager_connection_impl.h index 22508aeb816cb..814bc94662762 100644 --- a/google/cloud/certificatemanager/v1/internal/certificate_manager_connection_impl.h +++ b/google/cloud/certificatemanager/v1/internal/certificate_manager_connection_impl.h @@ -339,6 +339,12 @@ class CertificateManagerConnectionImpl future> DeleteTrustConfig(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/certificatemanager/v1/internal/certificate_manager_logging_decorator.cc b/google/cloud/certificatemanager/v1/internal/certificate_manager_logging_decorator.cc index 804c1a9ff66c7..57f6e15abb763 100644 --- a/google/cloud/certificatemanager/v1/internal/certificate_manager_logging_decorator.cc +++ b/google/cloud/certificatemanager/v1/internal/certificate_manager_logging_decorator.cc @@ -801,6 +801,30 @@ CertificateManagerLogging::DeleteTrustConfig( context, options, request, __func__, tracing_options_); } +StatusOr +CertificateManagerLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +CertificateManagerLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> CertificateManagerLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/certificatemanager/v1/internal/certificate_manager_logging_decorator.h b/google/cloud/certificatemanager/v1/internal/certificate_manager_logging_decorator.h index 100815b55693d..9267522ae79c0 100644 --- a/google/cloud/certificatemanager/v1/internal/certificate_manager_logging_decorator.h +++ b/google/cloud/certificatemanager/v1/internal/certificate_manager_logging_decorator.h @@ -320,6 +320,14 @@ class CertificateManagerLogging : public CertificateManagerStub { google::cloud::certificatemanager::v1::DeleteTrustConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/certificatemanager/v1/internal/certificate_manager_metadata_decorator.cc b/google/cloud/certificatemanager/v1/internal/certificate_manager_metadata_decorator.cc index 829b298fe597c..0c1e3dc3a95bc 100644 --- a/google/cloud/certificatemanager/v1/internal/certificate_manager_metadata_decorator.cc +++ b/google/cloud/certificatemanager/v1/internal/certificate_manager_metadata_decorator.cc @@ -573,6 +573,24 @@ CertificateManagerMetadata::DeleteTrustConfig( return child_->DeleteTrustConfig(context, options, request); } +StatusOr +CertificateManagerMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +CertificateManagerMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> CertificateManagerMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/certificatemanager/v1/internal/certificate_manager_metadata_decorator.h b/google/cloud/certificatemanager/v1/internal/certificate_manager_metadata_decorator.h index e43a4fcded249..8e5aadc0a6c59 100644 --- a/google/cloud/certificatemanager/v1/internal/certificate_manager_metadata_decorator.h +++ b/google/cloud/certificatemanager/v1/internal/certificate_manager_metadata_decorator.h @@ -321,6 +321,14 @@ class CertificateManagerMetadata : public CertificateManagerStub { google::cloud::certificatemanager::v1::DeleteTrustConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/certificatemanager/v1/internal/certificate_manager_stub.cc b/google/cloud/certificatemanager/v1/internal/certificate_manager_stub.cc index f6e6b80fc9184..fd69e5459205c 100644 --- a/google/cloud/certificatemanager/v1/internal/certificate_manager_stub.cc +++ b/google/cloud/certificatemanager/v1/internal/certificate_manager_stub.cc @@ -772,6 +772,30 @@ DefaultCertificateManagerStub::DeleteTrustConfig( return response; } +StatusOr +DefaultCertificateManagerStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultCertificateManagerStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultCertificateManagerStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/certificatemanager/v1/internal/certificate_manager_stub.h b/google/cloud/certificatemanager/v1/internal/certificate_manager_stub.h index e2d8d924a59b1..cb2f267694c4a 100644 --- a/google/cloud/certificatemanager/v1/internal/certificate_manager_stub.h +++ b/google/cloud/certificatemanager/v1/internal/certificate_manager_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -339,6 +341,15 @@ class CertificateManagerStub { google::cloud::certificatemanager::v1::DeleteTrustConfigRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -358,9 +369,13 @@ class DefaultCertificateManagerStub : public CertificateManagerStub { std::unique_ptr grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListCertificates( @@ -643,6 +658,14 @@ class DefaultCertificateManagerStub : public CertificateManagerStub { google::cloud::certificatemanager::v1::DeleteTrustConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -659,6 +682,8 @@ class DefaultCertificateManagerStub : public CertificateManagerStub { std::unique_ptr< google::cloud::certificatemanager::v1::CertificateManager::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/certificatemanager/v1/internal/certificate_manager_stub_factory.cc b/google/cloud/certificatemanager/v1/internal/certificate_manager_stub_factory.cc index bc58b8b21194c..7add57ffb78f2 100644 --- a/google/cloud/certificatemanager/v1/internal/certificate_manager_stub_factory.cc +++ b/google/cloud/certificatemanager/v1/internal/certificate_manager_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -45,9 +46,11 @@ std::shared_ptr CreateDefaultCertificateManagerStub( auto service_grpc_stub = google::cloud::certificatemanager::v1::CertificateManager::NewStub( channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/certificatemanager/v1/internal/certificate_manager_tracing_connection.cc b/google/cloud/certificatemanager/v1/internal/certificate_manager_tracing_connection.cc index 625838159627d..e179f4c142095 100644 --- a/google/cloud/certificatemanager/v1/internal/certificate_manager_tracing_connection.cc +++ b/google/cloud/certificatemanager/v1/internal/certificate_manager_tracing_connection.cc @@ -761,6 +761,26 @@ CertificateManagerTracingConnection::DeleteTrustConfig( child_->DeleteTrustConfig(operation)); } +StreamRange +CertificateManagerTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "certificatemanager_v1::CertificateManagerConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CertificateManagerTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "certificatemanager_v1::CertificateManagerConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/certificatemanager/v1/internal/certificate_manager_tracing_connection.h b/google/cloud/certificatemanager/v1/internal/certificate_manager_tracing_connection.h index 448ede40cde5d..6c6cd8ec07ccc 100644 --- a/google/cloud/certificatemanager/v1/internal/certificate_manager_tracing_connection.h +++ b/google/cloud/certificatemanager/v1/internal/certificate_manager_tracing_connection.h @@ -327,6 +327,12 @@ class CertificateManagerTracingConnection future> DeleteTrustConfig(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/certificatemanager/v1/internal/certificate_manager_tracing_stub.cc b/google/cloud/certificatemanager/v1/internal/certificate_manager_tracing_stub.cc index f6293ca3de79b..da00e47b81e37 100644 --- a/google/cloud/certificatemanager/v1/internal/certificate_manager_tracing_stub.cc +++ b/google/cloud/certificatemanager/v1/internal/certificate_manager_tracing_stub.cc @@ -741,6 +741,30 @@ CertificateManagerTracingStub::DeleteTrustConfig( context, *span, child_->DeleteTrustConfig(context, options, request)); } +StatusOr +CertificateManagerTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.certificatemanager.v1.CertificateManager", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +CertificateManagerTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.certificatemanager.v1.CertificateManager", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> CertificateManagerTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/certificatemanager/v1/internal/certificate_manager_tracing_stub.h b/google/cloud/certificatemanager/v1/internal/certificate_manager_tracing_stub.h index fe92c305b3867..a6a69e0b963bb 100644 --- a/google/cloud/certificatemanager/v1/internal/certificate_manager_tracing_stub.h +++ b/google/cloud/certificatemanager/v1/internal/certificate_manager_tracing_stub.h @@ -320,6 +320,14 @@ class CertificateManagerTracingStub : public CertificateManagerStub { google::cloud::certificatemanager::v1::DeleteTrustConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/certificatemanager/v1/mocks/mock_certificate_manager_connection.h b/google/cloud/certificatemanager/v1/mocks/mock_certificate_manager_connection.h index 151c0eecb3246..cdbfd67d2269a 100644 --- a/google/cloud/certificatemanager/v1/mocks/mock_certificate_manager_connection.h +++ b/google/cloud/certificatemanager/v1/mocks/mock_certificate_manager_connection.h @@ -858,6 +858,14 @@ class MockCertificateManagerConnection StatusOr>, DeleteTrustConfig, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/cloudbuild/BUILD.bazel b/google/cloud/cloudbuild/BUILD.bazel index 6f4e41867eaaa..01ed00c773dc1 100644 --- a/google/cloud/cloudbuild/BUILD.bazel +++ b/google/cloud/cloudbuild/BUILD.bazel @@ -27,6 +27,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/devtools/cloudbuild/v1:cloudbuild_cc_grpc", "@com_google_googleapis//google/devtools/cloudbuild/v2:cloudbuild_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/cloudbuild/v2/internal/repository_manager_auth_decorator.cc b/google/cloud/cloudbuild/v2/internal/repository_manager_auth_decorator.cc index 64007f3bf1eae..929737a99f467 100644 --- a/google/cloud/cloudbuild/v2/internal/repository_manager_auth_decorator.cc +++ b/google/cloud/cloudbuild/v2/internal/repository_manager_auth_decorator.cc @@ -281,6 +281,31 @@ RepositoryManagerAuth::FetchGitRefs( return child_->FetchGitRefs(context, options, request); } +StatusOr RepositoryManagerAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr RepositoryManagerAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +RepositoryManagerAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> RepositoryManagerAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/cloudbuild/v2/internal/repository_manager_auth_decorator.h b/google/cloud/cloudbuild/v2/internal/repository_manager_auth_decorator.h index 0a0cdc6222878..8ae0b20706591 100644 --- a/google/cloud/cloudbuild/v2/internal/repository_manager_auth_decorator.h +++ b/google/cloud/cloudbuild/v2/internal/repository_manager_auth_decorator.h @@ -155,6 +155,18 @@ class RepositoryManagerAuth : public RepositoryManagerStub { google::devtools::cloudbuild::v2::FetchGitRefsRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/cloudbuild/v2/internal/repository_manager_connection_impl.cc b/google/cloud/cloudbuild/v2/internal/repository_manager_connection_impl.cc index 40218508dd506..0382c91fa57a3 100644 --- a/google/cloud/cloudbuild/v2/internal/repository_manager_connection_impl.cc +++ b/google/cloud/cloudbuild/v2/internal/repository_manager_connection_impl.cc @@ -818,6 +818,46 @@ RepositoryManagerConnectionImpl::FetchGitRefs( *current, request, __func__); } +StatusOr RepositoryManagerConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr RepositoryManagerConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +RepositoryManagerConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloudbuild_v2_internal } // namespace cloud diff --git a/google/cloud/cloudbuild/v2/internal/repository_manager_connection_impl.h b/google/cloud/cloudbuild/v2/internal/repository_manager_connection_impl.h index 5c700181e7030..38f600c90a4ec 100644 --- a/google/cloud/cloudbuild/v2/internal/repository_manager_connection_impl.h +++ b/google/cloud/cloudbuild/v2/internal/repository_manager_connection_impl.h @@ -167,6 +167,15 @@ class RepositoryManagerConnectionImpl google::devtools::cloudbuild::v2::FetchGitRefsRequest const& request) override; + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/cloudbuild/v2/internal/repository_manager_logging_decorator.cc b/google/cloud/cloudbuild/v2/internal/repository_manager_logging_decorator.cc index c0813bc495113..ee9671569ecb7 100644 --- a/google/cloud/cloudbuild/v2/internal/repository_manager_logging_decorator.cc +++ b/google/cloud/cloudbuild/v2/internal/repository_manager_logging_decorator.cc @@ -335,6 +335,40 @@ RepositoryManagerLogging::FetchGitRefs( context, options, request, __func__, tracing_options_); } +StatusOr RepositoryManagerLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr RepositoryManagerLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +RepositoryManagerLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> RepositoryManagerLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/cloudbuild/v2/internal/repository_manager_logging_decorator.h b/google/cloud/cloudbuild/v2/internal/repository_manager_logging_decorator.h index 22c0c6e227347..d4d4d8361b971 100644 --- a/google/cloud/cloudbuild/v2/internal/repository_manager_logging_decorator.h +++ b/google/cloud/cloudbuild/v2/internal/repository_manager_logging_decorator.h @@ -155,6 +155,18 @@ class RepositoryManagerLogging : public RepositoryManagerStub { google::devtools::cloudbuild::v2::FetchGitRefsRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/cloudbuild/v2/internal/repository_manager_metadata_decorator.cc b/google/cloud/cloudbuild/v2/internal/repository_manager_metadata_decorator.cc index 3785995b4afaa..12ee9c6e3dccb 100644 --- a/google/cloud/cloudbuild/v2/internal/repository_manager_metadata_decorator.cc +++ b/google/cloud/cloudbuild/v2/internal/repository_manager_metadata_decorator.cc @@ -252,6 +252,34 @@ RepositoryManagerMetadata::FetchGitRefs( return child_->FetchGitRefs(context, options, request); } +StatusOr RepositoryManagerMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr RepositoryManagerMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +RepositoryManagerMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> RepositoryManagerMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/cloudbuild/v2/internal/repository_manager_metadata_decorator.h b/google/cloud/cloudbuild/v2/internal/repository_manager_metadata_decorator.h index 4d5257b966b44..861e43212be5c 100644 --- a/google/cloud/cloudbuild/v2/internal/repository_manager_metadata_decorator.h +++ b/google/cloud/cloudbuild/v2/internal/repository_manager_metadata_decorator.h @@ -156,6 +156,18 @@ class RepositoryManagerMetadata : public RepositoryManagerStub { google::devtools::cloudbuild::v2::FetchGitRefsRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/cloudbuild/v2/internal/repository_manager_stub.cc b/google/cloud/cloudbuild/v2/internal/repository_manager_stub.cc index bfdacd0254dec..3eb1aab2e4287 100644 --- a/google/cloud/cloudbuild/v2/internal/repository_manager_stub.cc +++ b/google/cloud/cloudbuild/v2/internal/repository_manager_stub.cc @@ -319,6 +319,41 @@ DefaultRepositoryManagerStub::FetchGitRefs( return response; } +StatusOr DefaultRepositoryManagerStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultRepositoryManagerStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultRepositoryManagerStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultRepositoryManagerStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/cloudbuild/v2/internal/repository_manager_stub.h b/google/cloud/cloudbuild/v2/internal/repository_manager_stub.h index 5d75f9e262df8..a53bbdd549dd7 100644 --- a/google/cloud/cloudbuild/v2/internal/repository_manager_stub.h +++ b/google/cloud/cloudbuild/v2/internal/repository_manager_stub.h @@ -24,8 +24,11 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include +#include +#include #include #include #include @@ -163,6 +166,19 @@ class RepositoryManagerStub { grpc::ClientContext& context, Options const& options, google::devtools::cloudbuild::v2::FetchGitRefsRequest const& request) = 0; + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -182,9 +198,12 @@ class DefaultRepositoryManagerStub : public RepositoryManagerStub { std::unique_ptr< google::devtools::cloudbuild::v2::RepositoryManager::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + operations_(std::move(operations)) {} future> AsyncCreateConnection( google::cloud::CompletionQueue& cq, @@ -302,6 +321,18 @@ class DefaultRepositoryManagerStub : public RepositoryManagerStub { google::devtools::cloudbuild::v2::FetchGitRefsRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -318,6 +349,7 @@ class DefaultRepositoryManagerStub : public RepositoryManagerStub { std::unique_ptr< google::devtools::cloudbuild::v2::RepositoryManager::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/cloudbuild/v2/internal/repository_manager_stub_factory.cc b/google/cloud/cloudbuild/v2/internal/repository_manager_stub_factory.cc index 7b997ec6e9f9e..4ce505107fb20 100644 --- a/google/cloud/cloudbuild/v2/internal/repository_manager_stub_factory.cc +++ b/google/cloud/cloudbuild/v2/internal/repository_manager_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,9 +45,10 @@ std::shared_ptr CreateDefaultRepositoryManagerStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::devtools::cloudbuild::v2::RepositoryManager::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/cloudbuild/v2/internal/repository_manager_tracing_connection.cc b/google/cloud/cloudbuild/v2/internal/repository_manager_tracing_connection.cc index 8ed0c821f23cf..85905ea8bdd94 100644 --- a/google/cloud/cloudbuild/v2/internal/repository_manager_tracing_connection.cc +++ b/google/cloud/cloudbuild/v2/internal/repository_manager_tracing_connection.cc @@ -301,6 +301,33 @@ RepositoryManagerTracingConnection::FetchGitRefs( return internal::EndSpan(*span, child_->FetchGitRefs(request)); } +StatusOr +RepositoryManagerTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "cloudbuild_v2::RepositoryManagerConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +RepositoryManagerTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "cloudbuild_v2::RepositoryManagerConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +RepositoryManagerTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "cloudbuild_v2::RepositoryManagerConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/cloudbuild/v2/internal/repository_manager_tracing_connection.h b/google/cloud/cloudbuild/v2/internal/repository_manager_tracing_connection.h index c4fc658122398..fbae1cde4413d 100644 --- a/google/cloud/cloudbuild/v2/internal/repository_manager_tracing_connection.h +++ b/google/cloud/cloudbuild/v2/internal/repository_manager_tracing_connection.h @@ -155,6 +155,15 @@ class RepositoryManagerTracingConnection google::devtools::cloudbuild::v2::FetchGitRefsRequest const& request) override; + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/cloudbuild/v2/internal/repository_manager_tracing_stub.cc b/google/cloud/cloudbuild/v2/internal/repository_manager_tracing_stub.cc index 536a46d37acfa..a0c069951cc92 100644 --- a/google/cloud/cloudbuild/v2/internal/repository_manager_tracing_stub.cc +++ b/google/cloud/cloudbuild/v2/internal/repository_manager_tracing_stub.cc @@ -299,6 +299,40 @@ RepositoryManagerTracingStub::FetchGitRefs( child_->FetchGitRefs(context, options, request)); } +StatusOr RepositoryManagerTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.devtools.cloudbuild.v2.RepositoryManager", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr RepositoryManagerTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.devtools.cloudbuild.v2.RepositoryManager", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +RepositoryManagerTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.devtools.cloudbuild.v2.RepositoryManager", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> RepositoryManagerTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/cloudbuild/v2/internal/repository_manager_tracing_stub.h b/google/cloud/cloudbuild/v2/internal/repository_manager_tracing_stub.h index b39a670648949..55e13f78facee 100644 --- a/google/cloud/cloudbuild/v2/internal/repository_manager_tracing_stub.h +++ b/google/cloud/cloudbuild/v2/internal/repository_manager_tracing_stub.h @@ -155,6 +155,18 @@ class RepositoryManagerTracingStub : public RepositoryManagerStub { google::devtools::cloudbuild::v2::FetchGitRefsRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/cloudbuild/v2/mocks/mock_repository_manager_connection.h b/google/cloud/cloudbuild/v2/mocks/mock_repository_manager_connection.h index 255b4d36231ea..f830e0cb5de0c 100644 --- a/google/cloud/cloudbuild/v2/mocks/mock_repository_manager_connection.h +++ b/google/cloud/cloudbuild/v2/mocks/mock_repository_manager_connection.h @@ -338,6 +338,19 @@ class MockRepositoryManagerConnection FetchGitRefs, (google::devtools::cloudbuild::v2::FetchGitRefsRequest const& request), (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/cloudbuild/v2/repository_manager_client.cc b/google/cloud/cloudbuild/v2/repository_manager_client.cc index 0d76b3130daf2..9a2c485fbd53b 100644 --- a/google/cloud/cloudbuild/v2/repository_manager_client.cc +++ b/google/cloud/cloudbuild/v2/repository_manager_client.cc @@ -444,6 +444,25 @@ RepositoryManagerClient::FetchGitRefs( return connection_->FetchGitRefs(request); } +StatusOr RepositoryManagerClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr RepositoryManagerClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +RepositoryManagerClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloudbuild_v2 } // namespace cloud diff --git a/google/cloud/cloudbuild/v2/repository_manager_client.h b/google/cloud/cloudbuild/v2/repository_manager_client.h index 0af52d22a6984..15bb783f6e4c0 100644 --- a/google/cloud/cloudbuild/v2/repository_manager_client.h +++ b/google/cloud/cloudbuild/v2/repository_manager_client.h @@ -1302,6 +1302,108 @@ class RepositoryManagerClient { google::devtools::cloudbuild::v2::FetchGitRefsRequest const& request, Options opts = {}); + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/cloudbuild/v2/repository_manager_connection.cc b/google/cloud/cloudbuild/v2/repository_manager_connection.cc index 5f0d3ed8b60ba..df2ca3c6c89c8 100644 --- a/google/cloud/cloudbuild/v2/repository_manager_connection.cc +++ b/google/cloud/cloudbuild/v2/repository_manager_connection.cc @@ -238,6 +238,22 @@ RepositoryManagerConnection::FetchGitRefs( return Status(StatusCode::kUnimplemented, "not implemented"); } +StatusOr RepositoryManagerConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr RepositoryManagerConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +RepositoryManagerConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeRepositoryManagerConnection( Options options) { internal::CheckExpectedOptions #include #include +#include #include #include @@ -290,6 +292,15 @@ class RepositoryManagerConnection { virtual StatusOr FetchGitRefs( google::devtools::cloudbuild::v2::FetchGitRefsRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/cloudbuild/v2/repository_manager_connection_idempotency_policy.cc b/google/cloud/cloudbuild/v2/repository_manager_connection_idempotency_policy.cc index 85aee1c47d2c4..823a0684a5aba 100644 --- a/google/cloud/cloudbuild/v2/repository_manager_connection_idempotency_policy.cc +++ b/google/cloud/cloudbuild/v2/repository_manager_connection_idempotency_policy.cc @@ -107,6 +107,22 @@ Idempotency RepositoryManagerConnectionIdempotencyPolicy::FetchGitRefs( return Idempotency::kIdempotent; } +Idempotency RepositoryManagerConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency RepositoryManagerConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency RepositoryManagerConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultRepositoryManagerConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/cloudbuild/v2/repository_manager_connection_idempotency_policy.h b/google/cloud/cloudbuild/v2/repository_manager_connection_idempotency_policy.h index ce72f9354600d..acf30899f09e7 100644 --- a/google/cloud/cloudbuild/v2/repository_manager_connection_idempotency_policy.h +++ b/google/cloud/cloudbuild/v2/repository_manager_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -81,6 +82,15 @@ class RepositoryManagerConnectionIdempotencyPolicy { virtual google::cloud::Idempotency FetchGitRefs( google::devtools::cloudbuild::v2::FetchGitRefsRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/confidentialcomputing/BUILD.bazel b/google/cloud/confidentialcomputing/BUILD.bazel index 472ceffc849d7..980a6f30ea838 100644 --- a/google/cloud/confidentialcomputing/BUILD.bazel +++ b/google/cloud/confidentialcomputing/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/confidentialcomputing/v1:confidentialcomputing_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/confidentialcomputing/v1/confidential_computing_client.cc b/google/cloud/confidentialcomputing/v1/confidential_computing_client.cc index e35d2899f32c2..0af687d39031e 100644 --- a/google/cloud/confidentialcomputing/v1/confidential_computing_client.cc +++ b/google/cloud/confidentialcomputing/v1/confidential_computing_client.cc @@ -62,6 +62,20 @@ ConfidentialComputingClient::VerifyAttestation( return connection_->VerifyAttestation(request); } +StreamRange +ConfidentialComputingClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +ConfidentialComputingClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace confidentialcomputing_v1 } // namespace cloud diff --git a/google/cloud/confidentialcomputing/v1/confidential_computing_client.h b/google/cloud/confidentialcomputing/v1/confidential_computing_client.h index fca38669b28cc..4234f3af1dc03 100644 --- a/google/cloud/confidentialcomputing/v1/confidential_computing_client.h +++ b/google/cloud/confidentialcomputing/v1/confidential_computing_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -183,6 +184,76 @@ class ConfidentialComputingClient { request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/confidentialcomputing/v1/confidential_computing_connection.cc b/google/cloud/confidentialcomputing/v1/confidential_computing_connection.cc index 8b1fe09798313..bf64029f8c2e4 100644 --- a/google/cloud/confidentialcomputing/v1/confidential_computing_connection.cc +++ b/google/cloud/confidentialcomputing/v1/confidential_computing_connection.cc @@ -26,6 +26,7 @@ #include "google/cloud/common_options.h" #include "google/cloud/credentials.h" #include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/unified_grpc_credentials.h" #include #include @@ -49,6 +50,20 @@ ConfidentialComputingConnection::VerifyAttestation( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +ConfidentialComputingConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +ConfidentialComputingConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeConfidentialComputingConnection(Options options) { internal::CheckExpectedOptions +#include #include namespace google { @@ -198,6 +200,12 @@ class ConfidentialComputingConnection { VerifyAttestation( google::cloud::confidentialcomputing::v1::VerifyAttestationRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/confidentialcomputing/v1/confidential_computing_connection_idempotency_policy.cc b/google/cloud/confidentialcomputing/v1/confidential_computing_connection_idempotency_policy.cc index 4aeeac9a8cb3c..4ba21b4d75ece 100644 --- a/google/cloud/confidentialcomputing/v1/confidential_computing_connection_idempotency_policy.cc +++ b/google/cloud/confidentialcomputing/v1/confidential_computing_connection_idempotency_policy.cc @@ -45,6 +45,16 @@ Idempotency ConfidentialComputingConnectionIdempotencyPolicy::VerifyAttestation( return Idempotency::kNonIdempotent; } +Idempotency ConfidentialComputingConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ConfidentialComputingConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultConfidentialComputingConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/confidentialcomputing/v1/confidential_computing_connection_idempotency_policy.h b/google/cloud/confidentialcomputing/v1/confidential_computing_connection_idempotency_policy.h index 2421160c3657c..d25b05d48f8ea 100644 --- a/google/cloud/confidentialcomputing/v1/confidential_computing_connection_idempotency_policy.h +++ b/google/cloud/confidentialcomputing/v1/confidential_computing_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -44,6 +45,12 @@ class ConfidentialComputingConnectionIdempotencyPolicy { virtual google::cloud::Idempotency VerifyAttestation( google::cloud::confidentialcomputing::v1::VerifyAttestationRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_auth_decorator.cc b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_auth_decorator.cc index 12880c3de9d33..0b6b9e655a0f5 100644 --- a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_auth_decorator.cc +++ b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_auth_decorator.cc @@ -51,6 +51,24 @@ ConfidentialComputingAuth::VerifyAttestation( return child_->VerifyAttestation(context, options, request); } +StatusOr +ConfidentialComputingAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +ConfidentialComputingAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace confidentialcomputing_v1_internal } // namespace cloud diff --git a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_auth_decorator.h b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_auth_decorator.h index 62112d603e72e..be6c5f0c2beaa 100644 --- a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_auth_decorator.h +++ b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_auth_decorator.h @@ -49,6 +49,14 @@ class ConfidentialComputingAuth : public ConfidentialComputingStub { google::cloud::confidentialcomputing::v1::VerifyAttestationRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_connection_impl.cc b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_connection_impl.cc index daa0bf7ed2625..9327958eea086 100644 --- a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_connection_impl.cc +++ b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_connection_impl.cc @@ -21,6 +21,7 @@ #include "google/cloud/background_threads.h" #include "google/cloud/common_options.h" #include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/retry_loop.h" #include #include @@ -98,6 +99,55 @@ ConfidentialComputingConnectionImpl::VerifyAttestation( *current, request, __func__); } +StreamRange +ConfidentialComputingConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr< + confidentialcomputing_v1::ConfidentialComputingRetryPolicy>( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ConfidentialComputingConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace confidentialcomputing_v1_internal } // namespace cloud diff --git a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_connection_impl.h b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_connection_impl.h index 491a9686e495b..3d39def2d8ccb 100644 --- a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_connection_impl.h +++ b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_connection_impl.h @@ -28,6 +28,7 @@ #include "google/cloud/backoff_policy.h" #include "google/cloud/options.h" #include "google/cloud/status_or.h" +#include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include @@ -59,6 +60,12 @@ class ConfidentialComputingConnectionImpl google::cloud::confidentialcomputing::v1::VerifyAttestationRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr diff --git a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_logging_decorator.cc b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_logging_decorator.cc index 87ade2e6cb772..e2af89806ae67 100644 --- a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_logging_decorator.cc +++ b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_logging_decorator.cc @@ -63,6 +63,30 @@ ConfidentialComputingLogging::VerifyAttestation( context, options, request, __func__, tracing_options_); } +StatusOr +ConfidentialComputingLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ConfidentialComputingLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace confidentialcomputing_v1_internal } // namespace cloud diff --git a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_logging_decorator.h b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_logging_decorator.h index 29f312d79afa1..afb1ddb87f19e 100644 --- a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_logging_decorator.h +++ b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_logging_decorator.h @@ -49,6 +49,14 @@ class ConfidentialComputingLogging : public ConfidentialComputingStub { google::cloud::confidentialcomputing::v1::VerifyAttestationRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_metadata_decorator.cc b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_metadata_decorator.cc index ae6c7a51a9aba..9659830ec4a63 100644 --- a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_metadata_decorator.cc +++ b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_metadata_decorator.cc @@ -65,6 +65,24 @@ ConfidentialComputingMetadata::VerifyAttestation( return child_->VerifyAttestation(context, options, request); } +StatusOr +ConfidentialComputingMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +ConfidentialComputingMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void ConfidentialComputingMetadata::SetMetadata( grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_metadata_decorator.h b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_metadata_decorator.h index 293bff9648e7e..e7d1b9371774d 100644 --- a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_metadata_decorator.h +++ b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_metadata_decorator.h @@ -50,6 +50,14 @@ class ConfidentialComputingMetadata : public ConfidentialComputingStub { google::cloud::confidentialcomputing::v1::VerifyAttestationRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_stub.cc b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_stub.cc index ca27e9eff9127..a05cd1d5e0968 100644 --- a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_stub.cc +++ b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_stub.cc @@ -56,6 +56,30 @@ DefaultConfidentialComputingStub::VerifyAttestation( return response; } +StatusOr +DefaultConfidentialComputingStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultConfidentialComputingStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace confidentialcomputing_v1_internal } // namespace cloud diff --git a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_stub.h b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_stub.h index a8d912f161521..1a7daea09c1ad 100644 --- a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_stub.h +++ b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_stub.h @@ -23,6 +23,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -47,6 +49,15 @@ class ConfidentialComputingStub { grpc::ClientContext& context, Options const& options, google::cloud::confidentialcomputing::v1::VerifyAttestationRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultConfidentialComputingStub : public ConfidentialComputingStub { @@ -54,8 +65,11 @@ class DefaultConfidentialComputingStub : public ConfidentialComputingStub { explicit DefaultConfidentialComputingStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr CreateChallenge( grpc::ClientContext& context, Options const& options, @@ -68,10 +82,20 @@ class DefaultConfidentialComputingStub : public ConfidentialComputingStub { google::cloud::confidentialcomputing::v1::VerifyAttestationRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_stub_factory.cc b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_stub_factory.cc index 044085725dace..7103c3697ec62 100644 --- a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_stub_factory.cc +++ b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -46,9 +47,11 @@ CreateDefaultConfidentialComputingStub( auto service_grpc_stub = google::cloud::confidentialcomputing::v1::ConfidentialComputing::NewStub( channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_tracing_connection.cc b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_tracing_connection.cc index 1228d2a626a2f..cce11a319a40c 100644 --- a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_tracing_connection.cc +++ b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/confidentialcomputing/v1/internal/confidential_computing_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -55,6 +56,27 @@ ConfidentialComputingTracingConnection::VerifyAttestation( return internal::EndSpan(*span, child_->VerifyAttestation(request)); } +StreamRange +ConfidentialComputingTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "confidentialcomputing_v1::ConfidentialComputingConnection::" + "ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ConfidentialComputingTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "confidentialcomputing_v1::ConfidentialComputingConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_tracing_connection.h b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_tracing_connection.h index 0b1c88a48309d..3039215a08a76 100644 --- a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_tracing_connection.h +++ b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_tracing_connection.h @@ -50,6 +50,12 @@ class ConfidentialComputingTracingConnection google::cloud::confidentialcomputing::v1::VerifyAttestationRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; diff --git a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_tracing_stub.cc b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_tracing_stub.cc index 92852708dda25..1811b548550a7 100644 --- a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_tracing_stub.cc +++ b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_tracing_stub.cc @@ -60,6 +60,32 @@ ConfidentialComputingTracingStub::VerifyAttestation( context, *span, child_->VerifyAttestation(context, options, request)); } +StatusOr +ConfidentialComputingTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.confidentialcomputing.v1.ConfidentialComputing", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +ConfidentialComputingTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.confidentialcomputing.v1.ConfidentialComputing", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeConfidentialComputingTracingStub( diff --git a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_tracing_stub.h b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_tracing_stub.h index eb0f6f22e5693..98ff9dec40e00 100644 --- a/google/cloud/confidentialcomputing/v1/internal/confidential_computing_tracing_stub.h +++ b/google/cloud/confidentialcomputing/v1/internal/confidential_computing_tracing_stub.h @@ -50,6 +50,14 @@ class ConfidentialComputingTracingStub : public ConfidentialComputingStub { google::cloud::confidentialcomputing::v1::VerifyAttestationRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/confidentialcomputing/v1/mocks/mock_confidential_computing_connection.h b/google/cloud/confidentialcomputing/v1/mocks/mock_confidential_computing_connection.h index ac2a676ce889f..d50913f1868d0 100644 --- a/google/cloud/confidentialcomputing/v1/mocks/mock_confidential_computing_connection.h +++ b/google/cloud/confidentialcomputing/v1/mocks/mock_confidential_computing_connection.h @@ -61,6 +61,14 @@ class MockConfidentialComputingConnection (google::cloud::confidentialcomputing::v1::VerifyAttestationRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/config/BUILD.bazel b/google/cloud/config/BUILD.bazel index b9fc4817edc99..b4ba517c929a6 100644 --- a/google/cloud/config/BUILD.bazel +++ b/google/cloud/config/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/config/v1:config_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/config/v1/config_client.cc b/google/cloud/config/v1/config_client.cc index 5b54d4ea02a60..73846d82728bc 100644 --- a/google/cloud/config/v1/config_client.cc +++ b/google/cloud/config/v1/config_client.cc @@ -541,6 +541,37 @@ ConfigClient::GetTerraformVersion( return connection_->GetTerraformVersion(request); } +StreamRange ConfigClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr ConfigClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr ConfigClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr ConfigClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +ConfigClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace config_v1 } // namespace cloud diff --git a/google/cloud/config/v1/config_client.h b/google/cloud/config/v1/config_client.h index 6821789dbe6d3..12bf0f4bf19ef 100644 --- a/google/cloud/config/v1/config_client.h +++ b/google/cloud/config/v1/config_client.h @@ -1841,6 +1841,178 @@ class ConfigClient { google::cloud::config::v1::GetTerraformVersionRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/config/v1/config_connection.cc b/google/cloud/config/v1/config_connection.cc index 4e6be125ce80f..b202d1ad39269 100644 --- a/google/cloud/config/v1/config_connection.cc +++ b/google/cloud/config/v1/config_connection.cc @@ -284,6 +284,34 @@ ConfigConnection::GetTerraformVersion( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange ConfigConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ConfigConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr ConfigConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr ConfigConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +ConfigConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeConfigConnection(Options options) { internal::CheckExpectedOptions +#include +#include #include #include @@ -310,6 +312,21 @@ class ConfigConnection { virtual StatusOr GetTerraformVersion( google::cloud::config::v1::GetTerraformVersionRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/config/v1/config_connection_idempotency_policy.cc b/google/cloud/config/v1/config_connection_idempotency_policy.cc index 3df91e60c53f4..a1f66f9ef7571 100644 --- a/google/cloud/config/v1/config_connection_idempotency_policy.cc +++ b/google/cloud/config/v1/config_connection_idempotency_policy.cc @@ -149,6 +149,32 @@ Idempotency ConfigConnectionIdempotencyPolicy::GetTerraformVersion( return Idempotency::kIdempotent; } +Idempotency ConfigConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ConfigConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ConfigConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency ConfigConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ConfigConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultConfigConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/config/v1/config_connection_idempotency_policy.h b/google/cloud/config/v1/config_connection_idempotency_policy.h index 3310b0aa592bd..11959ed56b00d 100644 --- a/google/cloud/config/v1/config_connection_idempotency_policy.h +++ b/google/cloud/config/v1/config_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -105,6 +107,21 @@ class ConfigConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GetTerraformVersion( google::cloud::config::v1::GetTerraformVersionRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/config/v1/internal/config_auth_decorator.cc b/google/cloud/config/v1/internal/config_auth_decorator.cc index 624fcd07b0f06..232b9b89c05fc 100644 --- a/google/cloud/config/v1/internal/config_auth_decorator.cc +++ b/google/cloud/config/v1/internal/config_auth_decorator.cc @@ -363,6 +363,48 @@ ConfigAuth::GetTerraformVersion( return child_->GetTerraformVersion(context, options, request); } +StatusOr +ConfigAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr ConfigAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr ConfigAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr ConfigAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +ConfigAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> ConfigAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/config/v1/internal/config_auth_decorator.h b/google/cloud/config/v1/internal/config_auth_decorator.h index df608a2b8e94c..36a9082f96c60 100644 --- a/google/cloud/config/v1/internal/config_auth_decorator.h +++ b/google/cloud/config/v1/internal/config_auth_decorator.h @@ -191,6 +191,26 @@ class ConfigAuth : public ConfigStub { google::cloud::config::v1::GetTerraformVersionRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/config/v1/internal/config_connection_impl.cc b/google/cloud/config/v1/internal/config_connection_impl.cc index c81ad28cd7e66..aa23a122a41a8 100644 --- a/google/cloud/config/v1/internal/config_connection_impl.cc +++ b/google/cloud/config/v1/internal/config_connection_impl.cc @@ -1016,6 +1016,93 @@ ConfigConnectionImpl::GetTerraformVersion( *current, request, __func__); } +StreamRange +ConfigConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr ConfigConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr ConfigConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr ConfigConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +ConfigConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace config_v1_internal } // namespace cloud diff --git a/google/cloud/config/v1/internal/config_connection_impl.h b/google/cloud/config/v1/internal/config_connection_impl.h index d765524027c9d..7fbf4488d0b7d 100644 --- a/google/cloud/config/v1/internal/config_connection_impl.h +++ b/google/cloud/config/v1/internal/config_connection_impl.h @@ -184,6 +184,21 @@ class ConfigConnectionImpl : public config_v1::ConfigConnection { google::cloud::config::v1::GetTerraformVersionRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/config/v1/internal/config_logging_decorator.cc b/google/cloud/config/v1/internal/config_logging_decorator.cc index d22011211e6a5..b2f4fe8784260 100644 --- a/google/cloud/config/v1/internal/config_logging_decorator.cc +++ b/google/cloud/config/v1/internal/config_logging_decorator.cc @@ -437,6 +437,63 @@ ConfigLogging::GetTerraformVersion( context, options, request, __func__, tracing_options_); } +StatusOr +ConfigLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ConfigLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ConfigLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ConfigLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ConfigLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ConfigLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/config/v1/internal/config_logging_decorator.h b/google/cloud/config/v1/internal/config_logging_decorator.h index a57873ba97212..669833bf047e0 100644 --- a/google/cloud/config/v1/internal/config_logging_decorator.h +++ b/google/cloud/config/v1/internal/config_logging_decorator.h @@ -191,6 +191,26 @@ class ConfigLogging : public ConfigStub { google::cloud::config::v1::GetTerraformVersionRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/config/v1/internal/config_metadata_decorator.cc b/google/cloud/config/v1/internal/config_metadata_decorator.cc index 70d7e54ad0ab0..b79cd4c18ae43 100644 --- a/google/cloud/config/v1/internal/config_metadata_decorator.cc +++ b/google/cloud/config/v1/internal/config_metadata_decorator.cc @@ -324,6 +324,51 @@ ConfigMetadata::GetTerraformVersion( return child_->GetTerraformVersion(context, options, request); } +StatusOr +ConfigMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr ConfigMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr ConfigMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr ConfigMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +ConfigMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> ConfigMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/config/v1/internal/config_metadata_decorator.h b/google/cloud/config/v1/internal/config_metadata_decorator.h index a6d567c784127..6ea44056ded36 100644 --- a/google/cloud/config/v1/internal/config_metadata_decorator.h +++ b/google/cloud/config/v1/internal/config_metadata_decorator.h @@ -191,6 +191,26 @@ class ConfigMetadata : public ConfigStub { google::cloud::config::v1::GetTerraformVersionRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/config/v1/internal/config_stub.cc b/google/cloud/config/v1/internal/config_stub.cc index d1f8b21de959e..9cf906c075652 100644 --- a/google/cloud/config/v1/internal/config_stub.cc +++ b/google/cloud/config/v1/internal/config_stub.cc @@ -424,6 +424,64 @@ DefaultConfigStub::GetTerraformVersion( return response; } +StatusOr +DefaultConfigStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultConfigStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultConfigStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultConfigStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultConfigStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultConfigStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/config/v1/internal/config_stub.h b/google/cloud/config/v1/internal/config_stub.h index 2ec06c6474ef0..14936e4ac0be1 100644 --- a/google/cloud/config/v1/internal/config_stub.h +++ b/google/cloud/config/v1/internal/config_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -188,6 +192,28 @@ class ConfigStub { grpc::ClientContext& context, Options const& options, google::cloud::config::v1::GetTerraformVersionRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -206,9 +232,15 @@ class DefaultConfigStub : public ConfigStub { DefaultConfigStub( std::unique_ptr grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListDeployments( grpc::ClientContext& context, Options const& options, @@ -362,6 +394,26 @@ class DefaultConfigStub : public ConfigStub { google::cloud::config::v1::GetTerraformVersionRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -376,6 +428,9 @@ class DefaultConfigStub : public ConfigStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/config/v1/internal/config_stub_factory.cc b/google/cloud/config/v1/internal/config_stub_factory.cc index 5bf94a71bc83d..2092ba2b577fe 100644 --- a/google/cloud/config/v1/internal/config_stub_factory.cc +++ b/google/cloud/config/v1/internal/config_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -43,8 +45,12 @@ std::shared_ptr CreateDefaultConfigStub( auto channel = auth->CreateChannel(options.get(), internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::config::v1::Config::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/config/v1/internal/config_tracing_connection.cc b/google/cloud/config/v1/internal/config_tracing_connection.cc index de0a79e1858d5..3afa5bd1a85b9 100644 --- a/google/cloud/config/v1/internal/config_tracing_connection.cc +++ b/google/cloud/config/v1/internal/config_tracing_connection.cc @@ -374,6 +374,47 @@ ConfigTracingConnection::GetTerraformVersion( return internal::EndSpan(*span, child_->GetTerraformVersion(request)); } +StreamRange +ConfigTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan("config_v1::ConfigConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ConfigTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan("config_v1::ConfigConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr ConfigTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan("config_v1::ConfigConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr ConfigTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan("config_v1::ConfigConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +ConfigTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = + internal::MakeSpan("config_v1::ConfigConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeConfigTracingConnection( diff --git a/google/cloud/config/v1/internal/config_tracing_connection.h b/google/cloud/config/v1/internal/config_tracing_connection.h index 1c3fe2a09bdc8..8391ac4cfbdb6 100644 --- a/google/cloud/config/v1/internal/config_tracing_connection.h +++ b/google/cloud/config/v1/internal/config_tracing_connection.h @@ -173,6 +173,21 @@ class ConfigTracingConnection : public config_v1::ConfigConnection { google::cloud::config::v1::GetTerraformVersionRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/config/v1/internal/config_tracing_stub.cc b/google/cloud/config/v1/internal/config_tracing_stub.cc index 986b118c39b0e..a6d7f51ee8d93 100644 --- a/google/cloud/config/v1/internal/config_tracing_stub.cc +++ b/google/cloud/config/v1/internal/config_tracing_stub.cc @@ -401,6 +401,63 @@ ConfigTracingStub::GetTerraformVersion( context, *span, child_->GetTerraformVersion(context, options, request)); } +StatusOr +ConfigTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.config.v1.Config", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr ConfigTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.config.v1.Config", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr ConfigTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.config.v1.Config", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr ConfigTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.config.v1.Config", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +ConfigTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.config.v1.Config", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> ConfigTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/config/v1/internal/config_tracing_stub.h b/google/cloud/config/v1/internal/config_tracing_stub.h index 83e0413c7b8a2..7c304ea9842f4 100644 --- a/google/cloud/config/v1/internal/config_tracing_stub.h +++ b/google/cloud/config/v1/internal/config_tracing_stub.h @@ -190,6 +190,26 @@ class ConfigTracingStub : public ConfigStub { google::cloud::config::v1::GetTerraformVersionRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/config/v1/mocks/mock_config_connection.h b/google/cloud/config/v1/mocks/mock_config_connection.h index 99c4215c01a3f..4d6daef39497c 100644 --- a/google/cloud/config/v1/mocks/mock_config_connection.h +++ b/google/cloud/config/v1/mocks/mock_config_connection.h @@ -384,6 +384,27 @@ class MockConfigConnection : public config_v1::ConfigConnection { GetTerraformVersion, (google::cloud::config::v1::GetTerraformVersionRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/connectors/BUILD.bazel b/google/cloud/connectors/BUILD.bazel index ed474bb371edc..d7237e4310c64 100644 --- a/google/cloud/connectors/BUILD.bazel +++ b/google/cloud/connectors/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/connectors/v1:connectors_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/connectors/v1/connectors_client.cc b/google/cloud/connectors/v1/connectors_client.cc index 9110c506e0ed3..cf0bcc31ebe69 100644 --- a/google/cloud/connectors/v1/connectors_client.cc +++ b/google/cloud/connectors/v1/connectors_client.cc @@ -419,6 +419,37 @@ ConnectorsClient::GetGlobalSettings( return connection_->GetGlobalSettings(request); } +StreamRange ConnectorsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr ConnectorsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr ConnectorsClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr ConnectorsClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +ConnectorsClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace connectors_v1 } // namespace cloud diff --git a/google/cloud/connectors/v1/connectors_client.h b/google/cloud/connectors/v1/connectors_client.h index a5b09c1322e4e..34dc251e0290b 100644 --- a/google/cloud/connectors/v1/connectors_client.h +++ b/google/cloud/connectors/v1/connectors_client.h @@ -1437,6 +1437,178 @@ class ConnectorsClient { google::cloud::connectors::v1::GetGlobalSettingsRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/connectors/v1/connectors_connection.cc b/google/cloud/connectors/v1/connectors_connection.cc index a520a513098a8..22295ee5a9978 100644 --- a/google/cloud/connectors/v1/connectors_connection.cc +++ b/google/cloud/connectors/v1/connectors_connection.cc @@ -216,6 +216,35 @@ ConnectorsConnection::GetGlobalSettings( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +ConnectorsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ConnectorsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr ConnectorsConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr ConnectorsConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +ConnectorsConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeConnectorsConnection( Options options) { internal::CheckExpectedOptions +#include +#include #include #include @@ -280,6 +282,21 @@ class ConnectorsConnection { virtual StatusOr GetGlobalSettings( google::cloud::connectors::v1::GetGlobalSettingsRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/connectors/v1/connectors_connection_idempotency_policy.cc b/google/cloud/connectors/v1/connectors_connection_idempotency_policy.cc index fd45c84b35e37..a619600393b81 100644 --- a/google/cloud/connectors/v1/connectors_connection_idempotency_policy.cc +++ b/google/cloud/connectors/v1/connectors_connection_idempotency_policy.cc @@ -121,6 +121,32 @@ Idempotency ConnectorsConnectionIdempotencyPolicy::GetGlobalSettings( return Idempotency::kIdempotent; } +Idempotency ConnectorsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ConnectorsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ConnectorsConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency ConnectorsConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ConnectorsConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultConnectorsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/connectors/v1/connectors_connection_idempotency_policy.h b/google/cloud/connectors/v1/connectors_connection_idempotency_policy.h index 7f8110efc1646..23215da6827fe 100644 --- a/google/cloud/connectors/v1/connectors_connection_idempotency_policy.h +++ b/google/cloud/connectors/v1/connectors_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -88,6 +90,21 @@ class ConnectorsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GetGlobalSettings( google::cloud::connectors::v1::GetGlobalSettingsRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/connectors/v1/internal/connectors_auth_decorator.cc b/google/cloud/connectors/v1/internal/connectors_auth_decorator.cc index f09a7bc284d20..a60d396567de5 100644 --- a/google/cloud/connectors/v1/internal/connectors_auth_decorator.cc +++ b/google/cloud/connectors/v1/internal/connectors_auth_decorator.cc @@ -265,6 +265,48 @@ ConnectorsAuth::GetGlobalSettings( return child_->GetGlobalSettings(context, options, request); } +StatusOr +ConnectorsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr ConnectorsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr ConnectorsAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr ConnectorsAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +ConnectorsAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> ConnectorsAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/connectors/v1/internal/connectors_auth_decorator.h b/google/cloud/connectors/v1/internal/connectors_auth_decorator.h index 83d6732607baf..adcc67b5fcbd1 100644 --- a/google/cloud/connectors/v1/internal/connectors_auth_decorator.h +++ b/google/cloud/connectors/v1/internal/connectors_auth_decorator.h @@ -157,6 +157,26 @@ class ConnectorsAuth : public ConnectorsStub { google::cloud::connectors::v1::GetGlobalSettingsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/connectors/v1/internal/connectors_connection_impl.cc b/google/cloud/connectors/v1/internal/connectors_connection_impl.cc index 800ddb83bccc4..9aa5482f3d383 100644 --- a/google/cloud/connectors/v1/internal/connectors_connection_impl.cc +++ b/google/cloud/connectors/v1/internal/connectors_connection_impl.cc @@ -755,6 +755,94 @@ ConnectorsConnectionImpl::GetGlobalSettings( *current, request, __func__); } +StreamRange +ConnectorsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ConnectorsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr ConnectorsConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr ConnectorsConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +ConnectorsConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace connectors_v1_internal } // namespace cloud diff --git a/google/cloud/connectors/v1/internal/connectors_connection_impl.h b/google/cloud/connectors/v1/internal/connectors_connection_impl.h index 46fd7fda14789..c422581c5840e 100644 --- a/google/cloud/connectors/v1/internal/connectors_connection_impl.h +++ b/google/cloud/connectors/v1/internal/connectors_connection_impl.h @@ -154,6 +154,21 @@ class ConnectorsConnectionImpl : public connectors_v1::ConnectorsConnection { google::cloud::connectors::v1::GetGlobalSettingsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/connectors/v1/internal/connectors_logging_decorator.cc b/google/cloud/connectors/v1/internal/connectors_logging_decorator.cc index 064b58f175ae5..a9947411b8f77 100644 --- a/google/cloud/connectors/v1/internal/connectors_logging_decorator.cc +++ b/google/cloud/connectors/v1/internal/connectors_logging_decorator.cc @@ -337,6 +337,63 @@ ConnectorsLogging::GetGlobalSettings( context, options, request, __func__, tracing_options_); } +StatusOr +ConnectorsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ConnectorsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ConnectorsLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ConnectorsLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ConnectorsLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ConnectorsLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/connectors/v1/internal/connectors_logging_decorator.h b/google/cloud/connectors/v1/internal/connectors_logging_decorator.h index 13be39c9dca2e..7054eaf1cfc70 100644 --- a/google/cloud/connectors/v1/internal/connectors_logging_decorator.h +++ b/google/cloud/connectors/v1/internal/connectors_logging_decorator.h @@ -157,6 +157,26 @@ class ConnectorsLogging : public ConnectorsStub { google::cloud::connectors::v1::GetGlobalSettingsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/connectors/v1/internal/connectors_metadata_decorator.cc b/google/cloud/connectors/v1/internal/connectors_metadata_decorator.cc index fe5e9095c2d0a..dd646cb27d3e7 100644 --- a/google/cloud/connectors/v1/internal/connectors_metadata_decorator.cc +++ b/google/cloud/connectors/v1/internal/connectors_metadata_decorator.cc @@ -250,6 +250,51 @@ ConnectorsMetadata::GetGlobalSettings( return child_->GetGlobalSettings(context, options, request); } +StatusOr +ConnectorsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr ConnectorsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr ConnectorsMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr ConnectorsMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +ConnectorsMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> ConnectorsMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/connectors/v1/internal/connectors_metadata_decorator.h b/google/cloud/connectors/v1/internal/connectors_metadata_decorator.h index 5f95c2fca3d39..d95b2286d8e14 100644 --- a/google/cloud/connectors/v1/internal/connectors_metadata_decorator.h +++ b/google/cloud/connectors/v1/internal/connectors_metadata_decorator.h @@ -157,6 +157,26 @@ class ConnectorsMetadata : public ConnectorsStub { google::cloud::connectors::v1::GetGlobalSettingsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/connectors/v1/internal/connectors_stub.cc b/google/cloud/connectors/v1/internal/connectors_stub.cc index 72d2c82dc0b2f..ad55b3cb2595a 100644 --- a/google/cloud/connectors/v1/internal/connectors_stub.cc +++ b/google/cloud/connectors/v1/internal/connectors_stub.cc @@ -322,6 +322,64 @@ DefaultConnectorsStub::GetGlobalSettings( return response; } +StatusOr +DefaultConnectorsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultConnectorsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultConnectorsStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultConnectorsStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultConnectorsStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultConnectorsStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/connectors/v1/internal/connectors_stub.h b/google/cloud/connectors/v1/internal/connectors_stub.h index 5eac10b57440a..8952fd36d5de3 100644 --- a/google/cloud/connectors/v1/internal/connectors_stub.h +++ b/google/cloud/connectors/v1/internal/connectors_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -160,6 +164,28 @@ class ConnectorsStub { google::cloud::connectors::v1::GetGlobalSettingsRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -178,9 +204,15 @@ class DefaultConnectorsStub : public ConnectorsStub { DefaultConnectorsStub( std::unique_ptr grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListConnections(grpc::ClientContext& context, Options const& options, @@ -300,6 +332,26 @@ class DefaultConnectorsStub : public ConnectorsStub { google::cloud::connectors::v1::GetGlobalSettingsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -315,6 +367,9 @@ class DefaultConnectorsStub : public ConnectorsStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/connectors/v1/internal/connectors_stub_factory.cc b/google/cloud/connectors/v1/internal/connectors_stub_factory.cc index 883062efe9c36..ea2cd2ca2136a 100644 --- a/google/cloud/connectors/v1/internal/connectors_stub_factory.cc +++ b/google/cloud/connectors/v1/internal/connectors_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultConnectorsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::connectors::v1::Connectors::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/connectors/v1/internal/connectors_tracing_connection.cc b/google/cloud/connectors/v1/internal/connectors_tracing_connection.cc index 10bae16dae920..698b69f91b504 100644 --- a/google/cloud/connectors/v1/internal/connectors_tracing_connection.cc +++ b/google/cloud/connectors/v1/internal/connectors_tracing_connection.cc @@ -290,6 +290,51 @@ ConnectorsTracingConnection::GetGlobalSettings( return internal::EndSpan(*span, child_->GetGlobalSettings(request)); } +StreamRange +ConnectorsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("connectors_v1::ConnectorsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ConnectorsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("connectors_v1::ConnectorsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr ConnectorsTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("connectors_v1::ConnectorsConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr ConnectorsTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("connectors_v1::ConnectorsConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +ConnectorsTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "connectors_v1::ConnectorsConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/connectors/v1/internal/connectors_tracing_connection.h b/google/cloud/connectors/v1/internal/connectors_tracing_connection.h index a3f6c54e49cde..cfdd896e698f6 100644 --- a/google/cloud/connectors/v1/internal/connectors_tracing_connection.h +++ b/google/cloud/connectors/v1/internal/connectors_tracing_connection.h @@ -142,6 +142,21 @@ class ConnectorsTracingConnection : public connectors_v1::ConnectorsConnection { google::cloud::connectors::v1::GetGlobalSettingsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/connectors/v1/internal/connectors_tracing_stub.cc b/google/cloud/connectors/v1/internal/connectors_tracing_stub.cc index d435954a50268..0a7c2665eac0d 100644 --- a/google/cloud/connectors/v1/internal/connectors_tracing_stub.cc +++ b/google/cloud/connectors/v1/internal/connectors_tracing_stub.cc @@ -306,6 +306,63 @@ ConnectorsTracingStub::GetGlobalSettings( context, *span, child_->GetGlobalSettings(context, options, request)); } +StatusOr +ConnectorsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.connectors.v1.Connectors", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr ConnectorsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.connectors.v1.Connectors", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr ConnectorsTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.connectors.v1.Connectors", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr ConnectorsTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.connectors.v1.Connectors", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +ConnectorsTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.connectors.v1.Connectors", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> ConnectorsTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/connectors/v1/internal/connectors_tracing_stub.h b/google/cloud/connectors/v1/internal/connectors_tracing_stub.h index 3fe4e5f36ad27..1bd0db7502dc0 100644 --- a/google/cloud/connectors/v1/internal/connectors_tracing_stub.h +++ b/google/cloud/connectors/v1/internal/connectors_tracing_stub.h @@ -156,6 +156,26 @@ class ConnectorsTracingStub : public ConnectorsStub { google::cloud::connectors::v1::GetGlobalSettingsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/connectors/v1/mocks/mock_connectors_connection.h b/google/cloud/connectors/v1/mocks/mock_connectors_connection.h index 30835760368e0..e2c52b014a6b9 100644 --- a/google/cloud/connectors/v1/mocks/mock_connectors_connection.h +++ b/google/cloud/connectors/v1/mocks/mock_connectors_connection.h @@ -277,6 +277,27 @@ class MockConnectorsConnection : public connectors_v1::ConnectorsConnection { StatusOr, GetGlobalSettings, (google::cloud::connectors::v1::GetGlobalSettingsRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/datacatalog/BUILD.bazel b/google/cloud/datacatalog/BUILD.bazel index a74b7443c852f..2771cd838e327 100644 --- a/google/cloud/datacatalog/BUILD.bazel +++ b/google/cloud/datacatalog/BUILD.bazel @@ -27,6 +27,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/datacatalog/lineage/v1:lineage_cc_grpc", "@com_google_googleapis//google/cloud/datacatalog/v1:datacatalog_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/datacatalog/v1/data_catalog_connection.h b/google/cloud/datacatalog/v1/data_catalog_connection.h index c2c7985e2e8a4..fd748cfdcf5ff 100644 --- a/google/cloud/datacatalog/v1/data_catalog_connection.h +++ b/google/cloud/datacatalog/v1/data_catalog_connection.h @@ -31,6 +31,7 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include #include #include diff --git a/google/cloud/datacatalog/v1/internal/data_catalog_stub.h b/google/cloud/datacatalog/v1/internal/data_catalog_stub.h index 2f0ddd39b22dd..c2247c9747e16 100644 --- a/google/cloud/datacatalog/v1/internal/data_catalog_stub.h +++ b/google/cloud/datacatalog/v1/internal/data_catalog_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_stub.h b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_stub.h index df9adfa4b61fc..bbca3c15988f4 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_stub.h +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_serialization_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include diff --git a/google/cloud/datacatalog/v1/internal/policy_tag_manager_stub.h b/google/cloud/datacatalog/v1/internal/policy_tag_manager_stub.h index db74e8939b987..e445134a4c3e6 100644 --- a/google/cloud/datacatalog/v1/internal/policy_tag_manager_stub.h +++ b/google/cloud/datacatalog/v1/internal/policy_tag_manager_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include diff --git a/google/cloud/datacatalog/v1/policy_tag_manager_connection.h b/google/cloud/datacatalog/v1/policy_tag_manager_connection.h index 532a53b50332e..d329d171c14b5 100644 --- a/google/cloud/datacatalog/v1/policy_tag_manager_connection.h +++ b/google/cloud/datacatalog/v1/policy_tag_manager_connection.h @@ -28,6 +28,7 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include #include namespace google { diff --git a/google/cloud/datacatalog/v1/policy_tag_manager_serialization_connection.h b/google/cloud/datacatalog/v1/policy_tag_manager_serialization_connection.h index 381416bbfe55d..cbcb4c5fa5214 100644 --- a/google/cloud/datacatalog/v1/policy_tag_manager_serialization_connection.h +++ b/google/cloud/datacatalog/v1/policy_tag_manager_serialization_connection.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include namespace google { diff --git a/google/cloud/dataplex/BUILD.bazel b/google/cloud/dataplex/BUILD.bazel index df24c92c4cee0..77150a0c67f9e 100644 --- a/google/cloud/dataplex/BUILD.bazel +++ b/google/cloud/dataplex/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/dataplex/v1:dataplex_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/dataplex/v1/catalog_client.cc b/google/cloud/dataplex/v1/catalog_client.cc index c6995ee936dc8..131834288beba 100644 --- a/google/cloud/dataplex/v1/catalog_client.cc +++ b/google/cloud/dataplex/v1/catalog_client.cc @@ -621,6 +621,38 @@ CatalogServiceClient::SearchEntries( return connection_->SearchEntries(std::move(request)); } +StreamRange +CatalogServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr CatalogServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr CatalogServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr CatalogServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +CatalogServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataplex_v1 } // namespace cloud diff --git a/google/cloud/dataplex/v1/catalog_client.h b/google/cloud/dataplex/v1/catalog_client.h index 79650a6b7e507..b1dda08ef8d10 100644 --- a/google/cloud/dataplex/v1/catalog_client.h +++ b/google/cloud/dataplex/v1/catalog_client.h @@ -1978,6 +1978,178 @@ class CatalogServiceClient { google::cloud::dataplex::v1::SearchEntriesRequest request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dataplex/v1/catalog_connection.cc b/google/cloud/dataplex/v1/catalog_connection.cc index a71e5ddb24fa7..165131fcf7afd 100644 --- a/google/cloud/dataplex/v1/catalog_connection.cc +++ b/google/cloud/dataplex/v1/catalog_connection.cc @@ -332,6 +332,36 @@ CatalogServiceConnection::SearchEntries( StreamRange>(); } +StreamRange +CatalogServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +CatalogServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr CatalogServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr CatalogServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +CatalogServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCatalogServiceConnection( Options options) { internal::CheckExpectedOptions +#include +#include #include #include @@ -323,6 +325,21 @@ class CatalogServiceConnection { virtual StreamRange SearchEntries(google::cloud::dataplex::v1::SearchEntriesRequest request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/dataplex/v1/catalog_connection_idempotency_policy.cc b/google/cloud/dataplex/v1/catalog_connection_idempotency_policy.cc index 99cbb50deb665..dc2d275a8391f 100644 --- a/google/cloud/dataplex/v1/catalog_connection_idempotency_policy.cc +++ b/google/cloud/dataplex/v1/catalog_connection_idempotency_policy.cc @@ -144,6 +144,32 @@ Idempotency CatalogServiceConnectionIdempotencyPolicy::SearchEntries( return Idempotency::kNonIdempotent; } +Idempotency CatalogServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CatalogServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency CatalogServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency CatalogServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency CatalogServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultCatalogServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dataplex/v1/catalog_connection_idempotency_policy.h b/google/cloud/dataplex/v1/catalog_connection_idempotency_policy.h index b65b5105065b9..358bf21945f68 100644 --- a/google/cloud/dataplex/v1/catalog_connection_idempotency_policy.h +++ b/google/cloud/dataplex/v1/catalog_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -102,6 +104,21 @@ class CatalogServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency SearchEntries( google::cloud::dataplex::v1::SearchEntriesRequest request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dataplex/v1/content_client.cc b/google/cloud/dataplex/v1/content_client.cc index 44c2fd5287e2b..a87886dc1e56d 100644 --- a/google/cloud/dataplex/v1/content_client.cc +++ b/google/cloud/dataplex/v1/content_client.cc @@ -142,6 +142,19 @@ ContentServiceClient::ListContent( return connection_->ListContent(std::move(request)); } +StreamRange +ContentServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr ContentServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataplex_v1 } // namespace cloud diff --git a/google/cloud/dataplex/v1/content_client.h b/google/cloud/dataplex/v1/content_client.h index 20613eb6aaeec..69fbe7cd85c0e 100644 --- a/google/cloud/dataplex/v1/content_client.h +++ b/google/cloud/dataplex/v1/content_client.h @@ -526,6 +526,76 @@ class ContentServiceClient { google::cloud::dataplex::v1::ListContentRequest request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dataplex/v1/content_connection.cc b/google/cloud/dataplex/v1/content_connection.cc index 1318e3323f778..77725ea6355d4 100644 --- a/google/cloud/dataplex/v1/content_connection.cc +++ b/google/cloud/dataplex/v1/content_connection.cc @@ -85,6 +85,20 @@ ContentServiceConnection::ListContent( StreamRange>(); } +StreamRange +ContentServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +ContentServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeContentServiceConnection( Options options) { internal::CheckExpectedOptions +#include +#include #include namespace google { @@ -205,6 +207,12 @@ class ContentServiceConnection { virtual StreamRange ListContent( google::cloud::dataplex::v1::ListContentRequest request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dataplex/v1/content_connection_idempotency_policy.cc b/google/cloud/dataplex/v1/content_connection_idempotency_policy.cc index e7b82c234ab2d..670c8ef87fa6d 100644 --- a/google/cloud/dataplex/v1/content_connection_idempotency_policy.cc +++ b/google/cloud/dataplex/v1/content_connection_idempotency_policy.cc @@ -75,6 +75,16 @@ Idempotency ContentServiceConnectionIdempotencyPolicy::ListContent( return Idempotency::kIdempotent; } +Idempotency ContentServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ContentServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultContentServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dataplex/v1/content_connection_idempotency_policy.h b/google/cloud/dataplex/v1/content_connection_idempotency_policy.h index 7bd826dd04c20..260dd49e5eb69 100644 --- a/google/cloud/dataplex/v1/content_connection_idempotency_policy.h +++ b/google/cloud/dataplex/v1/content_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -60,6 +61,12 @@ class ContentServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListContent( google::cloud::dataplex::v1::ListContentRequest request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dataplex/v1/data_scan_client.cc b/google/cloud/dataplex/v1/data_scan_client.cc index 7bb5edea6298d..3c816939bb5ce 100644 --- a/google/cloud/dataplex/v1/data_scan_client.cc +++ b/google/cloud/dataplex/v1/data_scan_client.cc @@ -260,6 +260,38 @@ DataScanServiceClient::GenerateDataQualityRules( return connection_->GenerateDataQualityRules(request); } +StreamRange +DataScanServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr DataScanServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr DataScanServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr DataScanServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +DataScanServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataplex_v1 } // namespace cloud diff --git a/google/cloud/dataplex/v1/data_scan_client.h b/google/cloud/dataplex/v1/data_scan_client.h index 69dcca62293ea..143a69f616d20 100644 --- a/google/cloud/dataplex/v1/data_scan_client.h +++ b/google/cloud/dataplex/v1/data_scan_client.h @@ -853,6 +853,178 @@ class DataScanServiceClient { request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dataplex/v1/data_scan_connection.cc b/google/cloud/dataplex/v1/data_scan_connection.cc index 086714c2bf683..f73d752471c18 100644 --- a/google/cloud/dataplex/v1/data_scan_connection.cc +++ b/google/cloud/dataplex/v1/data_scan_connection.cc @@ -147,6 +147,36 @@ DataScanServiceConnection::GenerateDataQualityRules( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +DataScanServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DataScanServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr DataScanServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr DataScanServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +DataScanServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDataScanServiceConnection( Options options) { internal::CheckExpectedOptions +#include +#include #include #include @@ -241,6 +243,21 @@ class DataScanServiceConnection { GenerateDataQualityRules( google::cloud::dataplex::v1::GenerateDataQualityRulesRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/dataplex/v1/data_scan_connection_idempotency_policy.cc b/google/cloud/dataplex/v1/data_scan_connection_idempotency_policy.cc index 03d8f588cf6f0..c0df8a775727d 100644 --- a/google/cloud/dataplex/v1/data_scan_connection_idempotency_policy.cc +++ b/google/cloud/dataplex/v1/data_scan_connection_idempotency_policy.cc @@ -80,6 +80,32 @@ DataScanServiceConnectionIdempotencyPolicy::GenerateDataQualityRules( return Idempotency::kNonIdempotent; } +Idempotency DataScanServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DataScanServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DataScanServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency DataScanServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DataScanServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultDataScanServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dataplex/v1/data_scan_connection_idempotency_policy.h b/google/cloud/dataplex/v1/data_scan_connection_idempotency_policy.h index 68e28f2aa587a..f8e6dcf50ad72 100644 --- a/google/cloud/dataplex/v1/data_scan_connection_idempotency_policy.h +++ b/google/cloud/dataplex/v1/data_scan_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -64,6 +66,21 @@ class DataScanServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GenerateDataQualityRules( google::cloud::dataplex::v1::GenerateDataQualityRulesRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dataplex/v1/data_taxonomy_client.cc b/google/cloud/dataplex/v1/data_taxonomy_client.cc index fe859b9bebad2..cf0de7a03fe8f 100644 --- a/google/cloud/dataplex/v1/data_taxonomy_client.cc +++ b/google/cloud/dataplex/v1/data_taxonomy_client.cc @@ -563,6 +563,39 @@ DataTaxonomyServiceClient::GetDataAttribute( return connection_->GetDataAttribute(request); } +StreamRange +DataTaxonomyServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +DataTaxonomyServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr DataTaxonomyServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr DataTaxonomyServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +DataTaxonomyServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataplex_v1 } // namespace cloud diff --git a/google/cloud/dataplex/v1/data_taxonomy_client.h b/google/cloud/dataplex/v1/data_taxonomy_client.h index 3f528ff3cabfb..bbcf38ab8a23c 100644 --- a/google/cloud/dataplex/v1/data_taxonomy_client.h +++ b/google/cloud/dataplex/v1/data_taxonomy_client.h @@ -1591,6 +1591,178 @@ class DataTaxonomyServiceClient { google::cloud::dataplex::v1::GetDataAttributeRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dataplex/v1/data_taxonomy_connection.cc b/google/cloud/dataplex/v1/data_taxonomy_connection.cc index 6e904029bf690..8a4db45a37013 100644 --- a/google/cloud/dataplex/v1/data_taxonomy_connection.cc +++ b/google/cloud/dataplex/v1/data_taxonomy_connection.cc @@ -293,6 +293,36 @@ DataTaxonomyServiceConnection::GetDataAttribute( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +DataTaxonomyServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DataTaxonomyServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr DataTaxonomyServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr DataTaxonomyServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +DataTaxonomyServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDataTaxonomyServiceConnection(Options options) { internal::CheckExpectedOptions +#include +#include #include #include @@ -316,6 +318,21 @@ class DataTaxonomyServiceConnection { virtual StatusOr GetDataAttribute( google::cloud::dataplex::v1::GetDataAttributeRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/dataplex/v1/data_taxonomy_connection_idempotency_policy.cc b/google/cloud/dataplex/v1/data_taxonomy_connection_idempotency_policy.cc index a3d489d4b6179..8257a84796c50 100644 --- a/google/cloud/dataplex/v1/data_taxonomy_connection_idempotency_policy.cc +++ b/google/cloud/dataplex/v1/data_taxonomy_connection_idempotency_policy.cc @@ -115,6 +115,32 @@ Idempotency DataTaxonomyServiceConnectionIdempotencyPolicy::GetDataAttribute( return Idempotency::kIdempotent; } +Idempotency DataTaxonomyServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DataTaxonomyServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DataTaxonomyServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency DataTaxonomyServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DataTaxonomyServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultDataTaxonomyServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dataplex/v1/data_taxonomy_connection_idempotency_policy.h b/google/cloud/dataplex/v1/data_taxonomy_connection_idempotency_policy.h index d41553a53a2e6..46ed7edce013e 100644 --- a/google/cloud/dataplex/v1/data_taxonomy_connection_idempotency_policy.h +++ b/google/cloud/dataplex/v1/data_taxonomy_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -85,6 +87,21 @@ class DataTaxonomyServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GetDataAttribute( google::cloud::dataplex::v1::GetDataAttributeRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dataplex/v1/dataplex_client.cc b/google/cloud/dataplex/v1/dataplex_client.cc index 967c4c89aeac6..6e962f0ca694a 100644 --- a/google/cloud/dataplex/v1/dataplex_client.cc +++ b/google/cloud/dataplex/v1/dataplex_client.cc @@ -945,6 +945,38 @@ DataplexServiceClient::ListSessions( return connection_->ListSessions(std::move(request)); } +StreamRange +DataplexServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr DataplexServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr DataplexServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr DataplexServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +DataplexServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataplex_v1 } // namespace cloud diff --git a/google/cloud/dataplex/v1/dataplex_client.h b/google/cloud/dataplex/v1/dataplex_client.h index c0e1789de9625..4055e08921400 100644 --- a/google/cloud/dataplex/v1/dataplex_client.h +++ b/google/cloud/dataplex/v1/dataplex_client.h @@ -3057,6 +3057,178 @@ class DataplexServiceClient { google::cloud::dataplex::v1::ListSessionsRequest request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dataplex/v1/dataplex_connection.cc b/google/cloud/dataplex/v1/dataplex_connection.cc index f443fa3b4d523..3004f0e4e2b31 100644 --- a/google/cloud/dataplex/v1/dataplex_connection.cc +++ b/google/cloud/dataplex/v1/dataplex_connection.cc @@ -482,6 +482,36 @@ DataplexServiceConnection::ListSessions( StreamRange>(); } +StreamRange +DataplexServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DataplexServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr DataplexServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr DataplexServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +DataplexServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDataplexServiceConnection( Options options) { internal::CheckExpectedOptions +#include +#include #include #include @@ -394,6 +396,21 @@ class DataplexServiceConnection { virtual StreamRange ListSessions( google::cloud::dataplex::v1::ListSessionsRequest request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/dataplex/v1/dataplex_connection_idempotency_policy.cc b/google/cloud/dataplex/v1/dataplex_connection_idempotency_policy.cc index 213b1630c5a23..a41f7e9a1e0d5 100644 --- a/google/cloud/dataplex/v1/dataplex_connection_idempotency_policy.cc +++ b/google/cloud/dataplex/v1/dataplex_connection_idempotency_policy.cc @@ -199,6 +199,32 @@ Idempotency DataplexServiceConnectionIdempotencyPolicy::ListSessions( return Idempotency::kIdempotent; } +Idempotency DataplexServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DataplexServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DataplexServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency DataplexServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DataplexServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultDataplexServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dataplex/v1/dataplex_connection_idempotency_policy.h b/google/cloud/dataplex/v1/dataplex_connection_idempotency_policy.h index 4a1b4b8b369fd..868faf9b1bffb 100644 --- a/google/cloud/dataplex/v1/dataplex_connection_idempotency_policy.h +++ b/google/cloud/dataplex/v1/dataplex_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -135,6 +137,21 @@ class DataplexServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListSessions( google::cloud::dataplex::v1::ListSessionsRequest request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dataplex/v1/internal/catalog_auth_decorator.cc b/google/cloud/dataplex/v1/internal/catalog_auth_decorator.cc index 20b0e27150e74..edb82a08a63cf 100644 --- a/google/cloud/dataplex/v1/internal/catalog_auth_decorator.cc +++ b/google/cloud/dataplex/v1/internal/catalog_auth_decorator.cc @@ -395,6 +395,48 @@ CatalogServiceAuth::SearchEntries( return child_->SearchEntries(context, options, request); } +StatusOr +CatalogServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr CatalogServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr CatalogServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr CatalogServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +CatalogServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> CatalogServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataplex/v1/internal/catalog_auth_decorator.h b/google/cloud/dataplex/v1/internal/catalog_auth_decorator.h index 0c885d14ab35c..e63623f116f0e 100644 --- a/google/cloud/dataplex/v1/internal/catalog_auth_decorator.h +++ b/google/cloud/dataplex/v1/internal/catalog_auth_decorator.h @@ -205,6 +205,26 @@ class CatalogServiceAuth : public CatalogServiceStub { google::cloud::dataplex::v1::SearchEntriesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataplex/v1/internal/catalog_connection_impl.cc b/google/cloud/dataplex/v1/internal/catalog_connection_impl.cc index 04e06394124cc..de385bfa71e02 100644 --- a/google/cloud/dataplex/v1/internal/catalog_connection_impl.cc +++ b/google/cloud/dataplex/v1/internal/catalog_connection_impl.cc @@ -1168,6 +1168,94 @@ CatalogServiceConnectionImpl::SearchEntries( }); } +StreamRange +CatalogServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +CatalogServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr CatalogServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr CatalogServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +CatalogServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataplex_v1_internal } // namespace cloud diff --git a/google/cloud/dataplex/v1/internal/catalog_connection_impl.h b/google/cloud/dataplex/v1/internal/catalog_connection_impl.h index 9c52563019d8e..f466fefcc1e93 100644 --- a/google/cloud/dataplex/v1/internal/catalog_connection_impl.h +++ b/google/cloud/dataplex/v1/internal/catalog_connection_impl.h @@ -201,6 +201,21 @@ class CatalogServiceConnectionImpl StreamRange SearchEntries( google::cloud::dataplex::v1::SearchEntriesRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dataplex/v1/internal/catalog_logging_decorator.cc b/google/cloud/dataplex/v1/internal/catalog_logging_decorator.cc index 7657b10b6b4cd..c31d34f2ef8ec 100644 --- a/google/cloud/dataplex/v1/internal/catalog_logging_decorator.cc +++ b/google/cloud/dataplex/v1/internal/catalog_logging_decorator.cc @@ -474,6 +474,63 @@ CatalogServiceLogging::SearchEntries( context, options, request, __func__, tracing_options_); } +StatusOr +CatalogServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr CatalogServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr CatalogServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr CatalogServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +CatalogServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> CatalogServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataplex/v1/internal/catalog_logging_decorator.h b/google/cloud/dataplex/v1/internal/catalog_logging_decorator.h index 490949b0ce812..c045dce606477 100644 --- a/google/cloud/dataplex/v1/internal/catalog_logging_decorator.h +++ b/google/cloud/dataplex/v1/internal/catalog_logging_decorator.h @@ -205,6 +205,26 @@ class CatalogServiceLogging : public CatalogServiceStub { google::cloud::dataplex::v1::SearchEntriesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataplex/v1/internal/catalog_metadata_decorator.cc b/google/cloud/dataplex/v1/internal/catalog_metadata_decorator.cc index c9bf30bf95b3d..6d070fc2b7d98 100644 --- a/google/cloud/dataplex/v1/internal/catalog_metadata_decorator.cc +++ b/google/cloud/dataplex/v1/internal/catalog_metadata_decorator.cc @@ -356,6 +356,51 @@ CatalogServiceMetadata::SearchEntries( return child_->SearchEntries(context, options, request); } +StatusOr +CatalogServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr CatalogServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr CatalogServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr CatalogServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +CatalogServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> CatalogServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataplex/v1/internal/catalog_metadata_decorator.h b/google/cloud/dataplex/v1/internal/catalog_metadata_decorator.h index 8ab6612b68198..402dd12991ada 100644 --- a/google/cloud/dataplex/v1/internal/catalog_metadata_decorator.h +++ b/google/cloud/dataplex/v1/internal/catalog_metadata_decorator.h @@ -205,6 +205,26 @@ class CatalogServiceMetadata : public CatalogServiceStub { google::cloud::dataplex::v1::SearchEntriesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataplex/v1/internal/catalog_stub.cc b/google/cloud/dataplex/v1/internal/catalog_stub.cc index 927194c86f58f..686b2659c0db5 100644 --- a/google/cloud/dataplex/v1/internal/catalog_stub.cc +++ b/google/cloud/dataplex/v1/internal/catalog_stub.cc @@ -463,6 +463,65 @@ DefaultCatalogServiceStub::SearchEntries( return response; } +StatusOr +DefaultCatalogServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultCatalogServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultCatalogServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultCatalogServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultCatalogServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultCatalogServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataplex/v1/internal/catalog_stub.h b/google/cloud/dataplex/v1/internal/catalog_stub.h index 8b3b236b57ebc..3c1a406acaeac 100644 --- a/google/cloud/dataplex/v1/internal/catalog_stub.h +++ b/google/cloud/dataplex/v1/internal/catalog_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -191,6 +195,28 @@ class CatalogServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::dataplex::v1::SearchEntriesRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -210,9 +236,15 @@ class DefaultCatalogServiceStub : public CatalogServiceStub { std::unique_ptr< google::cloud::dataplex::v1::CatalogService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateEntryType( google::cloud::CompletionQueue& cq, @@ -380,6 +412,26 @@ class DefaultCatalogServiceStub : public CatalogServiceStub { google::cloud::dataplex::v1::SearchEntriesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -395,6 +447,9 @@ class DefaultCatalogServiceStub : public CatalogServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/dataplex/v1/internal/catalog_stub_factory.cc b/google/cloud/dataplex/v1/internal/catalog_stub_factory.cc index 754d18cc663c8..a2abdc42dba4f 100644 --- a/google/cloud/dataplex/v1/internal/catalog_stub_factory.cc +++ b/google/cloud/dataplex/v1/internal/catalog_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultCatalogServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataplex::v1::CatalogService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/dataplex/v1/internal/catalog_tracing_connection.cc b/google/cloud/dataplex/v1/internal/catalog_tracing_connection.cc index f267d29c46a33..1136dc16684cf 100644 --- a/google/cloud/dataplex/v1/internal/catalog_tracing_connection.cc +++ b/google/cloud/dataplex/v1/internal/catalog_tracing_connection.cc @@ -428,6 +428,51 @@ CatalogServiceTracingConnection::SearchEntries( std::move(sr)); } +StreamRange +CatalogServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "dataplex_v1::CatalogServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CatalogServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dataplex_v1::CatalogServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr CatalogServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("dataplex_v1::CatalogServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr CatalogServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("dataplex_v1::CatalogServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +CatalogServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::CatalogServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dataplex/v1/internal/catalog_tracing_connection.h b/google/cloud/dataplex/v1/internal/catalog_tracing_connection.h index 0c168e66b4e66..6414b75c91190 100644 --- a/google/cloud/dataplex/v1/internal/catalog_tracing_connection.h +++ b/google/cloud/dataplex/v1/internal/catalog_tracing_connection.h @@ -189,6 +189,21 @@ class CatalogServiceTracingConnection StreamRange SearchEntries( google::cloud::dataplex::v1::SearchEntriesRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dataplex/v1/internal/catalog_tracing_stub.cc b/google/cloud/dataplex/v1/internal/catalog_tracing_stub.cc index 4358afbbd1f9f..2cc25df60885e 100644 --- a/google/cloud/dataplex/v1/internal/catalog_tracing_stub.cc +++ b/google/cloud/dataplex/v1/internal/catalog_tracing_stub.cc @@ -431,6 +431,64 @@ CatalogServiceTracingStub::SearchEntries( child_->SearchEntries(context, options, request)); } +StatusOr +CatalogServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.CatalogService", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +CatalogServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.CatalogService", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr CatalogServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.CatalogService", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr CatalogServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.CatalogService", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +CatalogServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.CatalogService", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> CatalogServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataplex/v1/internal/catalog_tracing_stub.h b/google/cloud/dataplex/v1/internal/catalog_tracing_stub.h index e8c14979af282..b758224e5787e 100644 --- a/google/cloud/dataplex/v1/internal/catalog_tracing_stub.h +++ b/google/cloud/dataplex/v1/internal/catalog_tracing_stub.h @@ -204,6 +204,26 @@ class CatalogServiceTracingStub : public CatalogServiceStub { google::cloud::dataplex::v1::SearchEntriesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataplex/v1/internal/content_auth_decorator.cc b/google/cloud/dataplex/v1/internal/content_auth_decorator.cc index 64572685eafc5..f374f9b0516ff 100644 --- a/google/cloud/dataplex/v1/internal/content_auth_decorator.cc +++ b/google/cloud/dataplex/v1/internal/content_auth_decorator.cc @@ -99,6 +99,23 @@ ContentServiceAuth::ListContent( return child_->ListContent(context, options, request); } +StatusOr +ContentServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr ContentServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataplex_v1_internal } // namespace cloud diff --git a/google/cloud/dataplex/v1/internal/content_auth_decorator.h b/google/cloud/dataplex/v1/internal/content_auth_decorator.h index 0443dda6f0eb2..846b8b063924f 100644 --- a/google/cloud/dataplex/v1/internal/content_auth_decorator.h +++ b/google/cloud/dataplex/v1/internal/content_auth_decorator.h @@ -72,6 +72,14 @@ class ContentServiceAuth : public ContentServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::dataplex::v1::ListContentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/dataplex/v1/internal/content_connection_impl.cc b/google/cloud/dataplex/v1/internal/content_connection_impl.cc index b802329454ef1..03aed4725fa5c 100644 --- a/google/cloud/dataplex/v1/internal/content_connection_impl.cc +++ b/google/cloud/dataplex/v1/internal/content_connection_impl.cc @@ -188,6 +188,54 @@ ContentServiceConnectionImpl::ListContent( }); } +StreamRange +ContentServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ContentServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataplex_v1_internal } // namespace cloud diff --git a/google/cloud/dataplex/v1/internal/content_connection_impl.h b/google/cloud/dataplex/v1/internal/content_connection_impl.h index 9a65c98e03df4..7e4df3f1eac0d 100644 --- a/google/cloud/dataplex/v1/internal/content_connection_impl.h +++ b/google/cloud/dataplex/v1/internal/content_connection_impl.h @@ -75,6 +75,12 @@ class ContentServiceConnectionImpl StreamRange ListContent( google::cloud::dataplex::v1::ListContentRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dataplex/v1/internal/content_logging_decorator.cc b/google/cloud/dataplex/v1/internal/content_logging_decorator.cc index 6a58cca47ff3b..070301d7129e3 100644 --- a/google/cloud/dataplex/v1/internal/content_logging_decorator.cc +++ b/google/cloud/dataplex/v1/internal/content_logging_decorator.cc @@ -128,6 +128,29 @@ ContentServiceLogging::ListContent( context, options, request, __func__, tracing_options_); } +StatusOr +ContentServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ContentServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataplex_v1_internal } // namespace cloud diff --git a/google/cloud/dataplex/v1/internal/content_logging_decorator.h b/google/cloud/dataplex/v1/internal/content_logging_decorator.h index 7f094a93f2946..9f2395d4f66ed 100644 --- a/google/cloud/dataplex/v1/internal/content_logging_decorator.h +++ b/google/cloud/dataplex/v1/internal/content_logging_decorator.h @@ -72,6 +72,14 @@ class ContentServiceLogging : public ContentServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::dataplex::v1::ListContentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/dataplex/v1/internal/content_metadata_decorator.cc b/google/cloud/dataplex/v1/internal/content_metadata_decorator.cc index bb03a818f418d..d8176ebf949f4 100644 --- a/google/cloud/dataplex/v1/internal/content_metadata_decorator.cc +++ b/google/cloud/dataplex/v1/internal/content_metadata_decorator.cc @@ -117,6 +117,23 @@ ContentServiceMetadata::ListContent( return child_->ListContent(context, options, request); } +StatusOr +ContentServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr ContentServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void ContentServiceMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/dataplex/v1/internal/content_metadata_decorator.h b/google/cloud/dataplex/v1/internal/content_metadata_decorator.h index 97b2b0403c127..82b70a5a0be56 100644 --- a/google/cloud/dataplex/v1/internal/content_metadata_decorator.h +++ b/google/cloud/dataplex/v1/internal/content_metadata_decorator.h @@ -72,6 +72,14 @@ class ContentServiceMetadata : public ContentServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::dataplex::v1::ListContentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/dataplex/v1/internal/content_stub.cc b/google/cloud/dataplex/v1/internal/content_stub.cc index 55ff3ee7eea6e..b4dee82acda64 100644 --- a/google/cloud/dataplex/v1/internal/content_stub.cc +++ b/google/cloud/dataplex/v1/internal/content_stub.cc @@ -123,6 +123,30 @@ DefaultContentServiceStub::ListContent( return response; } +StatusOr +DefaultContentServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultContentServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataplex_v1_internal } // namespace cloud diff --git a/google/cloud/dataplex/v1/internal/content_stub.h b/google/cloud/dataplex/v1/internal/content_stub.h index 123951e14f16c..bc7a07e579d9c 100644 --- a/google/cloud/dataplex/v1/internal/content_stub.h +++ b/google/cloud/dataplex/v1/internal/content_stub.h @@ -23,6 +23,9 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include #include #include @@ -68,6 +71,15 @@ class ContentServiceStub { ListContent( grpc::ClientContext& context, Options const& options, google::cloud::dataplex::v1::ListContentRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultContentServiceStub : public ContentServiceStub { @@ -75,8 +87,11 @@ class DefaultContentServiceStub : public ContentServiceStub { explicit DefaultContentServiceStub( std::unique_ptr< google::cloud::dataplex::v1::ContentService::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr CreateContent( grpc::ClientContext& context, Options const& options, @@ -112,9 +127,19 @@ class DefaultContentServiceStub : public ContentServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::dataplex::v1::ListContentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dataplex/v1/internal/content_stub_factory.cc b/google/cloud/dataplex/v1/internal/content_stub_factory.cc index 7c3b179c6589a..0c61d19a8ea59 100644 --- a/google/cloud/dataplex/v1/internal/content_stub_factory.cc +++ b/google/cloud/dataplex/v1/internal/content_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,8 +45,11 @@ std::shared_ptr CreateDefaultContentServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataplex::v1::ContentService::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + std::make_shared( + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = diff --git a/google/cloud/dataplex/v1/internal/content_tracing_connection.cc b/google/cloud/dataplex/v1/internal/content_tracing_connection.cc index 66f7fa0a32246..f71f3f629895d 100644 --- a/google/cloud/dataplex/v1/internal/content_tracing_connection.cc +++ b/google/cloud/dataplex/v1/internal/content_tracing_connection.cc @@ -104,6 +104,26 @@ ContentServiceTracingConnection::ListContent( std::move(span), std::move(sr)); } +StreamRange +ContentServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "dataplex_v1::ContentServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ContentServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dataplex_v1::ContentServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dataplex/v1/internal/content_tracing_connection.h b/google/cloud/dataplex/v1/internal/content_tracing_connection.h index 852634dc75f37..af304dc9a04cb 100644 --- a/google/cloud/dataplex/v1/internal/content_tracing_connection.h +++ b/google/cloud/dataplex/v1/internal/content_tracing_connection.h @@ -66,6 +66,12 @@ class ContentServiceTracingConnection StreamRange ListContent( google::cloud::dataplex::v1::ListContentRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dataplex/v1/internal/content_tracing_stub.cc b/google/cloud/dataplex/v1/internal/content_tracing_stub.cc index a0828ada17d65..db4ded27d0ee9 100644 --- a/google/cloud/dataplex/v1/internal/content_tracing_stub.cc +++ b/google/cloud/dataplex/v1/internal/content_tracing_stub.cc @@ -125,6 +125,30 @@ ContentServiceTracingStub::ListContent( child_->ListContent(context, options, request)); } +StatusOr +ContentServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.ContentService", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +ContentServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.ContentService", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeContentServiceTracingStub( diff --git a/google/cloud/dataplex/v1/internal/content_tracing_stub.h b/google/cloud/dataplex/v1/internal/content_tracing_stub.h index 94bdb0f46d68c..10b2c284323c0 100644 --- a/google/cloud/dataplex/v1/internal/content_tracing_stub.h +++ b/google/cloud/dataplex/v1/internal/content_tracing_stub.h @@ -72,6 +72,14 @@ class ContentServiceTracingStub : public ContentServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::dataplex::v1::ListContentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/dataplex/v1/internal/data_scan_auth_decorator.cc b/google/cloud/dataplex/v1/internal/data_scan_auth_decorator.cc index f4215d7d3e6df..99bfd04e7d5f2 100644 --- a/google/cloud/dataplex/v1/internal/data_scan_auth_decorator.cc +++ b/google/cloud/dataplex/v1/internal/data_scan_auth_decorator.cc @@ -170,6 +170,48 @@ DataScanServiceAuth::GenerateDataQualityRules( return child_->GenerateDataQualityRules(context, options, request); } +StatusOr +DataScanServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr DataScanServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr DataScanServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr DataScanServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +DataScanServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> DataScanServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataplex/v1/internal/data_scan_auth_decorator.h b/google/cloud/dataplex/v1/internal/data_scan_auth_decorator.h index fd1d274de3665..102e8c7cf5e37 100644 --- a/google/cloud/dataplex/v1/internal/data_scan_auth_decorator.h +++ b/google/cloud/dataplex/v1/internal/data_scan_auth_decorator.h @@ -104,6 +104,26 @@ class DataScanServiceAuth : public DataScanServiceStub { google::cloud::dataplex::v1::GenerateDataQualityRulesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataplex/v1/internal/data_scan_connection_impl.cc b/google/cloud/dataplex/v1/internal/data_scan_connection_impl.cc index f39cd83b218e0..5440e0fd779d7 100644 --- a/google/cloud/dataplex/v1/internal/data_scan_connection_impl.cc +++ b/google/cloud/dataplex/v1/internal/data_scan_connection_impl.cc @@ -467,6 +467,94 @@ DataScanServiceConnectionImpl::GenerateDataQualityRules( *current, request, __func__); } +StreamRange +DataScanServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DataScanServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr DataScanServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr DataScanServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +DataScanServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataplex_v1_internal } // namespace cloud diff --git a/google/cloud/dataplex/v1/internal/data_scan_connection_impl.h b/google/cloud/dataplex/v1/internal/data_scan_connection_impl.h index 7a34ef996a8b1..434058bb2e4b0 100644 --- a/google/cloud/dataplex/v1/internal/data_scan_connection_impl.h +++ b/google/cloud/dataplex/v1/internal/data_scan_connection_impl.h @@ -109,6 +109,21 @@ class DataScanServiceConnectionImpl google::cloud::dataplex::v1::GenerateDataQualityRulesRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dataplex/v1/internal/data_scan_logging_decorator.cc b/google/cloud/dataplex/v1/internal/data_scan_logging_decorator.cc index d4b52153d73f0..0aeef69da1ac4 100644 --- a/google/cloud/dataplex/v1/internal/data_scan_logging_decorator.cc +++ b/google/cloud/dataplex/v1/internal/data_scan_logging_decorator.cc @@ -204,6 +204,63 @@ DataScanServiceLogging::GenerateDataQualityRules( context, options, request, __func__, tracing_options_); } +StatusOr +DataScanServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DataScanServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DataScanServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DataScanServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataScanServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> DataScanServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataplex/v1/internal/data_scan_logging_decorator.h b/google/cloud/dataplex/v1/internal/data_scan_logging_decorator.h index 61b775b1268e9..e8a96f996de2d 100644 --- a/google/cloud/dataplex/v1/internal/data_scan_logging_decorator.h +++ b/google/cloud/dataplex/v1/internal/data_scan_logging_decorator.h @@ -104,6 +104,26 @@ class DataScanServiceLogging : public DataScanServiceStub { google::cloud::dataplex::v1::GenerateDataQualityRulesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataplex/v1/internal/data_scan_metadata_decorator.cc b/google/cloud/dataplex/v1/internal/data_scan_metadata_decorator.cc index 157ee8cfdd192..b6df8acd75367 100644 --- a/google/cloud/dataplex/v1/internal/data_scan_metadata_decorator.cc +++ b/google/cloud/dataplex/v1/internal/data_scan_metadata_decorator.cc @@ -164,6 +164,52 @@ DataScanServiceMetadata::GenerateDataQualityRules( return child_->GenerateDataQualityRules(context, options, request); } +StatusOr +DataScanServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +DataScanServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr DataScanServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr DataScanServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +DataScanServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> DataScanServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataplex/v1/internal/data_scan_metadata_decorator.h b/google/cloud/dataplex/v1/internal/data_scan_metadata_decorator.h index ee27e6dd50882..6a5b57e78cd7e 100644 --- a/google/cloud/dataplex/v1/internal/data_scan_metadata_decorator.h +++ b/google/cloud/dataplex/v1/internal/data_scan_metadata_decorator.h @@ -105,6 +105,26 @@ class DataScanServiceMetadata : public DataScanServiceStub { google::cloud::dataplex::v1::GenerateDataQualityRulesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataplex/v1/internal/data_scan_stub.cc b/google/cloud/dataplex/v1/internal/data_scan_stub.cc index fd08e8d1abf45..068e1a124507c 100644 --- a/google/cloud/dataplex/v1/internal/data_scan_stub.cc +++ b/google/cloud/dataplex/v1/internal/data_scan_stub.cc @@ -195,6 +195,65 @@ DefaultDataScanServiceStub::GenerateDataQualityRules( return response; } +StatusOr +DefaultDataScanServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataScanServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultDataScanServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultDataScanServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataScanServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultDataScanServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataplex/v1/internal/data_scan_stub.h b/google/cloud/dataplex/v1/internal/data_scan_stub.h index 1dab416f0c2ac..5bbfc2d46f86f 100644 --- a/google/cloud/dataplex/v1/internal/data_scan_stub.h +++ b/google/cloud/dataplex/v1/internal/data_scan_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -98,6 +102,28 @@ class DataScanServiceStub { google::cloud::dataplex::v1::GenerateDataQualityRulesRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -117,9 +143,15 @@ class DefaultDataScanServiceStub : public DataScanServiceStub { std::unique_ptr< google::cloud::dataplex::v1::DataScanService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateDataScan( google::cloud::CompletionQueue& cq, @@ -186,6 +218,26 @@ class DefaultDataScanServiceStub : public DataScanServiceStub { google::cloud::dataplex::v1::GenerateDataQualityRulesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -201,6 +253,9 @@ class DefaultDataScanServiceStub : public DataScanServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/dataplex/v1/internal/data_scan_stub_factory.cc b/google/cloud/dataplex/v1/internal/data_scan_stub_factory.cc index 9c8cabb427f96..a4026544b1b43 100644 --- a/google/cloud/dataplex/v1/internal/data_scan_stub_factory.cc +++ b/google/cloud/dataplex/v1/internal/data_scan_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultDataScanServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataplex::v1::DataScanService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/dataplex/v1/internal/data_scan_tracing_connection.cc b/google/cloud/dataplex/v1/internal/data_scan_tracing_connection.cc index e18bb111b91e0..7c00a2b953f3a 100644 --- a/google/cloud/dataplex/v1/internal/data_scan_tracing_connection.cc +++ b/google/cloud/dataplex/v1/internal/data_scan_tracing_connection.cc @@ -179,6 +179,53 @@ DataScanServiceTracingConnection::GenerateDataQualityRules( return internal::EndSpan(*span, child_->GenerateDataQualityRules(request)); } +StreamRange +DataScanServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "dataplex_v1::DataScanServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DataScanServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dataplex_v1::DataScanServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +DataScanServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::DataScanServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +DataScanServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::DataScanServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +DataScanServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::DataScanServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dataplex/v1/internal/data_scan_tracing_connection.h b/google/cloud/dataplex/v1/internal/data_scan_tracing_connection.h index 2be174db8ba84..5e78c8504ad2b 100644 --- a/google/cloud/dataplex/v1/internal/data_scan_tracing_connection.h +++ b/google/cloud/dataplex/v1/internal/data_scan_tracing_connection.h @@ -97,6 +97,21 @@ class DataScanServiceTracingConnection google::cloud::dataplex::v1::GenerateDataQualityRulesRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dataplex/v1/internal/data_scan_tracing_stub.cc b/google/cloud/dataplex/v1/internal/data_scan_tracing_stub.cc index 93c27dc3e6f39..e8a7eb0170ecd 100644 --- a/google/cloud/dataplex/v1/internal/data_scan_tracing_stub.cc +++ b/google/cloud/dataplex/v1/internal/data_scan_tracing_stub.cc @@ -187,6 +187,64 @@ DataScanServiceTracingStub::GenerateDataQualityRules( child_->GenerateDataQualityRules(context, options, request)); } +StatusOr +DataScanServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.DataScanService", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +DataScanServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.DataScanService", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr DataScanServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.DataScanService", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr DataScanServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.DataScanService", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +DataScanServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.DataScanService", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> DataScanServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataplex/v1/internal/data_scan_tracing_stub.h b/google/cloud/dataplex/v1/internal/data_scan_tracing_stub.h index 6f94b97445591..923f0d60427cb 100644 --- a/google/cloud/dataplex/v1/internal/data_scan_tracing_stub.h +++ b/google/cloud/dataplex/v1/internal/data_scan_tracing_stub.h @@ -104,6 +104,26 @@ class DataScanServiceTracingStub : public DataScanServiceStub { google::cloud::dataplex::v1::GenerateDataQualityRulesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataplex/v1/internal/data_taxonomy_auth_decorator.cc b/google/cloud/dataplex/v1/internal/data_taxonomy_auth_decorator.cc index 1b0cfb69c7071..df2251ca752b9 100644 --- a/google/cloud/dataplex/v1/internal/data_taxonomy_auth_decorator.cc +++ b/google/cloud/dataplex/v1/internal/data_taxonomy_auth_decorator.cc @@ -354,6 +354,49 @@ DataTaxonomyServiceAuth::GetDataAttribute( return child_->GetDataAttribute(context, options, request); } +StatusOr +DataTaxonomyServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +DataTaxonomyServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr DataTaxonomyServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr DataTaxonomyServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +DataTaxonomyServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> DataTaxonomyServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataplex/v1/internal/data_taxonomy_auth_decorator.h b/google/cloud/dataplex/v1/internal/data_taxonomy_auth_decorator.h index a197da26016d5..b5d98f3977b96 100644 --- a/google/cloud/dataplex/v1/internal/data_taxonomy_auth_decorator.h +++ b/google/cloud/dataplex/v1/internal/data_taxonomy_auth_decorator.h @@ -184,6 +184,26 @@ class DataTaxonomyServiceAuth : public DataTaxonomyServiceStub { google::cloud::dataplex::v1::GetDataAttributeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataplex/v1/internal/data_taxonomy_connection_impl.cc b/google/cloud/dataplex/v1/internal/data_taxonomy_connection_impl.cc index 97ea7a5a368a9..c7208d3b67d95 100644 --- a/google/cloud/dataplex/v1/internal/data_taxonomy_connection_impl.cc +++ b/google/cloud/dataplex/v1/internal/data_taxonomy_connection_impl.cc @@ -1063,6 +1063,96 @@ DataTaxonomyServiceConnectionImpl::GetDataAttribute( *current, request, __func__); } +StreamRange +DataTaxonomyServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DataTaxonomyServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +DataTaxonomyServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +DataTaxonomyServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +DataTaxonomyServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataplex_v1_internal } // namespace cloud diff --git a/google/cloud/dataplex/v1/internal/data_taxonomy_connection_impl.h b/google/cloud/dataplex/v1/internal/data_taxonomy_connection_impl.h index e991c4cd2d1bd..dc73f24aeb20e 100644 --- a/google/cloud/dataplex/v1/internal/data_taxonomy_connection_impl.h +++ b/google/cloud/dataplex/v1/internal/data_taxonomy_connection_impl.h @@ -196,6 +196,21 @@ class DataTaxonomyServiceConnectionImpl google::cloud::dataplex::v1::GetDataAttributeRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dataplex/v1/internal/data_taxonomy_logging_decorator.cc b/google/cloud/dataplex/v1/internal/data_taxonomy_logging_decorator.cc index 338886713cdfa..ab786199ba7c4 100644 --- a/google/cloud/dataplex/v1/internal/data_taxonomy_logging_decorator.cc +++ b/google/cloud/dataplex/v1/internal/data_taxonomy_logging_decorator.cc @@ -416,6 +416,64 @@ DataTaxonomyServiceLogging::GetDataAttribute( context, options, request, __func__, tracing_options_); } +StatusOr +DataTaxonomyServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataTaxonomyServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DataTaxonomyServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DataTaxonomyServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataTaxonomyServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> DataTaxonomyServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataplex/v1/internal/data_taxonomy_logging_decorator.h b/google/cloud/dataplex/v1/internal/data_taxonomy_logging_decorator.h index 03713e1b8134f..ec460714f1f15 100644 --- a/google/cloud/dataplex/v1/internal/data_taxonomy_logging_decorator.h +++ b/google/cloud/dataplex/v1/internal/data_taxonomy_logging_decorator.h @@ -184,6 +184,26 @@ class DataTaxonomyServiceLogging : public DataTaxonomyServiceStub { google::cloud::dataplex::v1::GetDataAttributeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataplex/v1/internal/data_taxonomy_metadata_decorator.cc b/google/cloud/dataplex/v1/internal/data_taxonomy_metadata_decorator.cc index 075477a6c795d..1518ba7fd7095 100644 --- a/google/cloud/dataplex/v1/internal/data_taxonomy_metadata_decorator.cc +++ b/google/cloud/dataplex/v1/internal/data_taxonomy_metadata_decorator.cc @@ -307,6 +307,52 @@ DataTaxonomyServiceMetadata::GetDataAttribute( return child_->GetDataAttribute(context, options, request); } +StatusOr +DataTaxonomyServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +DataTaxonomyServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr DataTaxonomyServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr DataTaxonomyServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +DataTaxonomyServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> DataTaxonomyServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataplex/v1/internal/data_taxonomy_metadata_decorator.h b/google/cloud/dataplex/v1/internal/data_taxonomy_metadata_decorator.h index 64ff732282a61..96913db6bf87c 100644 --- a/google/cloud/dataplex/v1/internal/data_taxonomy_metadata_decorator.h +++ b/google/cloud/dataplex/v1/internal/data_taxonomy_metadata_decorator.h @@ -185,6 +185,26 @@ class DataTaxonomyServiceMetadata : public DataTaxonomyServiceStub { google::cloud::dataplex::v1::GetDataAttributeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataplex/v1/internal/data_taxonomy_stub.cc b/google/cloud/dataplex/v1/internal/data_taxonomy_stub.cc index c72175f6bea5c..cf4902621202b 100644 --- a/google/cloud/dataplex/v1/internal/data_taxonomy_stub.cc +++ b/google/cloud/dataplex/v1/internal/data_taxonomy_stub.cc @@ -401,6 +401,65 @@ DefaultDataTaxonomyServiceStub::GetDataAttribute( return response; } +StatusOr +DefaultDataTaxonomyServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataTaxonomyServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultDataTaxonomyServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultDataTaxonomyServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataTaxonomyServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultDataTaxonomyServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataplex/v1/internal/data_taxonomy_stub.h b/google/cloud/dataplex/v1/internal/data_taxonomy_stub.h index a094adb0d799e..2e9c6d3204aa0 100644 --- a/google/cloud/dataplex/v1/internal/data_taxonomy_stub.h +++ b/google/cloud/dataplex/v1/internal/data_taxonomy_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -188,6 +192,28 @@ class DataTaxonomyServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::dataplex::v1::GetDataAttributeRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -207,9 +233,15 @@ class DefaultDataTaxonomyServiceStub : public DataTaxonomyServiceStub { std::unique_ptr< google::cloud::dataplex::v1::DataTaxonomyService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateDataTaxonomy( google::cloud::CompletionQueue& cq, @@ -356,6 +388,26 @@ class DefaultDataTaxonomyServiceStub : public DataTaxonomyServiceStub { google::cloud::dataplex::v1::GetDataAttributeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -372,6 +424,9 @@ class DefaultDataTaxonomyServiceStub : public DataTaxonomyServiceStub { std::unique_ptr< google::cloud::dataplex::v1::DataTaxonomyService::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/dataplex/v1/internal/data_taxonomy_stub_factory.cc b/google/cloud/dataplex/v1/internal/data_taxonomy_stub_factory.cc index 67382b7d63736..e631dc6cda29d 100644 --- a/google/cloud/dataplex/v1/internal/data_taxonomy_stub_factory.cc +++ b/google/cloud/dataplex/v1/internal/data_taxonomy_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultDataTaxonomyServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataplex::v1::DataTaxonomyService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/dataplex/v1/internal/data_taxonomy_tracing_connection.cc b/google/cloud/dataplex/v1/internal/data_taxonomy_tracing_connection.cc index 46cb3675b2f90..01f5b11b5f216 100644 --- a/google/cloud/dataplex/v1/internal/data_taxonomy_tracing_connection.cc +++ b/google/cloud/dataplex/v1/internal/data_taxonomy_tracing_connection.cc @@ -382,6 +382,53 @@ DataTaxonomyServiceTracingConnection::GetDataAttribute( return internal::EndSpan(*span, child_->GetDataAttribute(request)); } +StreamRange +DataTaxonomyServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "dataplex_v1::DataTaxonomyServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DataTaxonomyServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::DataTaxonomyServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +DataTaxonomyServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::DataTaxonomyServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +DataTaxonomyServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::DataTaxonomyServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +DataTaxonomyServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::DataTaxonomyServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dataplex/v1/internal/data_taxonomy_tracing_connection.h b/google/cloud/dataplex/v1/internal/data_taxonomy_tracing_connection.h index f54970d153d99..63399b5bc5287 100644 --- a/google/cloud/dataplex/v1/internal/data_taxonomy_tracing_connection.h +++ b/google/cloud/dataplex/v1/internal/data_taxonomy_tracing_connection.h @@ -184,6 +184,21 @@ class DataTaxonomyServiceTracingConnection google::cloud::dataplex::v1::GetDataAttributeRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dataplex/v1/internal/data_taxonomy_tracing_stub.cc b/google/cloud/dataplex/v1/internal/data_taxonomy_tracing_stub.cc index 79272b6de87e3..1f7a1ee19d947 100644 --- a/google/cloud/dataplex/v1/internal/data_taxonomy_tracing_stub.cc +++ b/google/cloud/dataplex/v1/internal/data_taxonomy_tracing_stub.cc @@ -368,6 +368,64 @@ DataTaxonomyServiceTracingStub::GetDataAttribute( child_->GetDataAttribute(context, options, request)); } +StatusOr +DataTaxonomyServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataplex.v1.DataTaxonomyService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +DataTaxonomyServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataplex.v1.DataTaxonomyService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr DataTaxonomyServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataplex.v1.DataTaxonomyService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr DataTaxonomyServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataplex.v1.DataTaxonomyService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +DataTaxonomyServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataplex.v1.DataTaxonomyService", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> DataTaxonomyServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataplex/v1/internal/data_taxonomy_tracing_stub.h b/google/cloud/dataplex/v1/internal/data_taxonomy_tracing_stub.h index 88b4c04f57f0c..dafc8baef43d6 100644 --- a/google/cloud/dataplex/v1/internal/data_taxonomy_tracing_stub.h +++ b/google/cloud/dataplex/v1/internal/data_taxonomy_tracing_stub.h @@ -184,6 +184,26 @@ class DataTaxonomyServiceTracingStub : public DataTaxonomyServiceStub { google::cloud::dataplex::v1::GetDataAttributeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataplex/v1/internal/dataplex_auth_decorator.cc b/google/cloud/dataplex/v1/internal/dataplex_auth_decorator.cc index 97222912123a8..a40b35d4c4ea0 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_auth_decorator.cc +++ b/google/cloud/dataplex/v1/internal/dataplex_auth_decorator.cc @@ -607,6 +607,48 @@ DataplexServiceAuth::ListSessions( return child_->ListSessions(context, options, request); } +StatusOr +DataplexServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr DataplexServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr DataplexServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr DataplexServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +DataplexServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> DataplexServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataplex/v1/internal/dataplex_auth_decorator.h b/google/cloud/dataplex/v1/internal/dataplex_auth_decorator.h index c4151ccfa534b..a1ab1c8c7a4e9 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_auth_decorator.h +++ b/google/cloud/dataplex/v1/internal/dataplex_auth_decorator.h @@ -272,6 +272,26 @@ class DataplexServiceAuth : public DataplexServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::dataplex::v1::ListSessionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataplex/v1/internal/dataplex_connection_impl.cc b/google/cloud/dataplex/v1/internal/dataplex_connection_impl.cc index 26be000dd29db..477609bebaff2 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_connection_impl.cc +++ b/google/cloud/dataplex/v1/internal/dataplex_connection_impl.cc @@ -1868,6 +1868,94 @@ DataplexServiceConnectionImpl::ListSessions( }); } +StreamRange +DataplexServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DataplexServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr DataplexServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr DataplexServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +DataplexServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataplex_v1_internal } // namespace cloud diff --git a/google/cloud/dataplex/v1/internal/dataplex_connection_impl.h b/google/cloud/dataplex/v1/internal/dataplex_connection_impl.h index 720018d7d31e8..913c73d149237 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_connection_impl.h +++ b/google/cloud/dataplex/v1/internal/dataplex_connection_impl.h @@ -263,6 +263,21 @@ class DataplexServiceConnectionImpl StreamRange ListSessions( google::cloud::dataplex::v1::ListSessionsRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dataplex/v1/internal/dataplex_logging_decorator.cc b/google/cloud/dataplex/v1/internal/dataplex_logging_decorator.cc index cf016c137a67b..88d17d982c548 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_logging_decorator.cc +++ b/google/cloud/dataplex/v1/internal/dataplex_logging_decorator.cc @@ -694,6 +694,63 @@ DataplexServiceLogging::ListSessions( context, options, request, __func__, tracing_options_); } +StatusOr +DataplexServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DataplexServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DataplexServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DataplexServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataplexServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> DataplexServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataplex/v1/internal/dataplex_logging_decorator.h b/google/cloud/dataplex/v1/internal/dataplex_logging_decorator.h index 190cc9a571d51..4f1a2438e0c41 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_logging_decorator.h +++ b/google/cloud/dataplex/v1/internal/dataplex_logging_decorator.h @@ -272,6 +272,26 @@ class DataplexServiceLogging : public DataplexServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::dataplex::v1::ListSessionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataplex/v1/internal/dataplex_metadata_decorator.cc b/google/cloud/dataplex/v1/internal/dataplex_metadata_decorator.cc index c9dde4a9112b4..74051bab337ae 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_metadata_decorator.cc +++ b/google/cloud/dataplex/v1/internal/dataplex_metadata_decorator.cc @@ -513,6 +513,52 @@ DataplexServiceMetadata::ListSessions( return child_->ListSessions(context, options, request); } +StatusOr +DataplexServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +DataplexServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr DataplexServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr DataplexServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +DataplexServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> DataplexServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataplex/v1/internal/dataplex_metadata_decorator.h b/google/cloud/dataplex/v1/internal/dataplex_metadata_decorator.h index 65aaa827f34b8..2930ad6e3e09f 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_metadata_decorator.h +++ b/google/cloud/dataplex/v1/internal/dataplex_metadata_decorator.h @@ -273,6 +273,26 @@ class DataplexServiceMetadata : public DataplexServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::dataplex::v1::ListSessionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataplex/v1/internal/dataplex_stub.cc b/google/cloud/dataplex/v1/internal/dataplex_stub.cc index 72836b4286b1b..db5b4dc5c8cb5 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_stub.cc +++ b/google/cloud/dataplex/v1/internal/dataplex_stub.cc @@ -686,6 +686,65 @@ DefaultDataplexServiceStub::ListSessions( return response; } +StatusOr +DefaultDataplexServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataplexServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultDataplexServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultDataplexServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataplexServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultDataplexServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataplex/v1/internal/dataplex_stub.h b/google/cloud/dataplex/v1/internal/dataplex_stub.h index b1b1f7b51c627..62c3b805e42ab 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_stub.h +++ b/google/cloud/dataplex/v1/internal/dataplex_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -268,6 +272,28 @@ class DataplexServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::dataplex::v1::ListSessionsRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -287,9 +313,15 @@ class DefaultDataplexServiceStub : public DataplexServiceStub { std::unique_ptr< google::cloud::dataplex::v1::DataplexService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateLake( google::cloud::CompletionQueue& cq, @@ -524,6 +556,26 @@ class DefaultDataplexServiceStub : public DataplexServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::dataplex::v1::ListSessionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -539,6 +591,9 @@ class DefaultDataplexServiceStub : public DataplexServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/dataplex/v1/internal/dataplex_stub_factory.cc b/google/cloud/dataplex/v1/internal/dataplex_stub_factory.cc index e62b36f2bcc0e..d222edd32dfaf 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_stub_factory.cc +++ b/google/cloud/dataplex/v1/internal/dataplex_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultDataplexServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataplex::v1::DataplexService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/dataplex/v1/internal/dataplex_tracing_connection.cc b/google/cloud/dataplex/v1/internal/dataplex_tracing_connection.cc index 010b12094b027..eb65d90ca770e 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_tracing_connection.cc +++ b/google/cloud/dataplex/v1/internal/dataplex_tracing_connection.cc @@ -631,6 +631,53 @@ DataplexServiceTracingConnection::ListSessions( std::move(span), std::move(sr)); } +StreamRange +DataplexServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "dataplex_v1::DataplexServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DataplexServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dataplex_v1::DataplexServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +DataplexServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::DataplexServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +DataplexServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::DataplexServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +DataplexServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::DataplexServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dataplex/v1/internal/dataplex_tracing_connection.h b/google/cloud/dataplex/v1/internal/dataplex_tracing_connection.h index 72b74281aabd0..6a2900f1f211a 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_tracing_connection.h +++ b/google/cloud/dataplex/v1/internal/dataplex_tracing_connection.h @@ -251,6 +251,21 @@ class DataplexServiceTracingConnection StreamRange ListSessions( google::cloud::dataplex::v1::ListSessionsRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dataplex/v1/internal/dataplex_tracing_stub.cc b/google/cloud/dataplex/v1/internal/dataplex_tracing_stub.cc index 590e9ee0e402c..73cfe81d900ae 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_tracing_stub.cc +++ b/google/cloud/dataplex/v1/internal/dataplex_tracing_stub.cc @@ -627,6 +627,64 @@ DataplexServiceTracingStub::ListSessions( child_->ListSessions(context, options, request)); } +StatusOr +DataplexServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.DataplexService", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +DataplexServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.DataplexService", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr DataplexServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.DataplexService", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr DataplexServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.DataplexService", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +DataplexServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.DataplexService", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> DataplexServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataplex/v1/internal/dataplex_tracing_stub.h b/google/cloud/dataplex/v1/internal/dataplex_tracing_stub.h index 52896ad079247..2174663b304b1 100644 --- a/google/cloud/dataplex/v1/internal/dataplex_tracing_stub.h +++ b/google/cloud/dataplex/v1/internal/dataplex_tracing_stub.h @@ -272,6 +272,26 @@ class DataplexServiceTracingStub : public DataplexServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::dataplex::v1::ListSessionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataplex/v1/internal/metadata_auth_decorator.cc b/google/cloud/dataplex/v1/internal/metadata_auth_decorator.cc index d025e0c90b2a1..eb84c50e3e50a 100644 --- a/google/cloud/dataplex/v1/internal/metadata_auth_decorator.cc +++ b/google/cloud/dataplex/v1/internal/metadata_auth_decorator.cc @@ -107,6 +107,48 @@ MetadataServiceAuth::ListPartitions( return child_->ListPartitions(context, options, request); } +StatusOr +MetadataServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr MetadataServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr MetadataServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr MetadataServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +MetadataServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataplex_v1_internal } // namespace cloud diff --git a/google/cloud/dataplex/v1/internal/metadata_auth_decorator.h b/google/cloud/dataplex/v1/internal/metadata_auth_decorator.h index 568cfbb789ca6..ca94473f90ba2 100644 --- a/google/cloud/dataplex/v1/internal/metadata_auth_decorator.h +++ b/google/cloud/dataplex/v1/internal/metadata_auth_decorator.h @@ -77,6 +77,26 @@ class MetadataServiceAuth : public MetadataServiceStub { google::cloud::dataplex::v1::ListPartitionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/dataplex/v1/internal/metadata_connection_impl.cc b/google/cloud/dataplex/v1/internal/metadata_connection_impl.cc index 29d5d78616fb7..7bc4236fba6c4 100644 --- a/google/cloud/dataplex/v1/internal/metadata_connection_impl.cc +++ b/google/cloud/dataplex/v1/internal/metadata_connection_impl.cc @@ -226,6 +226,94 @@ MetadataServiceConnectionImpl::ListPartitions( }); } +StreamRange +MetadataServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +MetadataServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr MetadataServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr MetadataServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +MetadataServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataplex_v1_internal } // namespace cloud diff --git a/google/cloud/dataplex/v1/internal/metadata_connection_impl.h b/google/cloud/dataplex/v1/internal/metadata_connection_impl.h index 9152698533bfa..40ce26fa8b694 100644 --- a/google/cloud/dataplex/v1/internal/metadata_connection_impl.h +++ b/google/cloud/dataplex/v1/internal/metadata_connection_impl.h @@ -78,6 +78,21 @@ class MetadataServiceConnectionImpl StreamRange ListPartitions( google::cloud::dataplex::v1::ListPartitionsRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dataplex/v1/internal/metadata_logging_decorator.cc b/google/cloud/dataplex/v1/internal/metadata_logging_decorator.cc index ca0be7eb93061..31b1809f5bc59 100644 --- a/google/cloud/dataplex/v1/internal/metadata_logging_decorator.cc +++ b/google/cloud/dataplex/v1/internal/metadata_logging_decorator.cc @@ -143,6 +143,63 @@ MetadataServiceLogging::ListPartitions( context, options, request, __func__, tracing_options_); } +StatusOr +MetadataServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr MetadataServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr MetadataServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr MetadataServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +MetadataServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataplex_v1_internal } // namespace cloud diff --git a/google/cloud/dataplex/v1/internal/metadata_logging_decorator.h b/google/cloud/dataplex/v1/internal/metadata_logging_decorator.h index 822bc73ac3d78..03d31d04c315d 100644 --- a/google/cloud/dataplex/v1/internal/metadata_logging_decorator.h +++ b/google/cloud/dataplex/v1/internal/metadata_logging_decorator.h @@ -77,6 +77,26 @@ class MetadataServiceLogging : public MetadataServiceStub { google::cloud::dataplex::v1::ListPartitionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/dataplex/v1/internal/metadata_metadata_decorator.cc b/google/cloud/dataplex/v1/internal/metadata_metadata_decorator.cc index ef9fbd27bce68..e146e96f99fd2 100644 --- a/google/cloud/dataplex/v1/internal/metadata_metadata_decorator.cc +++ b/google/cloud/dataplex/v1/internal/metadata_metadata_decorator.cc @@ -124,6 +124,52 @@ MetadataServiceMetadata::ListPartitions( return child_->ListPartitions(context, options, request); } +StatusOr +MetadataServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +MetadataServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr MetadataServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr MetadataServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +MetadataServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + void MetadataServiceMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/dataplex/v1/internal/metadata_metadata_decorator.h b/google/cloud/dataplex/v1/internal/metadata_metadata_decorator.h index eb4969f6e0591..7517fcb686aec 100644 --- a/google/cloud/dataplex/v1/internal/metadata_metadata_decorator.h +++ b/google/cloud/dataplex/v1/internal/metadata_metadata_decorator.h @@ -78,6 +78,26 @@ class MetadataServiceMetadata : public MetadataServiceStub { google::cloud::dataplex::v1::ListPartitionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/dataplex/v1/internal/metadata_stub.cc b/google/cloud/dataplex/v1/internal/metadata_stub.cc index d5e63d7f29340..1bcb5bea87a13 100644 --- a/google/cloud/dataplex/v1/internal/metadata_stub.cc +++ b/google/cloud/dataplex/v1/internal/metadata_stub.cc @@ -136,6 +136,65 @@ DefaultMetadataServiceStub::ListPartitions( return response; } +StatusOr +DefaultMetadataServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultMetadataServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultMetadataServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultMetadataServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultMetadataServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataplex_v1_internal } // namespace cloud diff --git a/google/cloud/dataplex/v1/internal/metadata_stub.h b/google/cloud/dataplex/v1/internal/metadata_stub.h index e84067413e61e..588adaf9ba47a 100644 --- a/google/cloud/dataplex/v1/internal/metadata_stub.h +++ b/google/cloud/dataplex/v1/internal/metadata_stub.h @@ -23,6 +23,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include @@ -72,6 +76,28 @@ class MetadataServiceStub { ListPartitions( grpc::ClientContext& context, Options const& options, google::cloud::dataplex::v1::ListPartitionsRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; }; class DefaultMetadataServiceStub : public MetadataServiceStub { @@ -79,8 +105,13 @@ class DefaultMetadataServiceStub : public MetadataServiceStub { explicit DefaultMetadataServiceStub( std::unique_ptr< google::cloud::dataplex::v1::MetadataService::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr CreateEntity( grpc::ClientContext& context, Options const& options, @@ -121,9 +152,32 @@ class DefaultMetadataServiceStub : public MetadataServiceStub { google::cloud::dataplex::v1::ListPartitionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dataplex/v1/internal/metadata_stub_factory.cc b/google/cloud/dataplex/v1/internal/metadata_stub_factory.cc index 8125009e4dca4..60bfc03c0fbb8 100644 --- a/google/cloud/dataplex/v1/internal/metadata_stub_factory.cc +++ b/google/cloud/dataplex/v1/internal/metadata_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultMetadataServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataplex::v1::MetadataService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = diff --git a/google/cloud/dataplex/v1/internal/metadata_tracing_connection.cc b/google/cloud/dataplex/v1/internal/metadata_tracing_connection.cc index fdb53717f8690..e91fead941c3c 100644 --- a/google/cloud/dataplex/v1/internal/metadata_tracing_connection.cc +++ b/google/cloud/dataplex/v1/internal/metadata_tracing_connection.cc @@ -116,6 +116,53 @@ MetadataServiceTracingConnection::ListPartitions( google::cloud::dataplex::v1::Partition>(std::move(span), std::move(sr)); } +StreamRange +MetadataServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "dataplex_v1::MetadataServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +MetadataServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dataplex_v1::MetadataServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +MetadataServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::MetadataServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +MetadataServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::MetadataServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +MetadataServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "dataplex_v1::MetadataServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dataplex/v1/internal/metadata_tracing_connection.h b/google/cloud/dataplex/v1/internal/metadata_tracing_connection.h index c68f6d22d8b4e..61756f0f4e3b8 100644 --- a/google/cloud/dataplex/v1/internal/metadata_tracing_connection.h +++ b/google/cloud/dataplex/v1/internal/metadata_tracing_connection.h @@ -69,6 +69,21 @@ class MetadataServiceTracingConnection StreamRange ListPartitions( google::cloud::dataplex::v1::ListPartitionsRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dataplex/v1/internal/metadata_tracing_stub.cc b/google/cloud/dataplex/v1/internal/metadata_tracing_stub.cc index 3f7b0a0abe305..6fd49937073f1 100644 --- a/google/cloud/dataplex/v1/internal/metadata_tracing_stub.cc +++ b/google/cloud/dataplex/v1/internal/metadata_tracing_stub.cc @@ -138,6 +138,64 @@ MetadataServiceTracingStub::ListPartitions( child_->ListPartitions(context, options, request)); } +StatusOr +MetadataServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.MetadataService", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +MetadataServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.MetadataService", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr MetadataServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.MetadataService", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr MetadataServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.MetadataService", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +MetadataServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataplex.v1.MetadataService", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeMetadataServiceTracingStub( diff --git a/google/cloud/dataplex/v1/internal/metadata_tracing_stub.h b/google/cloud/dataplex/v1/internal/metadata_tracing_stub.h index ba5a49a793deb..afe098f19bc38 100644 --- a/google/cloud/dataplex/v1/internal/metadata_tracing_stub.h +++ b/google/cloud/dataplex/v1/internal/metadata_tracing_stub.h @@ -78,6 +78,26 @@ class MetadataServiceTracingStub : public MetadataServiceStub { google::cloud::dataplex::v1::ListPartitionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/dataplex/v1/metadata_client.cc b/google/cloud/dataplex/v1/metadata_client.cc index fd9d82658fa5c..53178bc812b0a 100644 --- a/google/cloud/dataplex/v1/metadata_client.cc +++ b/google/cloud/dataplex/v1/metadata_client.cc @@ -169,6 +169,38 @@ MetadataServiceClient::ListPartitions( return connection_->ListPartitions(std::move(request)); } +StreamRange +MetadataServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr MetadataServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr MetadataServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr MetadataServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +MetadataServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataplex_v1 } // namespace cloud diff --git a/google/cloud/dataplex/v1/metadata_client.h b/google/cloud/dataplex/v1/metadata_client.h index 85728bdf43cee..254bda85c3dee 100644 --- a/google/cloud/dataplex/v1/metadata_client.h +++ b/google/cloud/dataplex/v1/metadata_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -605,6 +606,178 @@ class MetadataServiceClient { google::cloud::dataplex::v1::ListPartitionsRequest request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dataplex/v1/metadata_connection.cc b/google/cloud/dataplex/v1/metadata_connection.cc index a14a33a43b075..5bc2ed1184101 100644 --- a/google/cloud/dataplex/v1/metadata_connection.cc +++ b/google/cloud/dataplex/v1/metadata_connection.cc @@ -94,6 +94,36 @@ MetadataServiceConnection::ListPartitions( StreamRange>(); } +StreamRange +MetadataServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +MetadataServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr MetadataServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr MetadataServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +MetadataServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeMetadataServiceConnection( Options options) { internal::CheckExpectedOptions +#include +#include #include namespace google { @@ -209,6 +211,21 @@ class MetadataServiceConnection { virtual StreamRange ListPartitions( google::cloud::dataplex::v1::ListPartitionsRequest request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/dataplex/v1/metadata_connection_idempotency_policy.cc b/google/cloud/dataplex/v1/metadata_connection_idempotency_policy.cc index 0e91c38e7640f..e96513aa358ca 100644 --- a/google/cloud/dataplex/v1/metadata_connection_idempotency_policy.cc +++ b/google/cloud/dataplex/v1/metadata_connection_idempotency_policy.cc @@ -79,6 +79,32 @@ Idempotency MetadataServiceConnectionIdempotencyPolicy::ListPartitions( return Idempotency::kIdempotent; } +Idempotency MetadataServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency MetadataServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency MetadataServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency MetadataServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency MetadataServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultMetadataServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dataplex/v1/metadata_connection_idempotency_policy.h b/google/cloud/dataplex/v1/metadata_connection_idempotency_policy.h index 578f4dc26979a..7c1fd6488567f 100644 --- a/google/cloud/dataplex/v1/metadata_connection_idempotency_policy.h +++ b/google/cloud/dataplex/v1/metadata_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -63,6 +65,21 @@ class MetadataServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListPartitions( google::cloud::dataplex::v1::ListPartitionsRequest request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dataplex/v1/mocks/mock_catalog_connection.h b/google/cloud/dataplex/v1/mocks/mock_catalog_connection.h index 0fb35ba050d77..b0916e1b3c9f1 100644 --- a/google/cloud/dataplex/v1/mocks/mock_catalog_connection.h +++ b/google/cloud/dataplex/v1/mocks/mock_catalog_connection.h @@ -453,6 +453,27 @@ class MockCatalogServiceConnection SearchEntries, (google::cloud::dataplex::v1::SearchEntriesRequest request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dataplex/v1/mocks/mock_content_connection.h b/google/cloud/dataplex/v1/mocks/mock_content_connection.h index dae282f911152..6fd8d1b2e63c1 100644 --- a/google/cloud/dataplex/v1/mocks/mock_content_connection.h +++ b/google/cloud/dataplex/v1/mocks/mock_content_connection.h @@ -82,6 +82,14 @@ class MockContentServiceConnection MOCK_METHOD((StreamRange), ListContent, (google::cloud::dataplex::v1::ListContentRequest request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dataplex/v1/mocks/mock_data_scan_connection.h b/google/cloud/dataplex/v1/mocks/mock_data_scan_connection.h index 148ea02a74810..f73489ce93b10 100644 --- a/google/cloud/dataplex/v1/mocks/mock_data_scan_connection.h +++ b/google/cloud/dataplex/v1/mocks/mock_data_scan_connection.h @@ -192,6 +192,27 @@ class MockDataScanServiceConnection (google::cloud::dataplex::v1::GenerateDataQualityRulesRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dataplex/v1/mocks/mock_data_taxonomy_connection.h b/google/cloud/dataplex/v1/mocks/mock_data_taxonomy_connection.h index 06cdbc81cde52..378fddda95fcc 100644 --- a/google/cloud/dataplex/v1/mocks/mock_data_taxonomy_connection.h +++ b/google/cloud/dataplex/v1/mocks/mock_data_taxonomy_connection.h @@ -441,6 +441,27 @@ class MockDataTaxonomyServiceConnection StatusOr, GetDataAttribute, (google::cloud::dataplex::v1::GetDataAttributeRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dataplex/v1/mocks/mock_dataplex_connection.h b/google/cloud/dataplex/v1/mocks/mock_dataplex_connection.h index 913592f717ed9..86aba99b34261 100644 --- a/google/cloud/dataplex/v1/mocks/mock_dataplex_connection.h +++ b/google/cloud/dataplex/v1/mocks/mock_dataplex_connection.h @@ -668,6 +668,27 @@ class MockDataplexServiceConnection MOCK_METHOD((StreamRange), ListSessions, (google::cloud::dataplex::v1::ListSessionsRequest request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dataplex/v1/mocks/mock_metadata_connection.h b/google/cloud/dataplex/v1/mocks/mock_metadata_connection.h index dc9d6f759a33e..0252e156e5724 100644 --- a/google/cloud/dataplex/v1/mocks/mock_metadata_connection.h +++ b/google/cloud/dataplex/v1/mocks/mock_metadata_connection.h @@ -85,6 +85,27 @@ class MockMetadataServiceConnection ListPartitions, (google::cloud::dataplex::v1::ListPartitionsRequest request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dataproc/BUILD.bazel b/google/cloud/dataproc/BUILD.bazel index 995a3c6c8aa79..2ea90ea88661b 100644 --- a/google/cloud/dataproc/BUILD.bazel +++ b/google/cloud/dataproc/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/dataproc/v1:dataproc_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/dataproc/v1/autoscaling_policy_client.cc b/google/cloud/dataproc/v1/autoscaling_policy_client.cc index 6ff609dd6a837..99fecb3d0120b 100644 --- a/google/cloud/dataproc/v1/autoscaling_policy_client.cc +++ b/google/cloud/dataproc/v1/autoscaling_policy_client.cc @@ -120,6 +120,25 @@ Status AutoscalingPolicyServiceClient::DeleteAutoscalingPolicy( return connection_->DeleteAutoscalingPolicy(request); } +StatusOr AutoscalingPolicyServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr AutoscalingPolicyServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +AutoscalingPolicyServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataproc_v1 } // namespace cloud diff --git a/google/cloud/dataproc/v1/autoscaling_policy_client.h b/google/cloud/dataproc/v1/autoscaling_policy_client.h index 948e1ebfb1ee1..22b4a4cf41b32 100644 --- a/google/cloud/dataproc/v1/autoscaling_policy_client.h +++ b/google/cloud/dataproc/v1/autoscaling_policy_client.h @@ -438,6 +438,108 @@ class AutoscalingPolicyServiceClient { request, Options opts = {}); + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dataproc/v1/autoscaling_policy_connection.cc b/google/cloud/dataproc/v1/autoscaling_policy_connection.cc index 42d9ca916bede..c0a0a4090443e 100644 --- a/google/cloud/dataproc/v1/autoscaling_policy_connection.cc +++ b/google/cloud/dataproc/v1/autoscaling_policy_connection.cc @@ -70,6 +70,24 @@ Status AutoscalingPolicyServiceConnection::DeleteAutoscalingPolicy( return Status(StatusCode::kUnimplemented, "not implemented"); } +StatusOr +AutoscalingPolicyServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +AutoscalingPolicyServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +AutoscalingPolicyServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAutoscalingPolicyServiceConnection(std::string const& location, Options options) { diff --git a/google/cloud/dataproc/v1/autoscaling_policy_connection.h b/google/cloud/dataproc/v1/autoscaling_policy_connection.h index 84d4b14706311..1a632384149e6 100644 --- a/google/cloud/dataproc/v1/autoscaling_policy_connection.h +++ b/google/cloud/dataproc/v1/autoscaling_policy_connection.h @@ -28,6 +28,7 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include #include #include @@ -217,6 +218,15 @@ class AutoscalingPolicyServiceConnection { virtual Status DeleteAutoscalingPolicy( google::cloud::dataproc::v1::DeleteAutoscalingPolicyRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/dataproc/v1/autoscaling_policy_connection_idempotency_policy.cc b/google/cloud/dataproc/v1/autoscaling_policy_connection_idempotency_policy.cc index 978cab29b55a4..c21cb4e67b9f3 100644 --- a/google/cloud/dataproc/v1/autoscaling_policy_connection_idempotency_policy.cc +++ b/google/cloud/dataproc/v1/autoscaling_policy_connection_idempotency_policy.cc @@ -65,6 +65,23 @@ AutoscalingPolicyServiceConnectionIdempotencyPolicy::DeleteAutoscalingPolicy( return Idempotency::kNonIdempotent; } +Idempotency AutoscalingPolicyServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency AutoscalingPolicyServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +AutoscalingPolicyServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultAutoscalingPolicyServiceConnectionIdempotencyPolicy() { return std::make_unique< diff --git a/google/cloud/dataproc/v1/autoscaling_policy_connection_idempotency_policy.h b/google/cloud/dataproc/v1/autoscaling_policy_connection_idempotency_policy.h index 3d5af04549332..09b4574720e64 100644 --- a/google/cloud/dataproc/v1/autoscaling_policy_connection_idempotency_policy.h +++ b/google/cloud/dataproc/v1/autoscaling_policy_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -54,6 +55,15 @@ class AutoscalingPolicyServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteAutoscalingPolicy( google::cloud::dataproc::v1::DeleteAutoscalingPolicyRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dataproc/v1/batch_controller_client.cc b/google/cloud/dataproc/v1/batch_controller_client.cc index deeba74362d25..72cb3acbca71a 100644 --- a/google/cloud/dataproc/v1/batch_controller_client.cc +++ b/google/cloud/dataproc/v1/batch_controller_client.cc @@ -122,6 +122,25 @@ Status BatchControllerClient::DeleteBatch( return connection_->DeleteBatch(request); } +StatusOr BatchControllerClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr BatchControllerClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +BatchControllerClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataproc_v1 } // namespace cloud diff --git a/google/cloud/dataproc/v1/batch_controller_client.h b/google/cloud/dataproc/v1/batch_controller_client.h index bc9eb0da30863..25715d9ad32a8 100644 --- a/google/cloud/dataproc/v1/batch_controller_client.h +++ b/google/cloud/dataproc/v1/batch_controller_client.h @@ -394,6 +394,108 @@ class BatchControllerClient { google::cloud::dataproc::v1::DeleteBatchRequest const& request, Options opts = {}); + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dataproc/v1/batch_controller_connection.cc b/google/cloud/dataproc/v1/batch_controller_connection.cc index fe75f16245365..e386d2d7315ed 100644 --- a/google/cloud/dataproc/v1/batch_controller_connection.cc +++ b/google/cloud/dataproc/v1/batch_controller_connection.cc @@ -78,6 +78,22 @@ Status BatchControllerConnection::DeleteBatch( return Status(StatusCode::kUnimplemented, "not implemented"); } +StatusOr BatchControllerConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr BatchControllerConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +BatchControllerConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeBatchControllerConnection( std::string const& location, Options options) { internal::CheckExpectedOptions #include +#include #include #include #include @@ -207,6 +208,15 @@ class BatchControllerConnection { virtual Status DeleteBatch( google::cloud::dataproc::v1::DeleteBatchRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/dataproc/v1/batch_controller_connection_idempotency_policy.cc b/google/cloud/dataproc/v1/batch_controller_connection_idempotency_policy.cc index 5ab49f8054b1e..970820ec3087b 100644 --- a/google/cloud/dataproc/v1/batch_controller_connection_idempotency_policy.cc +++ b/google/cloud/dataproc/v1/batch_controller_connection_idempotency_policy.cc @@ -54,6 +54,22 @@ Idempotency BatchControllerConnectionIdempotencyPolicy::DeleteBatch( return Idempotency::kNonIdempotent; } +Idempotency BatchControllerConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency BatchControllerConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency BatchControllerConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultBatchControllerConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dataproc/v1/batch_controller_connection_idempotency_policy.h b/google/cloud/dataproc/v1/batch_controller_connection_idempotency_policy.h index cc75f359a1c09..6f6a2f7d42226 100644 --- a/google/cloud/dataproc/v1/batch_controller_connection_idempotency_policy.h +++ b/google/cloud/dataproc/v1/batch_controller_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -48,6 +49,15 @@ class BatchControllerConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteBatch( google::cloud::dataproc::v1::DeleteBatchRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dataproc/v1/cluster_controller_client.cc b/google/cloud/dataproc/v1/cluster_controller_client.cc index fd4a3f8811146..950412321b657 100644 --- a/google/cloud/dataproc/v1/cluster_controller_client.cc +++ b/google/cloud/dataproc/v1/cluster_controller_client.cc @@ -324,6 +324,25 @@ ClusterControllerClient::DiagnoseCluster( return connection_->DiagnoseCluster(operation); } +StatusOr ClusterControllerClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr ClusterControllerClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +ClusterControllerClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataproc_v1 } // namespace cloud diff --git a/google/cloud/dataproc/v1/cluster_controller_client.h b/google/cloud/dataproc/v1/cluster_controller_client.h index 2f3966edb7cd4..2a0f7eb632b00 100644 --- a/google/cloud/dataproc/v1/cluster_controller_client.h +++ b/google/cloud/dataproc/v1/cluster_controller_client.h @@ -941,6 +941,108 @@ class ClusterControllerClient { DiagnoseCluster(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dataproc/v1/cluster_controller_connection.cc b/google/cloud/dataproc/v1/cluster_controller_connection.cc index bf58533a5b14d..2026063d4f54b 100644 --- a/google/cloud/dataproc/v1/cluster_controller_connection.cc +++ b/google/cloud/dataproc/v1/cluster_controller_connection.cc @@ -190,6 +190,22 @@ ClusterControllerConnection::DiagnoseCluster( Status(StatusCode::kUnimplemented, "not implemented")); } +StatusOr ClusterControllerConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr ClusterControllerConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +ClusterControllerConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeClusterControllerConnection( std::string const& location, Options options) { internal::CheckExpectedOptions #include +#include #include #include #include @@ -258,6 +259,15 @@ class ClusterControllerConnection { virtual future> DiagnoseCluster(google::longrunning::Operation const& operation); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/dataproc/v1/cluster_controller_connection_idempotency_policy.cc b/google/cloud/dataproc/v1/cluster_controller_connection_idempotency_policy.cc index 42fcb427a6d69..6de4cde49db44 100644 --- a/google/cloud/dataproc/v1/cluster_controller_connection_idempotency_policy.cc +++ b/google/cloud/dataproc/v1/cluster_controller_connection_idempotency_policy.cc @@ -74,6 +74,22 @@ Idempotency ClusterControllerConnectionIdempotencyPolicy::DiagnoseCluster( return Idempotency::kNonIdempotent; } +Idempotency ClusterControllerConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency ClusterControllerConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ClusterControllerConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultClusterControllerConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dataproc/v1/cluster_controller_connection_idempotency_policy.h b/google/cloud/dataproc/v1/cluster_controller_connection_idempotency_policy.h index 1cbcd706527d9..aa2197ef224ca 100644 --- a/google/cloud/dataproc/v1/cluster_controller_connection_idempotency_policy.h +++ b/google/cloud/dataproc/v1/cluster_controller_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -60,6 +61,15 @@ class ClusterControllerConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DiagnoseCluster( google::cloud::dataproc::v1::DiagnoseClusterRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dataproc/v1/internal/autoscaling_policy_auth_decorator.cc b/google/cloud/dataproc/v1/internal/autoscaling_policy_auth_decorator.cc index bb50aa75ae915..bcd44384370ed 100644 --- a/google/cloud/dataproc/v1/internal/autoscaling_policy_auth_decorator.cc +++ b/google/cloud/dataproc/v1/internal/autoscaling_policy_auth_decorator.cc @@ -79,6 +79,31 @@ Status AutoscalingPolicyServiceAuth::DeleteAutoscalingPolicy( return child_->DeleteAutoscalingPolicy(context, options, request); } +StatusOr AutoscalingPolicyServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr AutoscalingPolicyServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +AutoscalingPolicyServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataproc_v1_internal } // namespace cloud diff --git a/google/cloud/dataproc/v1/internal/autoscaling_policy_auth_decorator.h b/google/cloud/dataproc/v1/internal/autoscaling_policy_auth_decorator.h index f7dc1242e9182..6d5d630c6051a 100644 --- a/google/cloud/dataproc/v1/internal/autoscaling_policy_auth_decorator.h +++ b/google/cloud/dataproc/v1/internal/autoscaling_policy_auth_decorator.h @@ -66,6 +66,18 @@ class AutoscalingPolicyServiceAuth : public AutoscalingPolicyServiceStub { google::cloud::dataproc::v1::DeleteAutoscalingPolicyRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/dataproc/v1/internal/autoscaling_policy_connection_impl.cc b/google/cloud/dataproc/v1/internal/autoscaling_policy_connection_impl.cc index 8993b69c3f82d..17eb352c7f69e 100644 --- a/google/cloud/dataproc/v1/internal/autoscaling_policy_connection_impl.cc +++ b/google/cloud/dataproc/v1/internal/autoscaling_policy_connection_impl.cc @@ -163,6 +163,48 @@ Status AutoscalingPolicyServiceConnectionImpl::DeleteAutoscalingPolicy( *current, request, __func__); } +StatusOr +AutoscalingPolicyServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +AutoscalingPolicyServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +AutoscalingPolicyServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataproc_v1_internal } // namespace cloud diff --git a/google/cloud/dataproc/v1/internal/autoscaling_policy_connection_impl.h b/google/cloud/dataproc/v1/internal/autoscaling_policy_connection_impl.h index 6e22767645116..db7d83bbaeb71 100644 --- a/google/cloud/dataproc/v1/internal/autoscaling_policy_connection_impl.h +++ b/google/cloud/dataproc/v1/internal/autoscaling_policy_connection_impl.h @@ -72,6 +72,15 @@ class AutoscalingPolicyServiceConnectionImpl google::cloud::dataproc::v1::DeleteAutoscalingPolicyRequest const& request) override; + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dataproc/v1/internal/autoscaling_policy_logging_decorator.cc b/google/cloud/dataproc/v1/internal/autoscaling_policy_logging_decorator.cc index 2482a83e40761..4f7264fa9b6fd 100644 --- a/google/cloud/dataproc/v1/internal/autoscaling_policy_logging_decorator.cc +++ b/google/cloud/dataproc/v1/internal/autoscaling_policy_logging_decorator.cc @@ -103,6 +103,40 @@ Status AutoscalingPolicyServiceLogging::DeleteAutoscalingPolicy( context, options, request, __func__, tracing_options_); } +StatusOr AutoscalingPolicyServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AutoscalingPolicyServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AutoscalingPolicyServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataproc_v1_internal } // namespace cloud diff --git a/google/cloud/dataproc/v1/internal/autoscaling_policy_logging_decorator.h b/google/cloud/dataproc/v1/internal/autoscaling_policy_logging_decorator.h index a6397d8abb7ec..ed607112c49ad 100644 --- a/google/cloud/dataproc/v1/internal/autoscaling_policy_logging_decorator.h +++ b/google/cloud/dataproc/v1/internal/autoscaling_policy_logging_decorator.h @@ -66,6 +66,18 @@ class AutoscalingPolicyServiceLogging : public AutoscalingPolicyServiceStub { google::cloud::dataproc::v1::DeleteAutoscalingPolicyRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/dataproc/v1/internal/autoscaling_policy_metadata_decorator.cc b/google/cloud/dataproc/v1/internal/autoscaling_policy_metadata_decorator.cc index e55c1bbf72df8..adb659e55e7b8 100644 --- a/google/cloud/dataproc/v1/internal/autoscaling_policy_metadata_decorator.cc +++ b/google/cloud/dataproc/v1/internal/autoscaling_policy_metadata_decorator.cc @@ -93,6 +93,36 @@ Status AutoscalingPolicyServiceMetadata::DeleteAutoscalingPolicy( return child_->DeleteAutoscalingPolicy(context, options, request); } +StatusOr +AutoscalingPolicyServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr +AutoscalingPolicyServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +AutoscalingPolicyServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + void AutoscalingPolicyServiceMetadata::SetMetadata( grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/dataproc/v1/internal/autoscaling_policy_metadata_decorator.h b/google/cloud/dataproc/v1/internal/autoscaling_policy_metadata_decorator.h index de730dbb85cac..73a3d6c589003 100644 --- a/google/cloud/dataproc/v1/internal/autoscaling_policy_metadata_decorator.h +++ b/google/cloud/dataproc/v1/internal/autoscaling_policy_metadata_decorator.h @@ -67,6 +67,18 @@ class AutoscalingPolicyServiceMetadata : public AutoscalingPolicyServiceStub { google::cloud::dataproc::v1::DeleteAutoscalingPolicyRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/dataproc/v1/internal/autoscaling_policy_stub.cc b/google/cloud/dataproc/v1/internal/autoscaling_policy_stub.cc index 570fe2d752089..02ccdf36ace51 100644 --- a/google/cloud/dataproc/v1/internal/autoscaling_policy_stub.cc +++ b/google/cloud/dataproc/v1/internal/autoscaling_policy_stub.cc @@ -97,6 +97,43 @@ Status DefaultAutoscalingPolicyServiceStub::DeleteAutoscalingPolicy( return google::cloud::Status(); } +StatusOr +DefaultAutoscalingPolicyServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAutoscalingPolicyServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAutoscalingPolicyServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataproc_v1_internal } // namespace cloud diff --git a/google/cloud/dataproc/v1/internal/autoscaling_policy_stub.h b/google/cloud/dataproc/v1/internal/autoscaling_policy_stub.h index 288f96d74ba87..1ebaf4ee08379 100644 --- a/google/cloud/dataproc/v1/internal/autoscaling_policy_stub.h +++ b/google/cloud/dataproc/v1/internal/autoscaling_policy_stub.h @@ -23,6 +23,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -63,6 +65,19 @@ class AutoscalingPolicyServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::dataproc::v1::DeleteAutoscalingPolicyRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; }; class DefaultAutoscalingPolicyServiceStub @@ -71,8 +86,10 @@ class DefaultAutoscalingPolicyServiceStub explicit DefaultAutoscalingPolicyServiceStub( std::unique_ptr< google::cloud::dataproc::v1::AutoscalingPolicyService::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr iampolicy_stub) + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)) {} StatusOr CreateAutoscalingPolicy( @@ -102,10 +119,23 @@ class DefaultAutoscalingPolicyServiceStub google::cloud::dataproc::v1::DeleteAutoscalingPolicyRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr< google::cloud::dataproc::v1::AutoscalingPolicyService::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dataproc/v1/internal/autoscaling_policy_stub_factory.cc b/google/cloud/dataproc/v1/internal/autoscaling_policy_stub_factory.cc index 6e52d77a4d0b9..6ba12f14a52e0 100644 --- a/google/cloud/dataproc/v1/internal/autoscaling_policy_stub_factory.cc +++ b/google/cloud/dataproc/v1/internal/autoscaling_policy_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -45,9 +46,10 @@ CreateDefaultAutoscalingPolicyServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataproc::v1::AutoscalingPolicyService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_iampolicy_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/dataproc/v1/internal/autoscaling_policy_tracing_connection.cc b/google/cloud/dataproc/v1/internal/autoscaling_policy_tracing_connection.cc index 167f57f7ce81f..d73a1b1cd9929 100644 --- a/google/cloud/dataproc/v1/internal/autoscaling_policy_tracing_connection.cc +++ b/google/cloud/dataproc/v1/internal/autoscaling_policy_tracing_connection.cc @@ -88,6 +88,33 @@ Status AutoscalingPolicyServiceTracingConnection::DeleteAutoscalingPolicy( return internal::EndSpan(*span, child_->DeleteAutoscalingPolicy(request)); } +StatusOr +AutoscalingPolicyServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::AutoscalingPolicyServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +AutoscalingPolicyServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::AutoscalingPolicyServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +AutoscalingPolicyServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::AutoscalingPolicyServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dataproc/v1/internal/autoscaling_policy_tracing_connection.h b/google/cloud/dataproc/v1/internal/autoscaling_policy_tracing_connection.h index e96f7102b4dff..4fd590ad97b1d 100644 --- a/google/cloud/dataproc/v1/internal/autoscaling_policy_tracing_connection.h +++ b/google/cloud/dataproc/v1/internal/autoscaling_policy_tracing_connection.h @@ -63,6 +63,15 @@ class AutoscalingPolicyServiceTracingConnection google::cloud::dataproc::v1::DeleteAutoscalingPolicyRequest const& request) override; + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dataproc/v1/internal/autoscaling_policy_tracing_stub.cc b/google/cloud/dataproc/v1/internal/autoscaling_policy_tracing_stub.cc index 99f3115b746da..e8b7e3a56f2a8 100644 --- a/google/cloud/dataproc/v1/internal/autoscaling_policy_tracing_stub.cc +++ b/google/cloud/dataproc/v1/internal/autoscaling_policy_tracing_stub.cc @@ -104,6 +104,43 @@ Status AutoscalingPolicyServiceTracingStub::DeleteAutoscalingPolicy( child_->DeleteAutoscalingPolicy(context, options, request)); } +StatusOr +AutoscalingPolicyServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.AutoscalingPolicyService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr +AutoscalingPolicyServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.AutoscalingPolicyService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +AutoscalingPolicyServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.AutoscalingPolicyService", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dataproc/v1/internal/autoscaling_policy_tracing_stub.h b/google/cloud/dataproc/v1/internal/autoscaling_policy_tracing_stub.h index d8efca9b6eca5..54b35dd7932b0 100644 --- a/google/cloud/dataproc/v1/internal/autoscaling_policy_tracing_stub.h +++ b/google/cloud/dataproc/v1/internal/autoscaling_policy_tracing_stub.h @@ -68,6 +68,18 @@ class AutoscalingPolicyServiceTracingStub google::cloud::dataproc::v1::DeleteAutoscalingPolicyRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/dataproc/v1/internal/batch_controller_auth_decorator.cc b/google/cloud/dataproc/v1/internal/batch_controller_auth_decorator.cc index 37dcc0536c2c9..62b3f05336b3b 100644 --- a/google/cloud/dataproc/v1/internal/batch_controller_auth_decorator.cc +++ b/google/cloud/dataproc/v1/internal/batch_controller_auth_decorator.cc @@ -84,6 +84,31 @@ Status BatchControllerAuth::DeleteBatch( return child_->DeleteBatch(context, options, request); } +StatusOr BatchControllerAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr BatchControllerAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +BatchControllerAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> BatchControllerAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/batch_controller_auth_decorator.h b/google/cloud/dataproc/v1/internal/batch_controller_auth_decorator.h index 42c1dbb621b14..bc0aa6375deb4 100644 --- a/google/cloud/dataproc/v1/internal/batch_controller_auth_decorator.h +++ b/google/cloud/dataproc/v1/internal/batch_controller_auth_decorator.h @@ -61,6 +61,18 @@ class BatchControllerAuth : public BatchControllerStub { grpc::ClientContext& context, Options const& options, google::cloud::dataproc::v1::DeleteBatchRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataproc/v1/internal/batch_controller_connection_impl.cc b/google/cloud/dataproc/v1/internal/batch_controller_connection_impl.cc index 757b19e371600..76dbce22e3fd3 100644 --- a/google/cloud/dataproc/v1/internal/batch_controller_connection_impl.cc +++ b/google/cloud/dataproc/v1/internal/batch_controller_connection_impl.cc @@ -218,6 +218,46 @@ Status BatchControllerConnectionImpl::DeleteBatch( *current, request, __func__); } +StatusOr BatchControllerConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr BatchControllerConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +BatchControllerConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataproc_v1_internal } // namespace cloud diff --git a/google/cloud/dataproc/v1/internal/batch_controller_connection_impl.h b/google/cloud/dataproc/v1/internal/batch_controller_connection_impl.h index a461917d467f1..6ce040944ed1c 100644 --- a/google/cloud/dataproc/v1/internal/batch_controller_connection_impl.h +++ b/google/cloud/dataproc/v1/internal/batch_controller_connection_impl.h @@ -71,6 +71,15 @@ class BatchControllerConnectionImpl Status DeleteBatch( google::cloud::dataproc::v1::DeleteBatchRequest const& request) override; + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dataproc/v1/internal/batch_controller_logging_decorator.cc b/google/cloud/dataproc/v1/internal/batch_controller_logging_decorator.cc index 09659d6f358d2..e06f6d67b27cc 100644 --- a/google/cloud/dataproc/v1/internal/batch_controller_logging_decorator.cc +++ b/google/cloud/dataproc/v1/internal/batch_controller_logging_decorator.cc @@ -98,6 +98,40 @@ Status BatchControllerLogging::DeleteBatch( context, options, request, __func__, tracing_options_); } +StatusOr BatchControllerLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr BatchControllerLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +BatchControllerLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> BatchControllerLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/batch_controller_logging_decorator.h b/google/cloud/dataproc/v1/internal/batch_controller_logging_decorator.h index 2688b62a78a45..036f22822ddaa 100644 --- a/google/cloud/dataproc/v1/internal/batch_controller_logging_decorator.h +++ b/google/cloud/dataproc/v1/internal/batch_controller_logging_decorator.h @@ -61,6 +61,18 @@ class BatchControllerLogging : public BatchControllerStub { grpc::ClientContext& context, Options const& options, google::cloud::dataproc::v1::DeleteBatchRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataproc/v1/internal/batch_controller_metadata_decorator.cc b/google/cloud/dataproc/v1/internal/batch_controller_metadata_decorator.cc index e9c5051ba20b6..0dfd428422399 100644 --- a/google/cloud/dataproc/v1/internal/batch_controller_metadata_decorator.cc +++ b/google/cloud/dataproc/v1/internal/batch_controller_metadata_decorator.cc @@ -89,6 +89,34 @@ Status BatchControllerMetadata::DeleteBatch( return child_->DeleteBatch(context, options, request); } +StatusOr BatchControllerMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr BatchControllerMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +BatchControllerMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> BatchControllerMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/batch_controller_metadata_decorator.h b/google/cloud/dataproc/v1/internal/batch_controller_metadata_decorator.h index eed0313a70c9e..486677edf133f 100644 --- a/google/cloud/dataproc/v1/internal/batch_controller_metadata_decorator.h +++ b/google/cloud/dataproc/v1/internal/batch_controller_metadata_decorator.h @@ -62,6 +62,18 @@ class BatchControllerMetadata : public BatchControllerStub { grpc::ClientContext& context, Options const& options, google::cloud::dataproc::v1::DeleteBatchRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataproc/v1/internal/batch_controller_stub.cc b/google/cloud/dataproc/v1/internal/batch_controller_stub.cc index a08f0cc1130d0..c03e84adac52f 100644 --- a/google/cloud/dataproc/v1/internal/batch_controller_stub.cc +++ b/google/cloud/dataproc/v1/internal/batch_controller_stub.cc @@ -96,6 +96,41 @@ Status DefaultBatchControllerStub::DeleteBatch( return google::cloud::Status(); } +StatusOr DefaultBatchControllerStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultBatchControllerStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultBatchControllerStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultBatchControllerStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/batch_controller_stub.h b/google/cloud/dataproc/v1/internal/batch_controller_stub.h index d9bc7240990fd..708780a18ad44 100644 --- a/google/cloud/dataproc/v1/internal/batch_controller_stub.h +++ b/google/cloud/dataproc/v1/internal/batch_controller_stub.h @@ -26,6 +26,8 @@ #include "google/cloud/version.h" #include #include +#include +#include #include #include #include @@ -62,6 +64,19 @@ class BatchControllerStub { grpc::ClientContext& context, Options const& options, google::cloud::dataproc::v1::DeleteBatchRequest const& request) = 0; + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -81,9 +96,12 @@ class DefaultBatchControllerStub : public BatchControllerStub { std::unique_ptr< google::cloud::dataproc::v1::BatchController::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + operations_(std::move(operations)) {} future> AsyncCreateBatch( google::cloud::CompletionQueue& cq, @@ -107,6 +125,18 @@ class DefaultBatchControllerStub : public BatchControllerStub { grpc::ClientContext& context, Options const& options, google::cloud::dataproc::v1::DeleteBatchRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -122,6 +152,7 @@ class DefaultBatchControllerStub : public BatchControllerStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/dataproc/v1/internal/batch_controller_stub_factory.cc b/google/cloud/dataproc/v1/internal/batch_controller_stub_factory.cc index fbc8a6c956a45..beeadd5c500c7 100644 --- a/google/cloud/dataproc/v1/internal/batch_controller_stub_factory.cc +++ b/google/cloud/dataproc/v1/internal/batch_controller_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,9 +45,10 @@ std::shared_ptr CreateDefaultBatchControllerStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataproc::v1::BatchController::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/dataproc/v1/internal/batch_controller_tracing_connection.cc b/google/cloud/dataproc/v1/internal/batch_controller_tracing_connection.cc index 6765273883c2b..fd4cad3a94769 100644 --- a/google/cloud/dataproc/v1/internal/batch_controller_tracing_connection.cc +++ b/google/cloud/dataproc/v1/internal/batch_controller_tracing_connection.cc @@ -89,6 +89,33 @@ Status BatchControllerTracingConnection::DeleteBatch( return internal::EndSpan(*span, child_->DeleteBatch(request)); } +StatusOr +BatchControllerTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::BatchControllerConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +BatchControllerTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::BatchControllerConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +BatchControllerTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::BatchControllerConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dataproc/v1/internal/batch_controller_tracing_connection.h b/google/cloud/dataproc/v1/internal/batch_controller_tracing_connection.h index 80e997b1ff1a6..76bc3c54b5437 100644 --- a/google/cloud/dataproc/v1/internal/batch_controller_tracing_connection.h +++ b/google/cloud/dataproc/v1/internal/batch_controller_tracing_connection.h @@ -59,6 +59,15 @@ class BatchControllerTracingConnection Status DeleteBatch( google::cloud::dataproc::v1::DeleteBatchRequest const& request) override; + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dataproc/v1/internal/batch_controller_tracing_stub.cc b/google/cloud/dataproc/v1/internal/batch_controller_tracing_stub.cc index 48939905c3130..7f85cbb086f00 100644 --- a/google/cloud/dataproc/v1/internal/batch_controller_tracing_stub.cc +++ b/google/cloud/dataproc/v1/internal/batch_controller_tracing_stub.cc @@ -93,6 +93,40 @@ Status BatchControllerTracingStub::DeleteBatch( child_->DeleteBatch(context, options, request)); } +StatusOr BatchControllerTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataproc.v1.BatchController", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr BatchControllerTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataproc.v1.BatchController", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +BatchControllerTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataproc.v1.BatchController", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> BatchControllerTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/batch_controller_tracing_stub.h b/google/cloud/dataproc/v1/internal/batch_controller_tracing_stub.h index 068692ea4c6fa..a5a5c9208d842 100644 --- a/google/cloud/dataproc/v1/internal/batch_controller_tracing_stub.h +++ b/google/cloud/dataproc/v1/internal/batch_controller_tracing_stub.h @@ -61,6 +61,18 @@ class BatchControllerTracingStub : public BatchControllerStub { grpc::ClientContext& context, Options const& options, google::cloud::dataproc::v1::DeleteBatchRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataproc/v1/internal/cluster_controller_auth_decorator.cc b/google/cloud/dataproc/v1/internal/cluster_controller_auth_decorator.cc index b8d53e9d1cb5f..1d87156b3ec54 100644 --- a/google/cloud/dataproc/v1/internal/cluster_controller_auth_decorator.cc +++ b/google/cloud/dataproc/v1/internal/cluster_controller_auth_decorator.cc @@ -217,6 +217,31 @@ StatusOr ClusterControllerAuth::DiagnoseCluster( return child_->DiagnoseCluster(context, options, request); } +StatusOr ClusterControllerAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr ClusterControllerAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +ClusterControllerAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> ClusterControllerAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/cluster_controller_auth_decorator.h b/google/cloud/dataproc/v1/internal/cluster_controller_auth_decorator.h index cffba009fb76b..55bc19eafb058 100644 --- a/google/cloud/dataproc/v1/internal/cluster_controller_auth_decorator.h +++ b/google/cloud/dataproc/v1/internal/cluster_controller_auth_decorator.h @@ -115,6 +115,18 @@ class ClusterControllerAuth : public ClusterControllerStub { google::cloud::dataproc::v1::DiagnoseClusterRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataproc/v1/internal/cluster_controller_connection_impl.cc b/google/cloud/dataproc/v1/internal/cluster_controller_connection_impl.cc index 3d11f82f009b8..aeb7f1b4fc79f 100644 --- a/google/cloud/dataproc/v1/internal/cluster_controller_connection_impl.cc +++ b/google/cloud/dataproc/v1/internal/cluster_controller_connection_impl.cc @@ -664,6 +664,46 @@ ClusterControllerConnectionImpl::DiagnoseCluster( polling_policy(*current), __func__); } +StatusOr ClusterControllerConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr ClusterControllerConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +ClusterControllerConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataproc_v1_internal } // namespace cloud diff --git a/google/cloud/dataproc/v1/internal/cluster_controller_connection_impl.h b/google/cloud/dataproc/v1/internal/cluster_controller_connection_impl.h index b27e8ca766dbb..f453e12d7c8df 100644 --- a/google/cloud/dataproc/v1/internal/cluster_controller_connection_impl.h +++ b/google/cloud/dataproc/v1/internal/cluster_controller_connection_impl.h @@ -126,6 +126,15 @@ class ClusterControllerConnectionImpl future> DiagnoseCluster(google::longrunning::Operation const& operation) override; + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dataproc/v1/internal/cluster_controller_logging_decorator.cc b/google/cloud/dataproc/v1/internal/cluster_controller_logging_decorator.cc index 2e9164041b8b4..01a8d5bc43f5c 100644 --- a/google/cloud/dataproc/v1/internal/cluster_controller_logging_decorator.cc +++ b/google/cloud/dataproc/v1/internal/cluster_controller_logging_decorator.cc @@ -239,6 +239,40 @@ ClusterControllerLogging::DiagnoseCluster( context, options, request, __func__, tracing_options_); } +StatusOr ClusterControllerLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ClusterControllerLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ClusterControllerLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ClusterControllerLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/cluster_controller_logging_decorator.h b/google/cloud/dataproc/v1/internal/cluster_controller_logging_decorator.h index 83cfa81a0d8d8..96e79b4d520e5 100644 --- a/google/cloud/dataproc/v1/internal/cluster_controller_logging_decorator.h +++ b/google/cloud/dataproc/v1/internal/cluster_controller_logging_decorator.h @@ -115,6 +115,18 @@ class ClusterControllerLogging : public ClusterControllerStub { google::cloud::dataproc::v1::DiagnoseClusterRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataproc/v1/internal/cluster_controller_metadata_decorator.cc b/google/cloud/dataproc/v1/internal/cluster_controller_metadata_decorator.cc index e3539c10c1a9c..0052abef65134 100644 --- a/google/cloud/dataproc/v1/internal/cluster_controller_metadata_decorator.cc +++ b/google/cloud/dataproc/v1/internal/cluster_controller_metadata_decorator.cc @@ -237,6 +237,34 @@ ClusterControllerMetadata::DiagnoseCluster( return child_->DiagnoseCluster(context, options, request); } +StatusOr ClusterControllerMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr ClusterControllerMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +ClusterControllerMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> ClusterControllerMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/cluster_controller_metadata_decorator.h b/google/cloud/dataproc/v1/internal/cluster_controller_metadata_decorator.h index 4dda58cb2d58e..470fe72a957ee 100644 --- a/google/cloud/dataproc/v1/internal/cluster_controller_metadata_decorator.h +++ b/google/cloud/dataproc/v1/internal/cluster_controller_metadata_decorator.h @@ -116,6 +116,18 @@ class ClusterControllerMetadata : public ClusterControllerStub { google::cloud::dataproc::v1::DiagnoseClusterRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataproc/v1/internal/cluster_controller_stub.cc b/google/cloud/dataproc/v1/internal/cluster_controller_stub.cc index 062fbc3b26871..3f42bc3647d56 100644 --- a/google/cloud/dataproc/v1/internal/cluster_controller_stub.cc +++ b/google/cloud/dataproc/v1/internal/cluster_controller_stub.cc @@ -235,6 +235,41 @@ DefaultClusterControllerStub::DiagnoseCluster( return response; } +StatusOr DefaultClusterControllerStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultClusterControllerStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultClusterControllerStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultClusterControllerStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/cluster_controller_stub.h b/google/cloud/dataproc/v1/internal/cluster_controller_stub.h index 42cc039fb4b75..dd23fde4b3176 100644 --- a/google/cloud/dataproc/v1/internal/cluster_controller_stub.h +++ b/google/cloud/dataproc/v1/internal/cluster_controller_stub.h @@ -26,6 +26,8 @@ #include "google/cloud/version.h" #include #include +#include +#include #include #include #include @@ -108,6 +110,19 @@ class ClusterControllerStub { grpc::ClientContext& context, Options options, google::cloud::dataproc::v1::DiagnoseClusterRequest const& request) = 0; + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -127,9 +142,12 @@ class DefaultClusterControllerStub : public ClusterControllerStub { std::unique_ptr< google::cloud::dataproc::v1::ClusterController::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + operations_(std::move(operations)) {} future> AsyncCreateCluster( google::cloud::CompletionQueue& cq, @@ -207,6 +225,18 @@ class DefaultClusterControllerStub : public ClusterControllerStub { google::cloud::dataproc::v1::DiagnoseClusterRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -222,6 +252,7 @@ class DefaultClusterControllerStub : public ClusterControllerStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/dataproc/v1/internal/cluster_controller_stub_factory.cc b/google/cloud/dataproc/v1/internal/cluster_controller_stub_factory.cc index cbb499cdb5a71..67ac1fa847c25 100644 --- a/google/cloud/dataproc/v1/internal/cluster_controller_stub_factory.cc +++ b/google/cloud/dataproc/v1/internal/cluster_controller_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,9 +45,10 @@ std::shared_ptr CreateDefaultClusterControllerStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataproc::v1::ClusterController::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/dataproc/v1/internal/cluster_controller_tracing_connection.cc b/google/cloud/dataproc/v1/internal/cluster_controller_tracing_connection.cc index 94d5ce8a1dc23..4cdb864f145c7 100644 --- a/google/cloud/dataproc/v1/internal/cluster_controller_tracing_connection.cc +++ b/google/cloud/dataproc/v1/internal/cluster_controller_tracing_connection.cc @@ -222,6 +222,33 @@ ClusterControllerTracingConnection::DiagnoseCluster( return internal::EndSpan(std::move(span), child_->DiagnoseCluster(operation)); } +StatusOr +ClusterControllerTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::ClusterControllerConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +ClusterControllerTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::ClusterControllerConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +ClusterControllerTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::ClusterControllerConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dataproc/v1/internal/cluster_controller_tracing_connection.h b/google/cloud/dataproc/v1/internal/cluster_controller_tracing_connection.h index e077508f98357..d11565af2a65e 100644 --- a/google/cloud/dataproc/v1/internal/cluster_controller_tracing_connection.h +++ b/google/cloud/dataproc/v1/internal/cluster_controller_tracing_connection.h @@ -114,6 +114,15 @@ class ClusterControllerTracingConnection future> DiagnoseCluster(google::longrunning::Operation const& operation) override; + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dataproc/v1/internal/cluster_controller_tracing_stub.cc b/google/cloud/dataproc/v1/internal/cluster_controller_tracing_stub.cc index b6e64b50992f9..eb24b4b678912 100644 --- a/google/cloud/dataproc/v1/internal/cluster_controller_tracing_stub.cc +++ b/google/cloud/dataproc/v1/internal/cluster_controller_tracing_stub.cc @@ -213,6 +213,40 @@ ClusterControllerTracingStub::DiagnoseCluster( child_->DiagnoseCluster(context, options, request)); } +StatusOr ClusterControllerTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.ClusterController", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr ClusterControllerTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.ClusterController", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +ClusterControllerTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.ClusterController", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> ClusterControllerTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/cluster_controller_tracing_stub.h b/google/cloud/dataproc/v1/internal/cluster_controller_tracing_stub.h index 7fa6dfd5cc34c..d5972e140dc04 100644 --- a/google/cloud/dataproc/v1/internal/cluster_controller_tracing_stub.h +++ b/google/cloud/dataproc/v1/internal/cluster_controller_tracing_stub.h @@ -115,6 +115,18 @@ class ClusterControllerTracingStub : public ClusterControllerStub { google::cloud::dataproc::v1::DiagnoseClusterRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataproc/v1/internal/job_controller_auth_decorator.cc b/google/cloud/dataproc/v1/internal/job_controller_auth_decorator.cc index 42366b9fd466c..1cc11b00725d5 100644 --- a/google/cloud/dataproc/v1/internal/job_controller_auth_decorator.cc +++ b/google/cloud/dataproc/v1/internal/job_controller_auth_decorator.cc @@ -109,6 +109,31 @@ Status JobControllerAuth::DeleteJob( return child_->DeleteJob(context, options, request); } +StatusOr JobControllerAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr JobControllerAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +JobControllerAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> JobControllerAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/job_controller_auth_decorator.h b/google/cloud/dataproc/v1/internal/job_controller_auth_decorator.h index 2a001bc86c8b0..0b4c86ca9631c 100644 --- a/google/cloud/dataproc/v1/internal/job_controller_auth_decorator.h +++ b/google/cloud/dataproc/v1/internal/job_controller_auth_decorator.h @@ -73,6 +73,18 @@ class JobControllerAuth : public JobControllerStub { grpc::ClientContext& context, Options const& options, google::cloud::dataproc::v1::DeleteJobRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataproc/v1/internal/job_controller_connection_impl.cc b/google/cloud/dataproc/v1/internal/job_controller_connection_impl.cc index d6fd36839c970..efb716f1f4e50 100644 --- a/google/cloud/dataproc/v1/internal/job_controller_connection_impl.cc +++ b/google/cloud/dataproc/v1/internal/job_controller_connection_impl.cc @@ -254,6 +254,46 @@ Status JobControllerConnectionImpl::DeleteJob( *current, request, __func__); } +StatusOr JobControllerConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr JobControllerConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +JobControllerConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataproc_v1_internal } // namespace cloud diff --git a/google/cloud/dataproc/v1/internal/job_controller_connection_impl.h b/google/cloud/dataproc/v1/internal/job_controller_connection_impl.h index d76c259a70446..87101d053154d 100644 --- a/google/cloud/dataproc/v1/internal/job_controller_connection_impl.h +++ b/google/cloud/dataproc/v1/internal/job_controller_connection_impl.h @@ -80,6 +80,15 @@ class JobControllerConnectionImpl Status DeleteJob( google::cloud::dataproc::v1::DeleteJobRequest const& request) override; + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dataproc/v1/internal/job_controller_logging_decorator.cc b/google/cloud/dataproc/v1/internal/job_controller_logging_decorator.cc index 5ed5133beb18d..45bfc48ac55c1 100644 --- a/google/cloud/dataproc/v1/internal/job_controller_logging_decorator.cc +++ b/google/cloud/dataproc/v1/internal/job_controller_logging_decorator.cc @@ -132,6 +132,40 @@ Status JobControllerLogging::DeleteJob( context, options, request, __func__, tracing_options_); } +StatusOr JobControllerLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr JobControllerLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +JobControllerLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> JobControllerLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/job_controller_logging_decorator.h b/google/cloud/dataproc/v1/internal/job_controller_logging_decorator.h index 422e064ce8477..35455855f904b 100644 --- a/google/cloud/dataproc/v1/internal/job_controller_logging_decorator.h +++ b/google/cloud/dataproc/v1/internal/job_controller_logging_decorator.h @@ -73,6 +73,18 @@ class JobControllerLogging : public JobControllerStub { grpc::ClientContext& context, Options const& options, google::cloud::dataproc::v1::DeleteJobRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataproc/v1/internal/job_controller_metadata_decorator.cc b/google/cloud/dataproc/v1/internal/job_controller_metadata_decorator.cc index ab8d97cb1b198..81c1292f81721 100644 --- a/google/cloud/dataproc/v1/internal/job_controller_metadata_decorator.cc +++ b/google/cloud/dataproc/v1/internal/job_controller_metadata_decorator.cc @@ -134,6 +134,34 @@ Status JobControllerMetadata::DeleteJob( return child_->DeleteJob(context, options, request); } +StatusOr JobControllerMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr JobControllerMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +JobControllerMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> JobControllerMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/job_controller_metadata_decorator.h b/google/cloud/dataproc/v1/internal/job_controller_metadata_decorator.h index dcc86dbf4b3ce..839750999fb1f 100644 --- a/google/cloud/dataproc/v1/internal/job_controller_metadata_decorator.h +++ b/google/cloud/dataproc/v1/internal/job_controller_metadata_decorator.h @@ -73,6 +73,18 @@ class JobControllerMetadata : public JobControllerStub { grpc::ClientContext& context, Options const& options, google::cloud::dataproc::v1::DeleteJobRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataproc/v1/internal/job_controller_stub.cc b/google/cloud/dataproc/v1/internal/job_controller_stub.cc index 8cc81c060bb5c..a72f82616f698 100644 --- a/google/cloud/dataproc/v1/internal/job_controller_stub.cc +++ b/google/cloud/dataproc/v1/internal/job_controller_stub.cc @@ -128,6 +128,41 @@ Status DefaultJobControllerStub::DeleteJob( return google::cloud::Status(); } +StatusOr DefaultJobControllerStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultJobControllerStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultJobControllerStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultJobControllerStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/job_controller_stub.h b/google/cloud/dataproc/v1/internal/job_controller_stub.h index f0fc7f02c2152..9f55ca83e63f8 100644 --- a/google/cloud/dataproc/v1/internal/job_controller_stub.h +++ b/google/cloud/dataproc/v1/internal/job_controller_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -73,6 +75,19 @@ class JobControllerStub { grpc::ClientContext& context, Options const& options, google::cloud::dataproc::v1::DeleteJobRequest const& request) = 0; + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -91,9 +106,12 @@ class DefaultJobControllerStub : public JobControllerStub { DefaultJobControllerStub( std::unique_ptr grpc_stub, + std::unique_ptr iampolicy_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + operations_(std::move(operations)) {} StatusOr SubmitJob( grpc::ClientContext& context, Options const& options, @@ -129,6 +147,18 @@ class DefaultJobControllerStub : public JobControllerStub { grpc::ClientContext& context, Options const& options, google::cloud::dataproc::v1::DeleteJobRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -144,6 +174,7 @@ class DefaultJobControllerStub : public JobControllerStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/dataproc/v1/internal/job_controller_stub_factory.cc b/google/cloud/dataproc/v1/internal/job_controller_stub_factory.cc index 26223956fb538..08a019485692b 100644 --- a/google/cloud/dataproc/v1/internal/job_controller_stub_factory.cc +++ b/google/cloud/dataproc/v1/internal/job_controller_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,9 +45,10 @@ std::shared_ptr CreateDefaultJobControllerStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataproc::v1::JobController::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/dataproc/v1/internal/job_controller_tracing_connection.cc b/google/cloud/dataproc/v1/internal/job_controller_tracing_connection.cc index 027e33842154e..787f580dfd5cb 100644 --- a/google/cloud/dataproc/v1/internal/job_controller_tracing_connection.cc +++ b/google/cloud/dataproc/v1/internal/job_controller_tracing_connection.cc @@ -118,6 +118,31 @@ Status JobControllerTracingConnection::DeleteJob( return internal::EndSpan(*span, child_->DeleteJob(request)); } +StatusOr JobControllerTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("dataproc_v1::JobControllerConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr JobControllerTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("dataproc_v1::JobControllerConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +JobControllerTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::JobControllerConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dataproc/v1/internal/job_controller_tracing_connection.h b/google/cloud/dataproc/v1/internal/job_controller_tracing_connection.h index 53ad010cc2a3b..46eedc2b0b271 100644 --- a/google/cloud/dataproc/v1/internal/job_controller_tracing_connection.h +++ b/google/cloud/dataproc/v1/internal/job_controller_tracing_connection.h @@ -68,6 +68,15 @@ class JobControllerTracingConnection Status DeleteJob( google::cloud::dataproc::v1::DeleteJobRequest const& request) override; + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dataproc/v1/internal/job_controller_tracing_stub.cc b/google/cloud/dataproc/v1/internal/job_controller_tracing_stub.cc index cc66939b8be9a..55f6901b70db9 100644 --- a/google/cloud/dataproc/v1/internal/job_controller_tracing_stub.cc +++ b/google/cloud/dataproc/v1/internal/job_controller_tracing_stub.cc @@ -126,6 +126,40 @@ Status JobControllerTracingStub::DeleteJob( child_->DeleteJob(context, options, request)); } +StatusOr JobControllerTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataproc.v1.JobController", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr JobControllerTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataproc.v1.JobController", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +JobControllerTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dataproc.v1.JobController", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> JobControllerTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/job_controller_tracing_stub.h b/google/cloud/dataproc/v1/internal/job_controller_tracing_stub.h index ba5663000a9e6..3693564d739ce 100644 --- a/google/cloud/dataproc/v1/internal/job_controller_tracing_stub.h +++ b/google/cloud/dataproc/v1/internal/job_controller_tracing_stub.h @@ -72,6 +72,18 @@ class JobControllerTracingStub : public JobControllerStub { grpc::ClientContext& context, Options const& options, google::cloud::dataproc::v1::DeleteJobRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataproc/v1/internal/node_group_controller_auth_decorator.cc b/google/cloud/dataproc/v1/internal/node_group_controller_auth_decorator.cc index b6105056f818f..fedd8eda8baae 100644 --- a/google/cloud/dataproc/v1/internal/node_group_controller_auth_decorator.cc +++ b/google/cloud/dataproc/v1/internal/node_group_controller_auth_decorator.cc @@ -98,6 +98,31 @@ NodeGroupControllerAuth::GetNodeGroup( return child_->GetNodeGroup(context, options, request); } +StatusOr NodeGroupControllerAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr NodeGroupControllerAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +NodeGroupControllerAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> NodeGroupControllerAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/node_group_controller_auth_decorator.h b/google/cloud/dataproc/v1/internal/node_group_controller_auth_decorator.h index 20992415212e2..bb82b958b0368 100644 --- a/google/cloud/dataproc/v1/internal/node_group_controller_auth_decorator.h +++ b/google/cloud/dataproc/v1/internal/node_group_controller_auth_decorator.h @@ -67,6 +67,18 @@ class NodeGroupControllerAuth : public NodeGroupControllerStub { grpc::ClientContext& context, Options const& options, google::cloud::dataproc::v1::GetNodeGroupRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataproc/v1/internal/node_group_controller_connection_impl.cc b/google/cloud/dataproc/v1/internal/node_group_controller_connection_impl.cc index 69711aef70f54..6064aabd6153d 100644 --- a/google/cloud/dataproc/v1/internal/node_group_controller_connection_impl.cc +++ b/google/cloud/dataproc/v1/internal/node_group_controller_connection_impl.cc @@ -264,6 +264,48 @@ NodeGroupControllerConnectionImpl::GetNodeGroup( *current, request, __func__); } +StatusOr +NodeGroupControllerConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +NodeGroupControllerConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +NodeGroupControllerConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataproc_v1_internal } // namespace cloud diff --git a/google/cloud/dataproc/v1/internal/node_group_controller_connection_impl.h b/google/cloud/dataproc/v1/internal/node_group_controller_connection_impl.h index 0c068ed991810..03037d9848196 100644 --- a/google/cloud/dataproc/v1/internal/node_group_controller_connection_impl.h +++ b/google/cloud/dataproc/v1/internal/node_group_controller_connection_impl.h @@ -78,6 +78,15 @@ class NodeGroupControllerConnectionImpl StatusOr GetNodeGroup( google::cloud::dataproc::v1::GetNodeGroupRequest const& request) override; + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dataproc/v1/internal/node_group_controller_logging_decorator.cc b/google/cloud/dataproc/v1/internal/node_group_controller_logging_decorator.cc index acce39c44b7c8..d75dbf8b32c09 100644 --- a/google/cloud/dataproc/v1/internal/node_group_controller_logging_decorator.cc +++ b/google/cloud/dataproc/v1/internal/node_group_controller_logging_decorator.cc @@ -111,6 +111,40 @@ NodeGroupControllerLogging::GetNodeGroup( context, options, request, __func__, tracing_options_); } +StatusOr NodeGroupControllerLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr NodeGroupControllerLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +NodeGroupControllerLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> NodeGroupControllerLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/node_group_controller_logging_decorator.h b/google/cloud/dataproc/v1/internal/node_group_controller_logging_decorator.h index 6cc320a1546a1..c2a1869b72619 100644 --- a/google/cloud/dataproc/v1/internal/node_group_controller_logging_decorator.h +++ b/google/cloud/dataproc/v1/internal/node_group_controller_logging_decorator.h @@ -67,6 +67,18 @@ class NodeGroupControllerLogging : public NodeGroupControllerStub { grpc::ClientContext& context, Options const& options, google::cloud::dataproc::v1::GetNodeGroupRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataproc/v1/internal/node_group_controller_metadata_decorator.cc b/google/cloud/dataproc/v1/internal/node_group_controller_metadata_decorator.cc index 2228080639aea..e1a1e8dc91683 100644 --- a/google/cloud/dataproc/v1/internal/node_group_controller_metadata_decorator.cc +++ b/google/cloud/dataproc/v1/internal/node_group_controller_metadata_decorator.cc @@ -95,6 +95,34 @@ NodeGroupControllerMetadata::GetNodeGroup( return child_->GetNodeGroup(context, options, request); } +StatusOr NodeGroupControllerMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr NodeGroupControllerMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +NodeGroupControllerMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> NodeGroupControllerMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/node_group_controller_metadata_decorator.h b/google/cloud/dataproc/v1/internal/node_group_controller_metadata_decorator.h index 85d2355a682a1..0c55bf444f03a 100644 --- a/google/cloud/dataproc/v1/internal/node_group_controller_metadata_decorator.h +++ b/google/cloud/dataproc/v1/internal/node_group_controller_metadata_decorator.h @@ -68,6 +68,18 @@ class NodeGroupControllerMetadata : public NodeGroupControllerStub { grpc::ClientContext& context, Options const& options, google::cloud::dataproc::v1::GetNodeGroupRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataproc/v1/internal/node_group_controller_stub.cc b/google/cloud/dataproc/v1/internal/node_group_controller_stub.cc index 9192f2ecb75d5..79a547e388dc8 100644 --- a/google/cloud/dataproc/v1/internal/node_group_controller_stub.cc +++ b/google/cloud/dataproc/v1/internal/node_group_controller_stub.cc @@ -103,6 +103,41 @@ DefaultNodeGroupControllerStub::GetNodeGroup( return response; } +StatusOr DefaultNodeGroupControllerStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultNodeGroupControllerStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultNodeGroupControllerStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultNodeGroupControllerStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/node_group_controller_stub.h b/google/cloud/dataproc/v1/internal/node_group_controller_stub.h index aa7b9a7d7ee58..0750f4d1858e7 100644 --- a/google/cloud/dataproc/v1/internal/node_group_controller_stub.h +++ b/google/cloud/dataproc/v1/internal/node_group_controller_stub.h @@ -26,6 +26,8 @@ #include "google/cloud/version.h" #include #include +#include +#include #include #include #include @@ -63,6 +65,19 @@ class NodeGroupControllerStub { grpc::ClientContext& context, Options const& options, google::cloud::dataproc::v1::GetNodeGroupRequest const& request) = 0; + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -82,9 +97,12 @@ class DefaultNodeGroupControllerStub : public NodeGroupControllerStub { std::unique_ptr< google::cloud::dataproc::v1::NodeGroupController::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + operations_(std::move(operations)) {} future> AsyncCreateNodeGroup( google::cloud::CompletionQueue& cq, @@ -114,6 +132,18 @@ class DefaultNodeGroupControllerStub : public NodeGroupControllerStub { grpc::ClientContext& context, Options const& options, google::cloud::dataproc::v1::GetNodeGroupRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -130,6 +160,7 @@ class DefaultNodeGroupControllerStub : public NodeGroupControllerStub { std::unique_ptr< google::cloud::dataproc::v1::NodeGroupController::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/dataproc/v1/internal/node_group_controller_stub_factory.cc b/google/cloud/dataproc/v1/internal/node_group_controller_stub_factory.cc index 57198ee5205f6..f5fcd92476eca 100644 --- a/google/cloud/dataproc/v1/internal/node_group_controller_stub_factory.cc +++ b/google/cloud/dataproc/v1/internal/node_group_controller_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,9 +45,10 @@ std::shared_ptr CreateDefaultNodeGroupControllerStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataproc::v1::NodeGroupController::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/dataproc/v1/internal/node_group_controller_tracing_connection.cc b/google/cloud/dataproc/v1/internal/node_group_controller_tracing_connection.cc index c8a56af264f95..cba3f70f41819 100644 --- a/google/cloud/dataproc/v1/internal/node_group_controller_tracing_connection.cc +++ b/google/cloud/dataproc/v1/internal/node_group_controller_tracing_connection.cc @@ -99,6 +99,33 @@ NodeGroupControllerTracingConnection::GetNodeGroup( return internal::EndSpan(*span, child_->GetNodeGroup(request)); } +StatusOr +NodeGroupControllerTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::NodeGroupControllerConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +NodeGroupControllerTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::NodeGroupControllerConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +NodeGroupControllerTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::NodeGroupControllerConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dataproc/v1/internal/node_group_controller_tracing_connection.h b/google/cloud/dataproc/v1/internal/node_group_controller_tracing_connection.h index e0c01b9519f76..2d9954ea1c7af 100644 --- a/google/cloud/dataproc/v1/internal/node_group_controller_tracing_connection.h +++ b/google/cloud/dataproc/v1/internal/node_group_controller_tracing_connection.h @@ -67,6 +67,15 @@ class NodeGroupControllerTracingConnection StatusOr GetNodeGroup( google::cloud::dataproc::v1::GetNodeGroupRequest const& request) override; + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dataproc/v1/internal/node_group_controller_tracing_stub.cc b/google/cloud/dataproc/v1/internal/node_group_controller_tracing_stub.cc index b44b2694a25d0..39e7d8bd96bdd 100644 --- a/google/cloud/dataproc/v1/internal/node_group_controller_tracing_stub.cc +++ b/google/cloud/dataproc/v1/internal/node_group_controller_tracing_stub.cc @@ -98,6 +98,40 @@ NodeGroupControllerTracingStub::GetNodeGroup( child_->GetNodeGroup(context, options, request)); } +StatusOr NodeGroupControllerTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.NodeGroupController", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr NodeGroupControllerTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.NodeGroupController", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +NodeGroupControllerTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.NodeGroupController", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> NodeGroupControllerTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/node_group_controller_tracing_stub.h b/google/cloud/dataproc/v1/internal/node_group_controller_tracing_stub.h index c8d5f19817aaf..4e7202317f32c 100644 --- a/google/cloud/dataproc/v1/internal/node_group_controller_tracing_stub.h +++ b/google/cloud/dataproc/v1/internal/node_group_controller_tracing_stub.h @@ -67,6 +67,18 @@ class NodeGroupControllerTracingStub : public NodeGroupControllerStub { grpc::ClientContext& context, Options const& options, google::cloud::dataproc::v1::GetNodeGroupRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataproc/v1/internal/session_controller_auth_decorator.cc b/google/cloud/dataproc/v1/internal/session_controller_auth_decorator.cc index ed0b376f9dab3..72548ad2b6cd0 100644 --- a/google/cloud/dataproc/v1/internal/session_controller_auth_decorator.cc +++ b/google/cloud/dataproc/v1/internal/session_controller_auth_decorator.cc @@ -134,6 +134,31 @@ StatusOr SessionControllerAuth::DeleteSession( return child_->DeleteSession(context, options, request); } +StatusOr SessionControllerAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr SessionControllerAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +SessionControllerAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> SessionControllerAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/session_controller_auth_decorator.h b/google/cloud/dataproc/v1/internal/session_controller_auth_decorator.h index 6329f9dbd690c..feb7126a32c8c 100644 --- a/google/cloud/dataproc/v1/internal/session_controller_auth_decorator.h +++ b/google/cloud/dataproc/v1/internal/session_controller_auth_decorator.h @@ -83,6 +83,18 @@ class SessionControllerAuth : public SessionControllerStub { google::cloud::dataproc::v1::DeleteSessionRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataproc/v1/internal/session_controller_connection_impl.cc b/google/cloud/dataproc/v1/internal/session_controller_connection_impl.cc index 1e6e28b91f4df..d3edba8eb1a5f 100644 --- a/google/cloud/dataproc/v1/internal/session_controller_connection_impl.cc +++ b/google/cloud/dataproc/v1/internal/session_controller_connection_impl.cc @@ -389,6 +389,46 @@ SessionControllerConnectionImpl::DeleteSession( polling_policy(*current), __func__); } +StatusOr SessionControllerConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr SessionControllerConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +SessionControllerConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataproc_v1_internal } // namespace cloud diff --git a/google/cloud/dataproc/v1/internal/session_controller_connection_impl.h b/google/cloud/dataproc/v1/internal/session_controller_connection_impl.h index d3742fb8a8a5f..14a2ad04c1d42 100644 --- a/google/cloud/dataproc/v1/internal/session_controller_connection_impl.h +++ b/google/cloud/dataproc/v1/internal/session_controller_connection_impl.h @@ -94,6 +94,15 @@ class SessionControllerConnectionImpl future> DeleteSession( google::longrunning::Operation const& operation) override; + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dataproc/v1/internal/session_controller_logging_decorator.cc b/google/cloud/dataproc/v1/internal/session_controller_logging_decorator.cc index df83e3187c528..947a8d64cfb59 100644 --- a/google/cloud/dataproc/v1/internal/session_controller_logging_decorator.cc +++ b/google/cloud/dataproc/v1/internal/session_controller_logging_decorator.cc @@ -151,6 +151,40 @@ SessionControllerLogging::DeleteSession( context, options, request, __func__, tracing_options_); } +StatusOr SessionControllerLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr SessionControllerLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +SessionControllerLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> SessionControllerLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/session_controller_logging_decorator.h b/google/cloud/dataproc/v1/internal/session_controller_logging_decorator.h index 4a84eb013e594..2a5c32e460b31 100644 --- a/google/cloud/dataproc/v1/internal/session_controller_logging_decorator.h +++ b/google/cloud/dataproc/v1/internal/session_controller_logging_decorator.h @@ -83,6 +83,18 @@ class SessionControllerLogging : public SessionControllerStub { google::cloud::dataproc::v1::DeleteSessionRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataproc/v1/internal/session_controller_metadata_decorator.cc b/google/cloud/dataproc/v1/internal/session_controller_metadata_decorator.cc index 2a917ac3a15f8..1d160875ac10b 100644 --- a/google/cloud/dataproc/v1/internal/session_controller_metadata_decorator.cc +++ b/google/cloud/dataproc/v1/internal/session_controller_metadata_decorator.cc @@ -125,6 +125,34 @@ SessionControllerMetadata::DeleteSession( return child_->DeleteSession(context, options, request); } +StatusOr SessionControllerMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr SessionControllerMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +SessionControllerMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> SessionControllerMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/session_controller_metadata_decorator.h b/google/cloud/dataproc/v1/internal/session_controller_metadata_decorator.h index 71fa84a9005a3..13456528ed544 100644 --- a/google/cloud/dataproc/v1/internal/session_controller_metadata_decorator.h +++ b/google/cloud/dataproc/v1/internal/session_controller_metadata_decorator.h @@ -84,6 +84,18 @@ class SessionControllerMetadata : public SessionControllerStub { google::cloud::dataproc::v1::DeleteSessionRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataproc/v1/internal/session_controller_stub.cc b/google/cloud/dataproc/v1/internal/session_controller_stub.cc index fffac091c3e07..9d1b91c79f628 100644 --- a/google/cloud/dataproc/v1/internal/session_controller_stub.cc +++ b/google/cloud/dataproc/v1/internal/session_controller_stub.cc @@ -146,6 +146,41 @@ DefaultSessionControllerStub::DeleteSession( return response; } +StatusOr DefaultSessionControllerStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultSessionControllerStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultSessionControllerStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultSessionControllerStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/session_controller_stub.h b/google/cloud/dataproc/v1/internal/session_controller_stub.h index 6c24cfc0497ff..ea420c845d17c 100644 --- a/google/cloud/dataproc/v1/internal/session_controller_stub.h +++ b/google/cloud/dataproc/v1/internal/session_controller_stub.h @@ -26,6 +26,8 @@ #include "google/cloud/version.h" #include #include +#include +#include #include #include #include @@ -79,6 +81,19 @@ class SessionControllerStub { grpc::ClientContext& context, Options options, google::cloud::dataproc::v1::DeleteSessionRequest const& request) = 0; + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -98,9 +113,12 @@ class DefaultSessionControllerStub : public SessionControllerStub { std::unique_ptr< google::cloud::dataproc::v1::SessionController::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + operations_(std::move(operations)) {} future> AsyncCreateSession( google::cloud::CompletionQueue& cq, @@ -146,6 +164,18 @@ class DefaultSessionControllerStub : public SessionControllerStub { google::cloud::dataproc::v1::DeleteSessionRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -161,6 +191,7 @@ class DefaultSessionControllerStub : public SessionControllerStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/dataproc/v1/internal/session_controller_stub_factory.cc b/google/cloud/dataproc/v1/internal/session_controller_stub_factory.cc index 22731d3c5bd4d..2cd98a54fa1ec 100644 --- a/google/cloud/dataproc/v1/internal/session_controller_stub_factory.cc +++ b/google/cloud/dataproc/v1/internal/session_controller_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,9 +45,10 @@ std::shared_ptr CreateDefaultSessionControllerStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataproc::v1::SessionController::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/dataproc/v1/internal/session_controller_tracing_connection.cc b/google/cloud/dataproc/v1/internal/session_controller_tracing_connection.cc index 12fbca6648448..dc13fb9ee1bf2 100644 --- a/google/cloud/dataproc/v1/internal/session_controller_tracing_connection.cc +++ b/google/cloud/dataproc/v1/internal/session_controller_tracing_connection.cc @@ -139,6 +139,33 @@ SessionControllerTracingConnection::DeleteSession( return internal::EndSpan(std::move(span), child_->DeleteSession(operation)); } +StatusOr +SessionControllerTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::SessionControllerConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +SessionControllerTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::SessionControllerConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +SessionControllerTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::SessionControllerConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dataproc/v1/internal/session_controller_tracing_connection.h b/google/cloud/dataproc/v1/internal/session_controller_tracing_connection.h index f0f5522fa0305..0b1904c34d981 100644 --- a/google/cloud/dataproc/v1/internal/session_controller_tracing_connection.h +++ b/google/cloud/dataproc/v1/internal/session_controller_tracing_connection.h @@ -82,6 +82,15 @@ class SessionControllerTracingConnection future> DeleteSession( google::longrunning::Operation const& operation) override; + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dataproc/v1/internal/session_controller_tracing_stub.cc b/google/cloud/dataproc/v1/internal/session_controller_tracing_stub.cc index e40a419d0e0aa..cf793e435884b 100644 --- a/google/cloud/dataproc/v1/internal/session_controller_tracing_stub.cc +++ b/google/cloud/dataproc/v1/internal/session_controller_tracing_stub.cc @@ -135,6 +135,40 @@ SessionControllerTracingStub::DeleteSession( child_->DeleteSession(context, options, request)); } +StatusOr SessionControllerTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.SessionController", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr SessionControllerTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.SessionController", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +SessionControllerTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.SessionController", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> SessionControllerTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/session_controller_tracing_stub.h b/google/cloud/dataproc/v1/internal/session_controller_tracing_stub.h index ca50198cfbe80..dc30f8bc08b6a 100644 --- a/google/cloud/dataproc/v1/internal/session_controller_tracing_stub.h +++ b/google/cloud/dataproc/v1/internal/session_controller_tracing_stub.h @@ -83,6 +83,18 @@ class SessionControllerTracingStub : public SessionControllerStub { google::cloud::dataproc::v1::DeleteSessionRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataproc/v1/internal/session_template_controller_auth_decorator.cc b/google/cloud/dataproc/v1/internal/session_template_controller_auth_decorator.cc index eb3c46188032e..de7c09574a776 100644 --- a/google/cloud/dataproc/v1/internal/session_template_controller_auth_decorator.cc +++ b/google/cloud/dataproc/v1/internal/session_template_controller_auth_decorator.cc @@ -75,6 +75,31 @@ Status SessionTemplateControllerAuth::DeleteSessionTemplate( return child_->DeleteSessionTemplate(context, options, request); } +StatusOr SessionTemplateControllerAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr SessionTemplateControllerAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +SessionTemplateControllerAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataproc_v1_internal } // namespace cloud diff --git a/google/cloud/dataproc/v1/internal/session_template_controller_auth_decorator.h b/google/cloud/dataproc/v1/internal/session_template_controller_auth_decorator.h index 8395d347d1e01..b5b5ecc1109e7 100644 --- a/google/cloud/dataproc/v1/internal/session_template_controller_auth_decorator.h +++ b/google/cloud/dataproc/v1/internal/session_template_controller_auth_decorator.h @@ -64,6 +64,18 @@ class SessionTemplateControllerAuth : public SessionTemplateControllerStub { google::cloud::dataproc::v1::DeleteSessionTemplateRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/dataproc/v1/internal/session_template_controller_connection_impl.cc b/google/cloud/dataproc/v1/internal/session_template_controller_connection_impl.cc index f6baf6ff251ba..03faf055ef1da 100644 --- a/google/cloud/dataproc/v1/internal/session_template_controller_connection_impl.cc +++ b/google/cloud/dataproc/v1/internal/session_template_controller_connection_impl.cc @@ -163,6 +163,48 @@ Status SessionTemplateControllerConnectionImpl::DeleteSessionTemplate( *current, request, __func__); } +StatusOr +SessionTemplateControllerConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +SessionTemplateControllerConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +SessionTemplateControllerConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataproc_v1_internal } // namespace cloud diff --git a/google/cloud/dataproc/v1/internal/session_template_controller_connection_impl.h b/google/cloud/dataproc/v1/internal/session_template_controller_connection_impl.h index e7e8baa892d90..b0a3259dadea5 100644 --- a/google/cloud/dataproc/v1/internal/session_template_controller_connection_impl.h +++ b/google/cloud/dataproc/v1/internal/session_template_controller_connection_impl.h @@ -69,6 +69,15 @@ class SessionTemplateControllerConnectionImpl google::cloud::dataproc::v1::DeleteSessionTemplateRequest const& request) override; + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dataproc/v1/internal/session_template_controller_logging_decorator.cc b/google/cloud/dataproc/v1/internal/session_template_controller_logging_decorator.cc index 9b83e1a33fdff..1f8158770b1a1 100644 --- a/google/cloud/dataproc/v1/internal/session_template_controller_logging_decorator.cc +++ b/google/cloud/dataproc/v1/internal/session_template_controller_logging_decorator.cc @@ -99,6 +99,42 @@ Status SessionTemplateControllerLogging::DeleteSessionTemplate( context, options, request, __func__, tracing_options_); } +StatusOr +SessionTemplateControllerLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +SessionTemplateControllerLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +SessionTemplateControllerLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataproc_v1_internal } // namespace cloud diff --git a/google/cloud/dataproc/v1/internal/session_template_controller_logging_decorator.h b/google/cloud/dataproc/v1/internal/session_template_controller_logging_decorator.h index fcc74c4bdc15e..e2ac24d11667d 100644 --- a/google/cloud/dataproc/v1/internal/session_template_controller_logging_decorator.h +++ b/google/cloud/dataproc/v1/internal/session_template_controller_logging_decorator.h @@ -64,6 +64,18 @@ class SessionTemplateControllerLogging : public SessionTemplateControllerStub { google::cloud::dataproc::v1::DeleteSessionTemplateRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/dataproc/v1/internal/session_template_controller_metadata_decorator.cc b/google/cloud/dataproc/v1/internal/session_template_controller_metadata_decorator.cc index 6358a3426b52e..eecb14e0df202 100644 --- a/google/cloud/dataproc/v1/internal/session_template_controller_metadata_decorator.cc +++ b/google/cloud/dataproc/v1/internal/session_template_controller_metadata_decorator.cc @@ -90,6 +90,36 @@ Status SessionTemplateControllerMetadata::DeleteSessionTemplate( return child_->DeleteSessionTemplate(context, options, request); } +StatusOr +SessionTemplateControllerMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr +SessionTemplateControllerMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +SessionTemplateControllerMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + void SessionTemplateControllerMetadata::SetMetadata( grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/dataproc/v1/internal/session_template_controller_metadata_decorator.h b/google/cloud/dataproc/v1/internal/session_template_controller_metadata_decorator.h index 14391f8cbdcb7..4ba23e0a4bf0e 100644 --- a/google/cloud/dataproc/v1/internal/session_template_controller_metadata_decorator.h +++ b/google/cloud/dataproc/v1/internal/session_template_controller_metadata_decorator.h @@ -65,6 +65,18 @@ class SessionTemplateControllerMetadata : public SessionTemplateControllerStub { google::cloud::dataproc::v1::DeleteSessionTemplateRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/dataproc/v1/internal/session_template_controller_stub.cc b/google/cloud/dataproc/v1/internal/session_template_controller_stub.cc index a0fc63b4ac202..49343e3dacdf1 100644 --- a/google/cloud/dataproc/v1/internal/session_template_controller_stub.cc +++ b/google/cloud/dataproc/v1/internal/session_template_controller_stub.cc @@ -89,6 +89,43 @@ Status DefaultSessionTemplateControllerStub::DeleteSessionTemplate( return google::cloud::Status(); } +StatusOr +DefaultSessionTemplateControllerStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultSessionTemplateControllerStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultSessionTemplateControllerStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataproc_v1_internal } // namespace cloud diff --git a/google/cloud/dataproc/v1/internal/session_template_controller_stub.h b/google/cloud/dataproc/v1/internal/session_template_controller_stub.h index cd8d71697b183..eb1e702832b20 100644 --- a/google/cloud/dataproc/v1/internal/session_template_controller_stub.h +++ b/google/cloud/dataproc/v1/internal/session_template_controller_stub.h @@ -23,6 +23,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -63,6 +65,19 @@ class SessionTemplateControllerStub { grpc::ClientContext& context, Options const& options, google::cloud::dataproc::v1::DeleteSessionTemplateRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; }; class DefaultSessionTemplateControllerStub @@ -71,8 +86,10 @@ class DefaultSessionTemplateControllerStub explicit DefaultSessionTemplateControllerStub( std::unique_ptr< google::cloud::dataproc::v1::SessionTemplateController::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr iampolicy_stub) + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)) {} StatusOr CreateSessionTemplate( grpc::ClientContext& context, Options const& options, @@ -100,10 +117,23 @@ class DefaultSessionTemplateControllerStub google::cloud::dataproc::v1::DeleteSessionTemplateRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr< google::cloud::dataproc::v1::SessionTemplateController::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dataproc/v1/internal/session_template_controller_stub_factory.cc b/google/cloud/dataproc/v1/internal/session_template_controller_stub_factory.cc index a0acc8f0bfe6d..54ae466d33b28 100644 --- a/google/cloud/dataproc/v1/internal/session_template_controller_stub_factory.cc +++ b/google/cloud/dataproc/v1/internal/session_template_controller_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -45,9 +46,10 @@ CreateDefaultSessionTemplateControllerStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataproc::v1::SessionTemplateController::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_iampolicy_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/dataproc/v1/internal/session_template_controller_tracing_connection.cc b/google/cloud/dataproc/v1/internal/session_template_controller_tracing_connection.cc index d2496dc560cb5..f49032e2fec2e 100644 --- a/google/cloud/dataproc/v1/internal/session_template_controller_tracing_connection.cc +++ b/google/cloud/dataproc/v1/internal/session_template_controller_tracing_connection.cc @@ -84,6 +84,33 @@ Status SessionTemplateControllerTracingConnection::DeleteSessionTemplate( return internal::EndSpan(*span, child_->DeleteSessionTemplate(request)); } +StatusOr +SessionTemplateControllerTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::SessionTemplateControllerConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +SessionTemplateControllerTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::SessionTemplateControllerConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +SessionTemplateControllerTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::SessionTemplateControllerConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dataproc/v1/internal/session_template_controller_tracing_connection.h b/google/cloud/dataproc/v1/internal/session_template_controller_tracing_connection.h index 2f2656e44ecb1..f049cd842955a 100644 --- a/google/cloud/dataproc/v1/internal/session_template_controller_tracing_connection.h +++ b/google/cloud/dataproc/v1/internal/session_template_controller_tracing_connection.h @@ -60,6 +60,15 @@ class SessionTemplateControllerTracingConnection google::cloud::dataproc::v1::DeleteSessionTemplateRequest const& request) override; + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dataproc/v1/internal/session_template_controller_tracing_stub.cc b/google/cloud/dataproc/v1/internal/session_template_controller_tracing_stub.cc index 06fb9b7ae34e0..13d35b6ebd51a 100644 --- a/google/cloud/dataproc/v1/internal/session_template_controller_tracing_stub.cc +++ b/google/cloud/dataproc/v1/internal/session_template_controller_tracing_stub.cc @@ -96,6 +96,43 @@ Status SessionTemplateControllerTracingStub::DeleteSessionTemplate( context, *span, child_->DeleteSessionTemplate(context, options, request)); } +StatusOr +SessionTemplateControllerTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.SessionTemplateController", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr +SessionTemplateControllerTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.SessionTemplateController", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +SessionTemplateControllerTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.SessionTemplateController", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dataproc/v1/internal/session_template_controller_tracing_stub.h b/google/cloud/dataproc/v1/internal/session_template_controller_tracing_stub.h index 0ed6f67b1d662..b9b0bf0e77f0b 100644 --- a/google/cloud/dataproc/v1/internal/session_template_controller_tracing_stub.h +++ b/google/cloud/dataproc/v1/internal/session_template_controller_tracing_stub.h @@ -66,6 +66,18 @@ class SessionTemplateControllerTracingStub google::cloud::dataproc::v1::DeleteSessionTemplateRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/dataproc/v1/internal/workflow_template_auth_decorator.cc b/google/cloud/dataproc/v1/internal/workflow_template_auth_decorator.cc index 460611388a7e6..c9f0730df741a 100644 --- a/google/cloud/dataproc/v1/internal/workflow_template_auth_decorator.cc +++ b/google/cloud/dataproc/v1/internal/workflow_template_auth_decorator.cc @@ -137,6 +137,31 @@ Status WorkflowTemplateServiceAuth::DeleteWorkflowTemplate( return child_->DeleteWorkflowTemplate(context, options, request); } +StatusOr WorkflowTemplateServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr WorkflowTemplateServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +WorkflowTemplateServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> WorkflowTemplateServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/workflow_template_auth_decorator.h b/google/cloud/dataproc/v1/internal/workflow_template_auth_decorator.h index 5d0cd9c80bb81..e49b36e0917fd 100644 --- a/google/cloud/dataproc/v1/internal/workflow_template_auth_decorator.h +++ b/google/cloud/dataproc/v1/internal/workflow_template_auth_decorator.h @@ -93,6 +93,18 @@ class WorkflowTemplateServiceAuth : public WorkflowTemplateServiceStub { google::cloud::dataproc::v1::DeleteWorkflowTemplateRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataproc/v1/internal/workflow_template_connection_impl.cc b/google/cloud/dataproc/v1/internal/workflow_template_connection_impl.cc index 9ef830a8c6b58..330e612afa036 100644 --- a/google/cloud/dataproc/v1/internal/workflow_template_connection_impl.cc +++ b/google/cloud/dataproc/v1/internal/workflow_template_connection_impl.cc @@ -357,6 +357,48 @@ Status WorkflowTemplateServiceConnectionImpl::DeleteWorkflowTemplate( *current, request, __func__); } +StatusOr +WorkflowTemplateServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +WorkflowTemplateServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +WorkflowTemplateServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataproc_v1_internal } // namespace cloud diff --git a/google/cloud/dataproc/v1/internal/workflow_template_connection_impl.h b/google/cloud/dataproc/v1/internal/workflow_template_connection_impl.h index 92ecdbbac438c..42a1476aecff6 100644 --- a/google/cloud/dataproc/v1/internal/workflow_template_connection_impl.h +++ b/google/cloud/dataproc/v1/internal/workflow_template_connection_impl.h @@ -103,6 +103,15 @@ class WorkflowTemplateServiceConnectionImpl google::cloud::dataproc::v1::DeleteWorkflowTemplateRequest const& request) override; + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dataproc/v1/internal/workflow_template_logging_decorator.cc b/google/cloud/dataproc/v1/internal/workflow_template_logging_decorator.cc index 3644fc534b820..8af2c5ce0d75f 100644 --- a/google/cloud/dataproc/v1/internal/workflow_template_logging_decorator.cc +++ b/google/cloud/dataproc/v1/internal/workflow_template_logging_decorator.cc @@ -170,6 +170,40 @@ Status WorkflowTemplateServiceLogging::DeleteWorkflowTemplate( context, options, request, __func__, tracing_options_); } +StatusOr WorkflowTemplateServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr WorkflowTemplateServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +WorkflowTemplateServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> WorkflowTemplateServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/workflow_template_logging_decorator.h b/google/cloud/dataproc/v1/internal/workflow_template_logging_decorator.h index ced4cd860db71..ddab15114dd51 100644 --- a/google/cloud/dataproc/v1/internal/workflow_template_logging_decorator.h +++ b/google/cloud/dataproc/v1/internal/workflow_template_logging_decorator.h @@ -93,6 +93,18 @@ class WorkflowTemplateServiceLogging : public WorkflowTemplateServiceStub { google::cloud::dataproc::v1::DeleteWorkflowTemplateRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataproc/v1/internal/workflow_template_metadata_decorator.cc b/google/cloud/dataproc/v1/internal/workflow_template_metadata_decorator.cc index 5c91a614b6e71..fca1138a5e991 100644 --- a/google/cloud/dataproc/v1/internal/workflow_template_metadata_decorator.cc +++ b/google/cloud/dataproc/v1/internal/workflow_template_metadata_decorator.cc @@ -135,6 +135,34 @@ Status WorkflowTemplateServiceMetadata::DeleteWorkflowTemplate( return child_->DeleteWorkflowTemplate(context, options, request); } +StatusOr WorkflowTemplateServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr WorkflowTemplateServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +WorkflowTemplateServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> WorkflowTemplateServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/workflow_template_metadata_decorator.h b/google/cloud/dataproc/v1/internal/workflow_template_metadata_decorator.h index 2a91a6cfe472e..e237a124e4c54 100644 --- a/google/cloud/dataproc/v1/internal/workflow_template_metadata_decorator.h +++ b/google/cloud/dataproc/v1/internal/workflow_template_metadata_decorator.h @@ -94,6 +94,18 @@ class WorkflowTemplateServiceMetadata : public WorkflowTemplateServiceStub { google::cloud::dataproc::v1::DeleteWorkflowTemplateRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataproc/v1/internal/workflow_template_stub.cc b/google/cloud/dataproc/v1/internal/workflow_template_stub.cc index 86b23a62d89d3..6d18dc63eaa49 100644 --- a/google/cloud/dataproc/v1/internal/workflow_template_stub.cc +++ b/google/cloud/dataproc/v1/internal/workflow_template_stub.cc @@ -164,6 +164,43 @@ Status DefaultWorkflowTemplateServiceStub::DeleteWorkflowTemplate( return google::cloud::Status(); } +StatusOr +DefaultWorkflowTemplateServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultWorkflowTemplateServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultWorkflowTemplateServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultWorkflowTemplateServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/workflow_template_stub.h b/google/cloud/dataproc/v1/internal/workflow_template_stub.h index fbd6743042449..3d9fd3f433116 100644 --- a/google/cloud/dataproc/v1/internal/workflow_template_stub.h +++ b/google/cloud/dataproc/v1/internal/workflow_template_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -94,6 +96,19 @@ class WorkflowTemplateServiceStub { google::cloud::dataproc::v1::DeleteWorkflowTemplateRequest const& request) = 0; + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -113,9 +128,12 @@ class DefaultWorkflowTemplateServiceStub : public WorkflowTemplateServiceStub { std::unique_ptr< google::cloud::dataproc::v1::WorkflowTemplateService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + operations_(std::move(operations)) {} StatusOr CreateWorkflowTemplate( @@ -171,6 +189,18 @@ class DefaultWorkflowTemplateServiceStub : public WorkflowTemplateServiceStub { google::cloud::dataproc::v1::DeleteWorkflowTemplateRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -187,6 +217,7 @@ class DefaultWorkflowTemplateServiceStub : public WorkflowTemplateServiceStub { std::unique_ptr< google::cloud::dataproc::v1::WorkflowTemplateService::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/dataproc/v1/internal/workflow_template_stub_factory.cc b/google/cloud/dataproc/v1/internal/workflow_template_stub_factory.cc index b378fb0ccb395..48645f59ab0b1 100644 --- a/google/cloud/dataproc/v1/internal/workflow_template_stub_factory.cc +++ b/google/cloud/dataproc/v1/internal/workflow_template_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -45,9 +46,10 @@ CreateDefaultWorkflowTemplateServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dataproc::v1::WorkflowTemplateService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/dataproc/v1/internal/workflow_template_tracing_connection.cc b/google/cloud/dataproc/v1/internal/workflow_template_tracing_connection.cc index 7ad85ce35da30..c464f3296e2ae 100644 --- a/google/cloud/dataproc/v1/internal/workflow_template_tracing_connection.cc +++ b/google/cloud/dataproc/v1/internal/workflow_template_tracing_connection.cc @@ -153,6 +153,33 @@ Status WorkflowTemplateServiceTracingConnection::DeleteWorkflowTemplate( return internal::EndSpan(*span, child_->DeleteWorkflowTemplate(request)); } +StatusOr +WorkflowTemplateServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::WorkflowTemplateServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +WorkflowTemplateServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::WorkflowTemplateServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +WorkflowTemplateServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "dataproc_v1::WorkflowTemplateServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dataproc/v1/internal/workflow_template_tracing_connection.h b/google/cloud/dataproc/v1/internal/workflow_template_tracing_connection.h index ead6859809263..e5d2eb1e7fffd 100644 --- a/google/cloud/dataproc/v1/internal/workflow_template_tracing_connection.h +++ b/google/cloud/dataproc/v1/internal/workflow_template_tracing_connection.h @@ -91,6 +91,15 @@ class WorkflowTemplateServiceTracingConnection google::cloud::dataproc::v1::DeleteWorkflowTemplateRequest const& request) override; + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dataproc/v1/internal/workflow_template_tracing_stub.cc b/google/cloud/dataproc/v1/internal/workflow_template_tracing_stub.cc index bdcadf1304fcb..a300740cf35a1 100644 --- a/google/cloud/dataproc/v1/internal/workflow_template_tracing_stub.cc +++ b/google/cloud/dataproc/v1/internal/workflow_template_tracing_stub.cc @@ -163,6 +163,42 @@ Status WorkflowTemplateServiceTracingStub::DeleteWorkflowTemplate( child_->DeleteWorkflowTemplate(context, options, request)); } +StatusOr +WorkflowTemplateServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.WorkflowTemplateService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr +WorkflowTemplateServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.WorkflowTemplateService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +WorkflowTemplateServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dataproc.v1.WorkflowTemplateService", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> WorkflowTemplateServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dataproc/v1/internal/workflow_template_tracing_stub.h b/google/cloud/dataproc/v1/internal/workflow_template_tracing_stub.h index 8b5379fb507ad..1854b9db03bb4 100644 --- a/google/cloud/dataproc/v1/internal/workflow_template_tracing_stub.h +++ b/google/cloud/dataproc/v1/internal/workflow_template_tracing_stub.h @@ -93,6 +93,18 @@ class WorkflowTemplateServiceTracingStub : public WorkflowTemplateServiceStub { google::cloud::dataproc::v1::DeleteWorkflowTemplateRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dataproc/v1/job_controller_client.cc b/google/cloud/dataproc/v1/job_controller_client.cc index 1310675f104cd..5e66443faf8ab 100644 --- a/google/cloud/dataproc/v1/job_controller_client.cc +++ b/google/cloud/dataproc/v1/job_controller_client.cc @@ -183,6 +183,25 @@ Status JobControllerClient::DeleteJob( return connection_->DeleteJob(request); } +StatusOr JobControllerClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr JobControllerClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +JobControllerClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataproc_v1 } // namespace cloud diff --git a/google/cloud/dataproc/v1/job_controller_client.h b/google/cloud/dataproc/v1/job_controller_client.h index a10172aa00c5b..dc1381b0afef1 100644 --- a/google/cloud/dataproc/v1/job_controller_client.h +++ b/google/cloud/dataproc/v1/job_controller_client.h @@ -604,6 +604,108 @@ class JobControllerClient { Status DeleteJob(google::cloud::dataproc::v1::DeleteJobRequest const& request, Options opts = {}); + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dataproc/v1/job_controller_connection.cc b/google/cloud/dataproc/v1/job_controller_connection.cc index 37cf5ca0d168c..98a3e22c4c24d 100644 --- a/google/cloud/dataproc/v1/job_controller_connection.cc +++ b/google/cloud/dataproc/v1/job_controller_connection.cc @@ -93,6 +93,22 @@ Status JobControllerConnection::DeleteJob( return Status(StatusCode::kUnimplemented, "not implemented"); } +StatusOr JobControllerConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr JobControllerConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +JobControllerConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeJobControllerConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include #include @@ -214,6 +215,15 @@ class JobControllerConnection { virtual Status DeleteJob( google::cloud::dataproc::v1::DeleteJobRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/dataproc/v1/job_controller_connection_idempotency_policy.cc b/google/cloud/dataproc/v1/job_controller_connection_idempotency_policy.cc index 51d5bebac787b..298cbceaf6b3c 100644 --- a/google/cloud/dataproc/v1/job_controller_connection_idempotency_policy.cc +++ b/google/cloud/dataproc/v1/job_controller_connection_idempotency_policy.cc @@ -69,6 +69,22 @@ Idempotency JobControllerConnectionIdempotencyPolicy::DeleteJob( return Idempotency::kNonIdempotent; } +Idempotency JobControllerConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency JobControllerConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency JobControllerConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultJobControllerConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dataproc/v1/job_controller_connection_idempotency_policy.h b/google/cloud/dataproc/v1/job_controller_connection_idempotency_policy.h index ed46f9677619a..95e67a9c5e881 100644 --- a/google/cloud/dataproc/v1/job_controller_connection_idempotency_policy.h +++ b/google/cloud/dataproc/v1/job_controller_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -57,6 +58,15 @@ class JobControllerConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteJob( google::cloud::dataproc::v1::DeleteJobRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dataproc/v1/mocks/mock_autoscaling_policy_connection.h b/google/cloud/dataproc/v1/mocks/mock_autoscaling_policy_connection.h index 62622db0e36de..c8e157d0490e4 100644 --- a/google/cloud/dataproc/v1/mocks/mock_autoscaling_policy_connection.h +++ b/google/cloud/dataproc/v1/mocks/mock_autoscaling_policy_connection.h @@ -78,6 +78,19 @@ class MockAutoscalingPolicyServiceConnection (google::cloud::dataproc::v1::DeleteAutoscalingPolicyRequest const& request), (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dataproc/v1/mocks/mock_batch_controller_connection.h b/google/cloud/dataproc/v1/mocks/mock_batch_controller_connection.h index cd9746872eb26..6b26d730002c3 100644 --- a/google/cloud/dataproc/v1/mocks/mock_batch_controller_connection.h +++ b/google/cloud/dataproc/v1/mocks/mock_batch_controller_connection.h @@ -93,6 +93,19 @@ class MockBatchControllerConnection MOCK_METHOD(Status, DeleteBatch, (google::cloud::dataproc::v1::DeleteBatchRequest const& request), (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dataproc/v1/mocks/mock_cluster_controller_connection.h b/google/cloud/dataproc/v1/mocks/mock_cluster_controller_connection.h index e3262532d8dd5..31119fd11c94d 100644 --- a/google/cloud/dataproc/v1/mocks/mock_cluster_controller_connection.h +++ b/google/cloud/dataproc/v1/mocks/mock_cluster_controller_connection.h @@ -284,6 +284,19 @@ class MockClusterControllerConnection future>, DiagnoseCluster, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dataproc/v1/mocks/mock_job_controller_connection.h b/google/cloud/dataproc/v1/mocks/mock_job_controller_connection.h index f750fa5259995..05bc49f6eb70f 100644 --- a/google/cloud/dataproc/v1/mocks/mock_job_controller_connection.h +++ b/google/cloud/dataproc/v1/mocks/mock_job_controller_connection.h @@ -107,6 +107,19 @@ class MockJobControllerConnection MOCK_METHOD(Status, DeleteJob, (google::cloud::dataproc::v1::DeleteJobRequest const& request), (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dataproc/v1/mocks/mock_node_group_controller_connection.h b/google/cloud/dataproc/v1/mocks/mock_node_group_controller_connection.h index 7922d8a4fdfac..fa08ed10a9e34 100644 --- a/google/cloud/dataproc/v1/mocks/mock_node_group_controller_connection.h +++ b/google/cloud/dataproc/v1/mocks/mock_node_group_controller_connection.h @@ -126,6 +126,19 @@ class MockNodeGroupControllerConnection MOCK_METHOD(StatusOr, GetNodeGroup, (google::cloud::dataproc::v1::GetNodeGroupRequest const& request), (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dataproc/v1/mocks/mock_session_controller_connection.h b/google/cloud/dataproc/v1/mocks/mock_session_controller_connection.h index dc008f7f216f6..a6a19565bc11a 100644 --- a/google/cloud/dataproc/v1/mocks/mock_session_controller_connection.h +++ b/google/cloud/dataproc/v1/mocks/mock_session_controller_connection.h @@ -168,6 +168,19 @@ class MockSessionControllerConnection MOCK_METHOD(future>, DeleteSession, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dataproc/v1/mocks/mock_session_template_controller_connection.h b/google/cloud/dataproc/v1/mocks/mock_session_template_controller_connection.h index cce53e5fdb887..02be92a78c195 100644 --- a/google/cloud/dataproc/v1/mocks/mock_session_template_controller_connection.h +++ b/google/cloud/dataproc/v1/mocks/mock_session_template_controller_connection.h @@ -75,6 +75,19 @@ class MockSessionTemplateControllerConnection (google::cloud::dataproc::v1::DeleteSessionTemplateRequest const& request), (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dataproc/v1/mocks/mock_workflow_template_connection.h b/google/cloud/dataproc/v1/mocks/mock_workflow_template_connection.h index 0f2687a8f4f5b..d3911e441d19d 100644 --- a/google/cloud/dataproc/v1/mocks/mock_workflow_template_connection.h +++ b/google/cloud/dataproc/v1/mocks/mock_workflow_template_connection.h @@ -158,6 +158,19 @@ class MockWorkflowTemplateServiceConnection (google::cloud::dataproc::v1::DeleteWorkflowTemplateRequest const& request), (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dataproc/v1/node_group_controller_client.cc b/google/cloud/dataproc/v1/node_group_controller_client.cc index 9e2ca6e50ae5c..3ab1d9cb7710e 100644 --- a/google/cloud/dataproc/v1/node_group_controller_client.cc +++ b/google/cloud/dataproc/v1/node_group_controller_client.cc @@ -142,6 +142,25 @@ NodeGroupControllerClient::GetNodeGroup( return connection_->GetNodeGroup(request); } +StatusOr NodeGroupControllerClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr NodeGroupControllerClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +NodeGroupControllerClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataproc_v1 } // namespace cloud diff --git a/google/cloud/dataproc/v1/node_group_controller_client.h b/google/cloud/dataproc/v1/node_group_controller_client.h index 154f6650e591e..afc83814f52e1 100644 --- a/google/cloud/dataproc/v1/node_group_controller_client.h +++ b/google/cloud/dataproc/v1/node_group_controller_client.h @@ -404,6 +404,108 @@ class NodeGroupControllerClient { google::cloud::dataproc::v1::GetNodeGroupRequest const& request, Options opts = {}); + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dataproc/v1/node_group_controller_connection.cc b/google/cloud/dataproc/v1/node_group_controller_connection.cc index fd2e2baf29c1a..6e4bcc3411515 100644 --- a/google/cloud/dataproc/v1/node_group_controller_connection.cc +++ b/google/cloud/dataproc/v1/node_group_controller_connection.cc @@ -89,6 +89,22 @@ NodeGroupControllerConnection::GetNodeGroup( return Status(StatusCode::kUnimplemented, "not implemented"); } +StatusOr NodeGroupControllerConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr NodeGroupControllerConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +NodeGroupControllerConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeNodeGroupControllerConnection(std::string const& location, Options options) { diff --git a/google/cloud/dataproc/v1/node_group_controller_connection.h b/google/cloud/dataproc/v1/node_group_controller_connection.h index 0eb9e6d7aff3f..98ab91a3705af 100644 --- a/google/cloud/dataproc/v1/node_group_controller_connection.h +++ b/google/cloud/dataproc/v1/node_group_controller_connection.h @@ -31,6 +31,7 @@ #include "google/cloud/version.h" #include #include +#include #include #include #include @@ -214,6 +215,15 @@ class NodeGroupControllerConnection { virtual StatusOr GetNodeGroup( google::cloud::dataproc::v1::GetNodeGroupRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/dataproc/v1/node_group_controller_connection_idempotency_policy.cc b/google/cloud/dataproc/v1/node_group_controller_connection_idempotency_policy.cc index 162609237c540..417c00e9ff1c2 100644 --- a/google/cloud/dataproc/v1/node_group_controller_connection_idempotency_policy.cc +++ b/google/cloud/dataproc/v1/node_group_controller_connection_idempotency_policy.cc @@ -50,6 +50,22 @@ Idempotency NodeGroupControllerConnectionIdempotencyPolicy::GetNodeGroup( return Idempotency::kIdempotent; } +Idempotency NodeGroupControllerConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency NodeGroupControllerConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency NodeGroupControllerConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultNodeGroupControllerConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dataproc/v1/node_group_controller_connection_idempotency_policy.h b/google/cloud/dataproc/v1/node_group_controller_connection_idempotency_policy.h index e771675d7c7c6..bc7403d63ecc4 100644 --- a/google/cloud/dataproc/v1/node_group_controller_connection_idempotency_policy.h +++ b/google/cloud/dataproc/v1/node_group_controller_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -45,6 +46,15 @@ class NodeGroupControllerConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GetNodeGroup( google::cloud::dataproc::v1::GetNodeGroupRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dataproc/v1/session_controller_client.cc b/google/cloud/dataproc/v1/session_controller_client.cc index 09038bd5cab27..6beacea57a0e3 100644 --- a/google/cloud/dataproc/v1/session_controller_client.cc +++ b/google/cloud/dataproc/v1/session_controller_client.cc @@ -192,6 +192,25 @@ SessionControllerClient::DeleteSession( return connection_->DeleteSession(operation); } +StatusOr SessionControllerClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr SessionControllerClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +SessionControllerClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataproc_v1 } // namespace cloud diff --git a/google/cloud/dataproc/v1/session_controller_client.h b/google/cloud/dataproc/v1/session_controller_client.h index 10615f90e7565..c9e6eaf8e7508 100644 --- a/google/cloud/dataproc/v1/session_controller_client.h +++ b/google/cloud/dataproc/v1/session_controller_client.h @@ -567,6 +567,108 @@ class SessionControllerClient { future> DeleteSession( google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dataproc/v1/session_controller_connection.cc b/google/cloud/dataproc/v1/session_controller_connection.cc index 078bff2a1dbcc..ee25f9759e67d 100644 --- a/google/cloud/dataproc/v1/session_controller_connection.cc +++ b/google/cloud/dataproc/v1/session_controller_connection.cc @@ -121,6 +121,22 @@ SessionControllerConnection::DeleteSession( Status(StatusCode::kUnimplemented, "not implemented")); } +StatusOr SessionControllerConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr SessionControllerConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +SessionControllerConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSessionControllerConnection( std::string const& location, Options options) { internal::CheckExpectedOptions #include +#include #include #include #include @@ -225,6 +226,15 @@ class SessionControllerConnection { virtual future> DeleteSession( google::longrunning::Operation const& operation); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/dataproc/v1/session_controller_connection_idempotency_policy.cc b/google/cloud/dataproc/v1/session_controller_connection_idempotency_policy.cc index b72fab30ec786..8dbbc70a24a2d 100644 --- a/google/cloud/dataproc/v1/session_controller_connection_idempotency_policy.cc +++ b/google/cloud/dataproc/v1/session_controller_connection_idempotency_policy.cc @@ -59,6 +59,22 @@ Idempotency SessionControllerConnectionIdempotencyPolicy::DeleteSession( return Idempotency::kNonIdempotent; } +Idempotency SessionControllerConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency SessionControllerConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency SessionControllerConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultSessionControllerConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dataproc/v1/session_controller_connection_idempotency_policy.h b/google/cloud/dataproc/v1/session_controller_connection_idempotency_policy.h index 9ced85d56681b..b4cebf17a70a6 100644 --- a/google/cloud/dataproc/v1/session_controller_connection_idempotency_policy.h +++ b/google/cloud/dataproc/v1/session_controller_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -51,6 +52,15 @@ class SessionControllerConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteSession( google::cloud::dataproc::v1::DeleteSessionRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dataproc/v1/session_template_controller_client.cc b/google/cloud/dataproc/v1/session_template_controller_client.cc index dc973380ec407..4d3c6bdeb9db8 100644 --- a/google/cloud/dataproc/v1/session_template_controller_client.cc +++ b/google/cloud/dataproc/v1/session_template_controller_client.cc @@ -120,6 +120,25 @@ Status SessionTemplateControllerClient::DeleteSessionTemplate( return connection_->DeleteSessionTemplate(request); } +StatusOr SessionTemplateControllerClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr SessionTemplateControllerClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +SessionTemplateControllerClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataproc_v1 } // namespace cloud diff --git a/google/cloud/dataproc/v1/session_template_controller_client.h b/google/cloud/dataproc/v1/session_template_controller_client.h index 5447b5fff6a8b..e21dabbadaf41 100644 --- a/google/cloud/dataproc/v1/session_template_controller_client.h +++ b/google/cloud/dataproc/v1/session_template_controller_client.h @@ -386,6 +386,108 @@ class SessionTemplateControllerClient { google::cloud::dataproc::v1::DeleteSessionTemplateRequest const& request, Options opts = {}); + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dataproc/v1/session_template_controller_connection.cc b/google/cloud/dataproc/v1/session_template_controller_connection.cc index 7563708843b84..8f47e6a1c63bf 100644 --- a/google/cloud/dataproc/v1/session_template_controller_connection.cc +++ b/google/cloud/dataproc/v1/session_template_controller_connection.cc @@ -70,6 +70,24 @@ Status SessionTemplateControllerConnection::DeleteSessionTemplate( return Status(StatusCode::kUnimplemented, "not implemented"); } +StatusOr +SessionTemplateControllerConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +SessionTemplateControllerConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +SessionTemplateControllerConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSessionTemplateControllerConnection(std::string const& location, Options options) { diff --git a/google/cloud/dataproc/v1/session_template_controller_connection.h b/google/cloud/dataproc/v1/session_template_controller_connection.h index 91714189f594b..351361ebd178d 100644 --- a/google/cloud/dataproc/v1/session_template_controller_connection.h +++ b/google/cloud/dataproc/v1/session_template_controller_connection.h @@ -28,6 +28,7 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include #include #include @@ -215,6 +216,15 @@ class SessionTemplateControllerConnection { virtual Status DeleteSessionTemplate( google::cloud::dataproc::v1::DeleteSessionTemplateRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/dataproc/v1/session_template_controller_connection_idempotency_policy.cc b/google/cloud/dataproc/v1/session_template_controller_connection_idempotency_policy.cc index 637a0de5d378d..31d4e47c4762d 100644 --- a/google/cloud/dataproc/v1/session_template_controller_connection_idempotency_policy.cc +++ b/google/cloud/dataproc/v1/session_template_controller_connection_idempotency_policy.cc @@ -65,6 +65,23 @@ SessionTemplateControllerConnectionIdempotencyPolicy::DeleteSessionTemplate( return Idempotency::kNonIdempotent; } +Idempotency SessionTemplateControllerConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency SessionTemplateControllerConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +SessionTemplateControllerConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultSessionTemplateControllerConnectionIdempotencyPolicy() { return std::make_unique< diff --git a/google/cloud/dataproc/v1/session_template_controller_connection_idempotency_policy.h b/google/cloud/dataproc/v1/session_template_controller_connection_idempotency_policy.h index dfac553f727ef..1621b862dbe68 100644 --- a/google/cloud/dataproc/v1/session_template_controller_connection_idempotency_policy.h +++ b/google/cloud/dataproc/v1/session_template_controller_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -51,6 +52,15 @@ class SessionTemplateControllerConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteSessionTemplate( google::cloud::dataproc::v1::DeleteSessionTemplateRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dataproc/v1/workflow_template_client.cc b/google/cloud/dataproc/v1/workflow_template_client.cc index 6a441f80a2cd0..62d014a7a234a 100644 --- a/google/cloud/dataproc/v1/workflow_template_client.cc +++ b/google/cloud/dataproc/v1/workflow_template_client.cc @@ -235,6 +235,25 @@ Status WorkflowTemplateServiceClient::DeleteWorkflowTemplate( return connection_->DeleteWorkflowTemplate(request); } +StatusOr WorkflowTemplateServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr WorkflowTemplateServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +WorkflowTemplateServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataproc_v1 } // namespace cloud diff --git a/google/cloud/dataproc/v1/workflow_template_client.h b/google/cloud/dataproc/v1/workflow_template_client.h index d092e16607aa8..7e180f300a9a9 100644 --- a/google/cloud/dataproc/v1/workflow_template_client.h +++ b/google/cloud/dataproc/v1/workflow_template_client.h @@ -890,6 +890,108 @@ class WorkflowTemplateServiceClient { google::cloud::dataproc::v1::DeleteWorkflowTemplateRequest const& request, Options opts = {}); + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dataproc/v1/workflow_template_connection.cc b/google/cloud/dataproc/v1/workflow_template_connection.cc index 81a79235dc697..d0d0b9cf390d5 100644 --- a/google/cloud/dataproc/v1/workflow_template_connection.cc +++ b/google/cloud/dataproc/v1/workflow_template_connection.cc @@ -119,6 +119,24 @@ Status WorkflowTemplateServiceConnection::DeleteWorkflowTemplate( return Status(StatusCode::kUnimplemented, "not implemented"); } +StatusOr +WorkflowTemplateServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +WorkflowTemplateServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +WorkflowTemplateServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeWorkflowTemplateServiceConnection(std::string const& location, Options options) { diff --git a/google/cloud/dataproc/v1/workflow_template_connection.h b/google/cloud/dataproc/v1/workflow_template_connection.h index 6253990ad8ab4..4043fb811ee19 100644 --- a/google/cloud/dataproc/v1/workflow_template_connection.h +++ b/google/cloud/dataproc/v1/workflow_template_connection.h @@ -31,6 +31,7 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -242,6 +243,15 @@ class WorkflowTemplateServiceConnection { virtual Status DeleteWorkflowTemplate( google::cloud::dataproc::v1::DeleteWorkflowTemplateRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/dataproc/v1/workflow_template_connection_idempotency_policy.cc b/google/cloud/dataproc/v1/workflow_template_connection_idempotency_policy.cc index a7183868ed8c9..8bf2be6e55a25 100644 --- a/google/cloud/dataproc/v1/workflow_template_connection_idempotency_policy.cc +++ b/google/cloud/dataproc/v1/workflow_template_connection_idempotency_policy.cc @@ -78,6 +78,23 @@ WorkflowTemplateServiceConnectionIdempotencyPolicy::DeleteWorkflowTemplate( return Idempotency::kNonIdempotent; } +Idempotency WorkflowTemplateServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency WorkflowTemplateServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +WorkflowTemplateServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultWorkflowTemplateServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dataproc/v1/workflow_template_connection_idempotency_policy.h b/google/cloud/dataproc/v1/workflow_template_connection_idempotency_policy.h index 896cfc7c177fc..b963c7ee485b2 100644 --- a/google/cloud/dataproc/v1/workflow_template_connection_idempotency_policy.h +++ b/google/cloud/dataproc/v1/workflow_template_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -62,6 +63,15 @@ class WorkflowTemplateServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteWorkflowTemplate( google::cloud::dataproc::v1::DeleteWorkflowTemplateRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/datastream/BUILD.bazel b/google/cloud/datastream/BUILD.bazel index 4971ef90eba7d..6d795a909ffd3 100644 --- a/google/cloud/datastream/BUILD.bazel +++ b/google/cloud/datastream/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/datastream/v1:datastream_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/datastream/v1/datastream_client.cc b/google/cloud/datastream/v1/datastream_client.cc index 59402e8081fa6..c56e5422bff69 100644 --- a/google/cloud/datastream/v1/datastream_client.cc +++ b/google/cloud/datastream/v1/datastream_client.cc @@ -711,6 +711,18 @@ DatastreamClient::DeleteRoute(google::longrunning::Operation const& operation, return connection_->DeleteRoute(operation); } +StreamRange DatastreamClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr DatastreamClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datastream_v1 } // namespace cloud diff --git a/google/cloud/datastream/v1/datastream_client.h b/google/cloud/datastream/v1/datastream_client.h index eeea6c0cb74aa..3e3fc5cb56da0 100644 --- a/google/cloud/datastream/v1/datastream_client.h +++ b/google/cloud/datastream/v1/datastream_client.h @@ -2196,6 +2196,76 @@ class DatastreamClient { DeleteRoute(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/datastream/v1/datastream_connection.cc b/google/cloud/datastream/v1/datastream_connection.cc index b2988d53d6047..1bf282eaa98e5 100644 --- a/google/cloud/datastream/v1/datastream_connection.cc +++ b/google/cloud/datastream/v1/datastream_connection.cc @@ -362,6 +362,19 @@ DatastreamConnection::DeleteRoute(google::longrunning::Operation const&) { Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +DatastreamConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr DatastreamConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDatastreamConnection( Options options) { internal::CheckExpectedOptions +#include +#include #include #include @@ -358,6 +360,12 @@ class DatastreamConnection { virtual future> DeleteRoute(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/datastream/v1/datastream_connection_idempotency_policy.cc b/google/cloud/datastream/v1/datastream_connection_idempotency_policy.cc index 1d9908d189527..a63ee89c4e598 100644 --- a/google/cloud/datastream/v1/datastream_connection_idempotency_policy.cc +++ b/google/cloud/datastream/v1/datastream_connection_idempotency_policy.cc @@ -159,6 +159,16 @@ Idempotency DatastreamConnectionIdempotencyPolicy::DeleteRoute( return Idempotency::kNonIdempotent; } +Idempotency DatastreamConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DatastreamConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultDatastreamConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/datastream/v1/datastream_connection_idempotency_policy.h b/google/cloud/datastream/v1/datastream_connection_idempotency_policy.h index 5dd88f4406be5..875e2949dc8d5 100644 --- a/google/cloud/datastream/v1/datastream_connection_idempotency_policy.h +++ b/google/cloud/datastream/v1/datastream_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -118,6 +119,12 @@ class DatastreamConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteRoute( google::cloud::datastream::v1::DeleteRouteRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/datastream/v1/internal/datastream_auth_decorator.cc b/google/cloud/datastream/v1/internal/datastream_auth_decorator.cc index bf2170c57f28a..cea02bed69359 100644 --- a/google/cloud/datastream/v1/internal/datastream_auth_decorator.cc +++ b/google/cloud/datastream/v1/internal/datastream_auth_decorator.cc @@ -462,6 +462,23 @@ StatusOr DatastreamAuth::DeleteRoute( return child_->DeleteRoute(context, options, request); } +StatusOr +DatastreamAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr DatastreamAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> DatastreamAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datastream/v1/internal/datastream_auth_decorator.h b/google/cloud/datastream/v1/internal/datastream_auth_decorator.h index 98ee1d0c9a8bd..0f77c845182fd 100644 --- a/google/cloud/datastream/v1/internal/datastream_auth_decorator.h +++ b/google/cloud/datastream/v1/internal/datastream_auth_decorator.h @@ -237,6 +237,14 @@ class DatastreamAuth : public DatastreamStub { google::cloud::datastream::v1::DeleteRouteRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datastream/v1/internal/datastream_connection_impl.cc b/google/cloud/datastream/v1/internal/datastream_connection_impl.cc index 6b13df581f913..5ff599f94cdd2 100644 --- a/google/cloud/datastream/v1/internal/datastream_connection_impl.cc +++ b/google/cloud/datastream/v1/internal/datastream_connection_impl.cc @@ -1335,6 +1335,54 @@ DatastreamConnectionImpl::DeleteRoute( polling_policy(*current), __func__); } +StreamRange +DatastreamConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DatastreamConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace datastream_v1_internal } // namespace cloud diff --git a/google/cloud/datastream/v1/internal/datastream_connection_impl.h b/google/cloud/datastream/v1/internal/datastream_connection_impl.h index 5907ee47a6500..735e1095f651b 100644 --- a/google/cloud/datastream/v1/internal/datastream_connection_impl.h +++ b/google/cloud/datastream/v1/internal/datastream_connection_impl.h @@ -240,6 +240,12 @@ class DatastreamConnectionImpl : public datastream_v1::DatastreamConnection { future> DeleteRoute(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/datastream/v1/internal/datastream_logging_decorator.cc b/google/cloud/datastream/v1/internal/datastream_logging_decorator.cc index ba7550654a5dd..a28ca06e98b43 100644 --- a/google/cloud/datastream/v1/internal/datastream_logging_decorator.cc +++ b/google/cloud/datastream/v1/internal/datastream_logging_decorator.cc @@ -559,6 +559,29 @@ StatusOr DatastreamLogging::DeleteRoute( context, options, request, __func__, tracing_options_); } +StatusOr +DatastreamLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DatastreamLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> DatastreamLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datastream/v1/internal/datastream_logging_decorator.h b/google/cloud/datastream/v1/internal/datastream_logging_decorator.h index 4f9aa80eea271..e80245fe102ea 100644 --- a/google/cloud/datastream/v1/internal/datastream_logging_decorator.h +++ b/google/cloud/datastream/v1/internal/datastream_logging_decorator.h @@ -237,6 +237,14 @@ class DatastreamLogging : public DatastreamStub { google::cloud::datastream::v1::DeleteRouteRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datastream/v1/internal/datastream_metadata_decorator.cc b/google/cloud/datastream/v1/internal/datastream_metadata_decorator.cc index d7693082d669a..c312529a98352 100644 --- a/google/cloud/datastream/v1/internal/datastream_metadata_decorator.cc +++ b/google/cloud/datastream/v1/internal/datastream_metadata_decorator.cc @@ -401,6 +401,23 @@ StatusOr DatastreamMetadata::DeleteRoute( return child_->DeleteRoute(context, options, request); } +StatusOr +DatastreamMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr DatastreamMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> DatastreamMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datastream/v1/internal/datastream_metadata_decorator.h b/google/cloud/datastream/v1/internal/datastream_metadata_decorator.h index ad318322297b1..04f1e95126fe0 100644 --- a/google/cloud/datastream/v1/internal/datastream_metadata_decorator.h +++ b/google/cloud/datastream/v1/internal/datastream_metadata_decorator.h @@ -237,6 +237,14 @@ class DatastreamMetadata : public DatastreamStub { google::cloud::datastream::v1::DeleteRouteRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datastream/v1/internal/datastream_stub.cc b/google/cloud/datastream/v1/internal/datastream_stub.cc index 7c80f01569d84..366de255668d5 100644 --- a/google/cloud/datastream/v1/internal/datastream_stub.cc +++ b/google/cloud/datastream/v1/internal/datastream_stub.cc @@ -536,6 +536,29 @@ StatusOr DefaultDatastreamStub::DeleteRoute( return response; } +StatusOr +DefaultDatastreamStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultDatastreamStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultDatastreamStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datastream/v1/internal/datastream_stub.h b/google/cloud/datastream/v1/internal/datastream_stub.h index 7277ee5ef542c..350e2529cece6 100644 --- a/google/cloud/datastream/v1/internal/datastream_stub.h +++ b/google/cloud/datastream/v1/internal/datastream_stub.h @@ -25,6 +25,9 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include #include #include #include @@ -235,6 +238,15 @@ class DatastreamStub { grpc::ClientContext& context, Options options, google::cloud::datastream::v1::DeleteRouteRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -253,9 +265,13 @@ class DefaultDatastreamStub : public DatastreamStub { DefaultDatastreamStub( std::unique_ptr grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListConnectionProfiles( @@ -455,6 +471,14 @@ class DefaultDatastreamStub : public DatastreamStub { google::cloud::datastream::v1::DeleteRouteRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -470,6 +494,8 @@ class DefaultDatastreamStub : public DatastreamStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/datastream/v1/internal/datastream_stub_factory.cc b/google/cloud/datastream/v1/internal/datastream_stub_factory.cc index 7afc732817734..3d1a989728ef7 100644 --- a/google/cloud/datastream/v1/internal/datastream_stub_factory.cc +++ b/google/cloud/datastream/v1/internal/datastream_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultDatastreamStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::datastream::v1::Datastream::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/datastream/v1/internal/datastream_tracing_connection.cc b/google/cloud/datastream/v1/internal/datastream_tracing_connection.cc index 4a4e10b50eedd..dd9441d2ca274 100644 --- a/google/cloud/datastream/v1/internal/datastream_tracing_connection.cc +++ b/google/cloud/datastream/v1/internal/datastream_tracing_connection.cc @@ -488,6 +488,26 @@ DatastreamTracingConnection::DeleteRoute( return internal::EndSpan(std::move(span), child_->DeleteRoute(operation)); } +StreamRange +DatastreamTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("datastream_v1::DatastreamConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DatastreamTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("datastream_v1::DatastreamConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/datastream/v1/internal/datastream_tracing_connection.h b/google/cloud/datastream/v1/internal/datastream_tracing_connection.h index 297bbe5dbfebd..dfcb8083b7f71 100644 --- a/google/cloud/datastream/v1/internal/datastream_tracing_connection.h +++ b/google/cloud/datastream/v1/internal/datastream_tracing_connection.h @@ -228,6 +228,12 @@ class DatastreamTracingConnection : public datastream_v1::DatastreamConnection { future> DeleteRoute(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/datastream/v1/internal/datastream_tracing_stub.cc b/google/cloud/datastream/v1/internal/datastream_tracing_stub.cc index b8a0890fb9739..6af128b53cfd8 100644 --- a/google/cloud/datastream/v1/internal/datastream_tracing_stub.cc +++ b/google/cloud/datastream/v1/internal/datastream_tracing_stub.cc @@ -492,6 +492,29 @@ StatusOr DatastreamTracingStub::DeleteRoute( child_->DeleteRoute(context, options, request)); } +StatusOr +DatastreamTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.datastream.v1.Datastream", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr DatastreamTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.datastream.v1.Datastream", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> DatastreamTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/datastream/v1/internal/datastream_tracing_stub.h b/google/cloud/datastream/v1/internal/datastream_tracing_stub.h index a18523d41d345..4ea6f46b16579 100644 --- a/google/cloud/datastream/v1/internal/datastream_tracing_stub.h +++ b/google/cloud/datastream/v1/internal/datastream_tracing_stub.h @@ -236,6 +236,14 @@ class DatastreamTracingStub : public DatastreamStub { google::cloud::datastream::v1::DeleteRouteRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/datastream/v1/mocks/mock_datastream_connection.h b/google/cloud/datastream/v1/mocks/mock_datastream_connection.h index 4defdd5440170..2274346dd82bf 100644 --- a/google/cloud/datastream/v1/mocks/mock_datastream_connection.h +++ b/google/cloud/datastream/v1/mocks/mock_datastream_connection.h @@ -533,6 +533,14 @@ class MockDatastreamConnection : public datastream_v1::DatastreamConnection { future>, DeleteRoute, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/deploy/BUILD.bazel b/google/cloud/deploy/BUILD.bazel index 7d2b0d82079bc..79d91b229d5a7 100644 --- a/google/cloud/deploy/BUILD.bazel +++ b/google/cloud/deploy/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/deploy/v1:deploy_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/deploy/v1/cloud_deploy_client.cc b/google/cloud/deploy/v1/cloud_deploy_client.cc index 9df4f8bc706ac..5daf47d0cf39a 100644 --- a/google/cloud/deploy/v1/cloud_deploy_client.cc +++ b/google/cloud/deploy/v1/cloud_deploy_client.cc @@ -1073,6 +1073,37 @@ CloudDeployClient::CancelAutomationRun( return connection_->CancelAutomationRun(request); } +StreamRange CloudDeployClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr CloudDeployClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr CloudDeployClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr CloudDeployClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +CloudDeployClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace deploy_v1 } // namespace cloud diff --git a/google/cloud/deploy/v1/cloud_deploy_client.h b/google/cloud/deploy/v1/cloud_deploy_client.h index 2a1ce10360584..7565ec9b70d25 100644 --- a/google/cloud/deploy/v1/cloud_deploy_client.h +++ b/google/cloud/deploy/v1/cloud_deploy_client.h @@ -3396,6 +3396,178 @@ class CloudDeployClient { google::cloud::deploy::v1::CancelAutomationRunRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/deploy/v1/cloud_deploy_connection.cc b/google/cloud/deploy/v1/cloud_deploy_connection.cc index 0f6f497a73556..b36a76719ef5f 100644 --- a/google/cloud/deploy/v1/cloud_deploy_connection.cc +++ b/google/cloud/deploy/v1/cloud_deploy_connection.cc @@ -520,6 +520,35 @@ CloudDeployConnection::CancelAutomationRun( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +CloudDeployConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr CloudDeployConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr CloudDeployConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr CloudDeployConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +CloudDeployConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCloudDeployConnection( Options options) { internal::CheckExpectedOptions +#include +#include #include #include @@ -422,6 +424,21 @@ class CloudDeployConnection { virtual StatusOr CancelAutomationRun( google::cloud::deploy::v1::CancelAutomationRunRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/deploy/v1/cloud_deploy_connection_idempotency_policy.cc b/google/cloud/deploy/v1/cloud_deploy_connection_idempotency_policy.cc index 6417d5039f22a..ef3536cedc00c 100644 --- a/google/cloud/deploy/v1/cloud_deploy_connection_idempotency_policy.cc +++ b/google/cloud/deploy/v1/cloud_deploy_connection_idempotency_policy.cc @@ -234,6 +234,32 @@ Idempotency CloudDeployConnectionIdempotencyPolicy::CancelAutomationRun( return Idempotency::kNonIdempotent; } +Idempotency CloudDeployConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CloudDeployConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency CloudDeployConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency CloudDeployConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency CloudDeployConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultCloudDeployConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/deploy/v1/cloud_deploy_connection_idempotency_policy.h b/google/cloud/deploy/v1/cloud_deploy_connection_idempotency_policy.h index c39f522b90bca..b1bd7a25d01b3 100644 --- a/google/cloud/deploy/v1/cloud_deploy_connection_idempotency_policy.h +++ b/google/cloud/deploy/v1/cloud_deploy_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -155,6 +157,21 @@ class CloudDeployConnectionIdempotencyPolicy { virtual google::cloud::Idempotency CancelAutomationRun( google::cloud::deploy::v1::CancelAutomationRunRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/deploy/v1/internal/cloud_deploy_auth_decorator.cc b/google/cloud/deploy/v1/internal/cloud_deploy_auth_decorator.cc index a551ec6ad5fa7..1dd2928d0f672 100644 --- a/google/cloud/deploy/v1/internal/cloud_deploy_auth_decorator.cc +++ b/google/cloud/deploy/v1/internal/cloud_deploy_auth_decorator.cc @@ -656,6 +656,48 @@ CloudDeployAuth::CancelAutomationRun( return child_->CancelAutomationRun(context, options, request); } +StatusOr +CloudDeployAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr CloudDeployAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr CloudDeployAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr CloudDeployAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +CloudDeployAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> CloudDeployAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/deploy/v1/internal/cloud_deploy_auth_decorator.h b/google/cloud/deploy/v1/internal/cloud_deploy_auth_decorator.h index 16af742ea83bc..4210ad8ab26da 100644 --- a/google/cloud/deploy/v1/internal/cloud_deploy_auth_decorator.h +++ b/google/cloud/deploy/v1/internal/cloud_deploy_auth_decorator.h @@ -313,6 +313,26 @@ class CloudDeployAuth : public CloudDeployStub { google::cloud::deploy::v1::CancelAutomationRunRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/deploy/v1/internal/cloud_deploy_connection_impl.cc b/google/cloud/deploy/v1/internal/cloud_deploy_connection_impl.cc index 41339cb5e2d4c..f74a3630a2f73 100644 --- a/google/cloud/deploy/v1/internal/cloud_deploy_connection_impl.cc +++ b/google/cloud/deploy/v1/internal/cloud_deploy_connection_impl.cc @@ -1874,6 +1874,94 @@ CloudDeployConnectionImpl::CancelAutomationRun( *current, request, __func__); } +StreamRange +CloudDeployConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +CloudDeployConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr CloudDeployConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr CloudDeployConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +CloudDeployConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace deploy_v1_internal } // namespace cloud diff --git a/google/cloud/deploy/v1/internal/cloud_deploy_connection_impl.h b/google/cloud/deploy/v1/internal/cloud_deploy_connection_impl.h index cb9b5541f327d..709abed013fea 100644 --- a/google/cloud/deploy/v1/internal/cloud_deploy_connection_impl.h +++ b/google/cloud/deploy/v1/internal/cloud_deploy_connection_impl.h @@ -307,6 +307,21 @@ class CloudDeployConnectionImpl : public deploy_v1::CloudDeployConnection { google::cloud::deploy::v1::CancelAutomationRunRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/deploy/v1/internal/cloud_deploy_logging_decorator.cc b/google/cloud/deploy/v1/internal/cloud_deploy_logging_decorator.cc index 8f96035b1a7b7..6e2378c6fe8a4 100644 --- a/google/cloud/deploy/v1/internal/cloud_deploy_logging_decorator.cc +++ b/google/cloud/deploy/v1/internal/cloud_deploy_logging_decorator.cc @@ -779,6 +779,63 @@ CloudDeployLogging::CancelAutomationRun( context, options, request, __func__, tracing_options_); } +StatusOr +CloudDeployLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr CloudDeployLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr CloudDeployLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr CloudDeployLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +CloudDeployLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> CloudDeployLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/deploy/v1/internal/cloud_deploy_logging_decorator.h b/google/cloud/deploy/v1/internal/cloud_deploy_logging_decorator.h index 317739974c940..b67b8400c0a77 100644 --- a/google/cloud/deploy/v1/internal/cloud_deploy_logging_decorator.h +++ b/google/cloud/deploy/v1/internal/cloud_deploy_logging_decorator.h @@ -313,6 +313,26 @@ class CloudDeployLogging : public CloudDeployStub { google::cloud::deploy::v1::CancelAutomationRunRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/deploy/v1/internal/cloud_deploy_metadata_decorator.cc b/google/cloud/deploy/v1/internal/cloud_deploy_metadata_decorator.cc index 6ea04e9aab0c7..de40f4cf209e0 100644 --- a/google/cloud/deploy/v1/internal/cloud_deploy_metadata_decorator.cc +++ b/google/cloud/deploy/v1/internal/cloud_deploy_metadata_decorator.cc @@ -571,6 +571,51 @@ CloudDeployMetadata::CancelAutomationRun( return child_->CancelAutomationRun(context, options, request); } +StatusOr +CloudDeployMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr CloudDeployMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr CloudDeployMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr CloudDeployMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +CloudDeployMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> CloudDeployMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/deploy/v1/internal/cloud_deploy_metadata_decorator.h b/google/cloud/deploy/v1/internal/cloud_deploy_metadata_decorator.h index 54fd06ff16f46..d9d437533bd5d 100644 --- a/google/cloud/deploy/v1/internal/cloud_deploy_metadata_decorator.h +++ b/google/cloud/deploy/v1/internal/cloud_deploy_metadata_decorator.h @@ -313,6 +313,26 @@ class CloudDeployMetadata : public CloudDeployStub { google::cloud::deploy::v1::CancelAutomationRunRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/deploy/v1/internal/cloud_deploy_stub.cc b/google/cloud/deploy/v1/internal/cloud_deploy_stub.cc index f69d0771ede90..1573a752aa5da 100644 --- a/google/cloud/deploy/v1/internal/cloud_deploy_stub.cc +++ b/google/cloud/deploy/v1/internal/cloud_deploy_stub.cc @@ -765,6 +765,64 @@ DefaultCloudDeployStub::CancelAutomationRun( return response; } +StatusOr +DefaultCloudDeployStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultCloudDeployStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultCloudDeployStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultCloudDeployStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultCloudDeployStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultCloudDeployStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/deploy/v1/internal/cloud_deploy_stub.h b/google/cloud/deploy/v1/internal/cloud_deploy_stub.h index 2045e7dd938bb..0393114dd6eaa 100644 --- a/google/cloud/deploy/v1/internal/cloud_deploy_stub.h +++ b/google/cloud/deploy/v1/internal/cloud_deploy_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -320,6 +324,28 @@ class CloudDeployStub { grpc::ClientContext& context, Options const& options, google::cloud::deploy::v1::CancelAutomationRunRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -338,9 +364,15 @@ class DefaultCloudDeployStub : public CloudDeployStub { DefaultCloudDeployStub( std::unique_ptr grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListDeliveryPipelines( @@ -616,6 +648,26 @@ class DefaultCloudDeployStub : public CloudDeployStub { google::cloud::deploy::v1::CancelAutomationRunRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -631,6 +683,9 @@ class DefaultCloudDeployStub : public CloudDeployStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/deploy/v1/internal/cloud_deploy_stub_factory.cc b/google/cloud/deploy/v1/internal/cloud_deploy_stub_factory.cc index 8fd45e4645c49..fa9dec510f585 100644 --- a/google/cloud/deploy/v1/internal/cloud_deploy_stub_factory.cc +++ b/google/cloud/deploy/v1/internal/cloud_deploy_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultCloudDeployStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::deploy::v1::CloudDeploy::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/deploy/v1/internal/cloud_deploy_tracing_connection.cc b/google/cloud/deploy/v1/internal/cloud_deploy_tracing_connection.cc index 638ce5dd60860..49d142c94a156 100644 --- a/google/cloud/deploy/v1/internal/cloud_deploy_tracing_connection.cc +++ b/google/cloud/deploy/v1/internal/cloud_deploy_tracing_connection.cc @@ -693,6 +693,51 @@ CloudDeployTracingConnection::CancelAutomationRun( return internal::EndSpan(*span, child_->CancelAutomationRun(request)); } +StreamRange +CloudDeployTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("deploy_v1::CloudDeployConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CloudDeployTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("deploy_v1::CloudDeployConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr CloudDeployTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("deploy_v1::CloudDeployConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr CloudDeployTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("deploy_v1::CloudDeployConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +CloudDeployTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "deploy_v1::CloudDeployConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/deploy/v1/internal/cloud_deploy_tracing_connection.h b/google/cloud/deploy/v1/internal/cloud_deploy_tracing_connection.h index 2fe41a464f606..703662cf37787 100644 --- a/google/cloud/deploy/v1/internal/cloud_deploy_tracing_connection.h +++ b/google/cloud/deploy/v1/internal/cloud_deploy_tracing_connection.h @@ -295,6 +295,21 @@ class CloudDeployTracingConnection : public deploy_v1::CloudDeployConnection { google::cloud::deploy::v1::CancelAutomationRunRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/deploy/v1/internal/cloud_deploy_tracing_stub.cc b/google/cloud/deploy/v1/internal/cloud_deploy_tracing_stub.cc index 1365359defb0d..ca34086f5eadc 100644 --- a/google/cloud/deploy/v1/internal/cloud_deploy_tracing_stub.cc +++ b/google/cloud/deploy/v1/internal/cloud_deploy_tracing_stub.cc @@ -713,6 +713,63 @@ CloudDeployTracingStub::CancelAutomationRun( context, *span, child_->CancelAutomationRun(context, options, request)); } +StatusOr +CloudDeployTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.deploy.v1.CloudDeploy", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr CloudDeployTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.deploy.v1.CloudDeploy", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr CloudDeployTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.deploy.v1.CloudDeploy", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr CloudDeployTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.deploy.v1.CloudDeploy", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +CloudDeployTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.deploy.v1.CloudDeploy", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> CloudDeployTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/deploy/v1/internal/cloud_deploy_tracing_stub.h b/google/cloud/deploy/v1/internal/cloud_deploy_tracing_stub.h index 0893eea18ecdb..1760e402273c7 100644 --- a/google/cloud/deploy/v1/internal/cloud_deploy_tracing_stub.h +++ b/google/cloud/deploy/v1/internal/cloud_deploy_tracing_stub.h @@ -312,6 +312,26 @@ class CloudDeployTracingStub : public CloudDeployStub { google::cloud::deploy::v1::CancelAutomationRunRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/deploy/v1/mocks/mock_cloud_deploy_connection.h b/google/cloud/deploy/v1/mocks/mock_cloud_deploy_connection.h index 5f7d7b1ec7e18..8956a49c25394 100644 --- a/google/cloud/deploy/v1/mocks/mock_cloud_deploy_connection.h +++ b/google/cloud/deploy/v1/mocks/mock_cloud_deploy_connection.h @@ -697,6 +697,27 @@ class MockCloudDeployConnection : public deploy_v1::CloudDeployConnection { CancelAutomationRun, (google::cloud::deploy::v1::CancelAutomationRunRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/developerconnect/BUILD.bazel b/google/cloud/developerconnect/BUILD.bazel index 22c1f45ea2f9a..6f0e5f5d0c166 100644 --- a/google/cloud/developerconnect/BUILD.bazel +++ b/google/cloud/developerconnect/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/developerconnect/v1:developerconnect_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/developerconnect/v1/developer_connect_client.cc b/google/cloud/developerconnect/v1/developer_connect_client.cc index aed14a4522e3a..9d6e4655fa934 100644 --- a/google/cloud/developerconnect/v1/developer_connect_client.cc +++ b/google/cloud/developerconnect/v1/developer_connect_client.cc @@ -428,6 +428,19 @@ StreamRange DeveloperConnectClient::FetchGitRefs( return connection_->FetchGitRefs(std::move(request)); } +StreamRange +DeveloperConnectClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr DeveloperConnectClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace developerconnect_v1 } // namespace cloud diff --git a/google/cloud/developerconnect/v1/developer_connect_client.h b/google/cloud/developerconnect/v1/developer_connect_client.h index 6afe0caf8b6b4..c5693ceed94c2 100644 --- a/google/cloud/developerconnect/v1/developer_connect_client.h +++ b/google/cloud/developerconnect/v1/developer_connect_client.h @@ -1308,6 +1308,76 @@ class DeveloperConnectClient { google::cloud::developerconnect::v1::FetchGitRefsRequest request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/developerconnect/v1/developer_connect_connection.cc b/google/cloud/developerconnect/v1/developer_connect_connection.cc index 6dbc424fc858d..20b7fceed4972 100644 --- a/google/cloud/developerconnect/v1/developer_connect_connection.cc +++ b/google/cloud/developerconnect/v1/developer_connect_connection.cc @@ -222,6 +222,20 @@ StreamRange DeveloperConnectConnection::FetchGitRefs( StreamRange>(); } +StreamRange +DeveloperConnectConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DeveloperConnectConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDeveloperConnectConnection( Options options) { internal::CheckExpectedOptions +#include #include #include @@ -300,6 +301,12 @@ class DeveloperConnectConnection { virtual StreamRange FetchGitRefs( google::cloud::developerconnect::v1::FetchGitRefsRequest request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/developerconnect/v1/developer_connect_connection_idempotency_policy.cc b/google/cloud/developerconnect/v1/developer_connect_connection_idempotency_policy.cc index fed954bbaf82b..8c8330ecc6f2b 100644 --- a/google/cloud/developerconnect/v1/developer_connect_connection_idempotency_policy.cc +++ b/google/cloud/developerconnect/v1/developer_connect_connection_idempotency_policy.cc @@ -113,6 +113,16 @@ Idempotency DeveloperConnectConnectionIdempotencyPolicy::FetchGitRefs( return Idempotency::kIdempotent; } +Idempotency DeveloperConnectConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DeveloperConnectConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultDeveloperConnectConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/developerconnect/v1/developer_connect_connection_idempotency_policy.h b/google/cloud/developerconnect/v1/developer_connect_connection_idempotency_policy.h index c2b4d4fd98baf..71579a9cf95ef 100644 --- a/google/cloud/developerconnect/v1/developer_connect_connection_idempotency_policy.h +++ b/google/cloud/developerconnect/v1/developer_connect_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -89,6 +90,12 @@ class DeveloperConnectConnectionIdempotencyPolicy { virtual google::cloud::Idempotency FetchGitRefs( google::cloud::developerconnect::v1::FetchGitRefsRequest request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/developerconnect/v1/internal/developer_connect_auth_decorator.cc b/google/cloud/developerconnect/v1/internal/developer_connect_auth_decorator.cc index 018ea19a5e378..3fd45d4adf400 100644 --- a/google/cloud/developerconnect/v1/internal/developer_connect_auth_decorator.cc +++ b/google/cloud/developerconnect/v1/internal/developer_connect_auth_decorator.cc @@ -271,6 +271,23 @@ DeveloperConnectAuth::FetchGitRefs( return child_->FetchGitRefs(context, options, request); } +StatusOr +DeveloperConnectAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr DeveloperConnectAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> DeveloperConnectAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/developerconnect/v1/internal/developer_connect_auth_decorator.h b/google/cloud/developerconnect/v1/internal/developer_connect_auth_decorator.h index 7b57a3b2f87d4..7074fc3e595bc 100644 --- a/google/cloud/developerconnect/v1/internal/developer_connect_auth_decorator.h +++ b/google/cloud/developerconnect/v1/internal/developer_connect_auth_decorator.h @@ -153,6 +153,14 @@ class DeveloperConnectAuth : public DeveloperConnectStub { google::cloud::developerconnect::v1::FetchGitRefsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/developerconnect/v1/internal/developer_connect_connection_impl.cc b/google/cloud/developerconnect/v1/internal/developer_connect_connection_impl.cc index 003cd0a29703d..730d927ae7239 100644 --- a/google/cloud/developerconnect/v1/internal/developer_connect_connection_impl.cc +++ b/google/cloud/developerconnect/v1/internal/developer_connect_connection_impl.cc @@ -775,6 +775,55 @@ StreamRange DeveloperConnectConnectionImpl::FetchGitRefs( }); } +StreamRange +DeveloperConnectConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = + std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DeveloperConnectConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace developerconnect_v1_internal } // namespace cloud diff --git a/google/cloud/developerconnect/v1/internal/developer_connect_connection_impl.h b/google/cloud/developerconnect/v1/internal/developer_connect_connection_impl.h index d4b7dd5533e7f..25a1cfc163097 100644 --- a/google/cloud/developerconnect/v1/internal/developer_connect_connection_impl.h +++ b/google/cloud/developerconnect/v1/internal/developer_connect_connection_impl.h @@ -162,6 +162,12 @@ class DeveloperConnectConnectionImpl google::cloud::developerconnect::v1::FetchGitRefsRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/developerconnect/v1/internal/developer_connect_logging_decorator.cc b/google/cloud/developerconnect/v1/internal/developer_connect_logging_decorator.cc index d04d530d1732a..89528a53e8a28 100644 --- a/google/cloud/developerconnect/v1/internal/developer_connect_logging_decorator.cc +++ b/google/cloud/developerconnect/v1/internal/developer_connect_logging_decorator.cc @@ -330,6 +330,30 @@ DeveloperConnectLogging::FetchGitRefs( context, options, request, __func__, tracing_options_); } +StatusOr +DeveloperConnectLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DeveloperConnectLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> DeveloperConnectLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/developerconnect/v1/internal/developer_connect_logging_decorator.h b/google/cloud/developerconnect/v1/internal/developer_connect_logging_decorator.h index c38fe4d2bc137..c65c58d3e84f8 100644 --- a/google/cloud/developerconnect/v1/internal/developer_connect_logging_decorator.h +++ b/google/cloud/developerconnect/v1/internal/developer_connect_logging_decorator.h @@ -153,6 +153,14 @@ class DeveloperConnectLogging : public DeveloperConnectStub { google::cloud::developerconnect::v1::FetchGitRefsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/developerconnect/v1/internal/developer_connect_metadata_decorator.cc b/google/cloud/developerconnect/v1/internal/developer_connect_metadata_decorator.cc index 3ec9a58fa7d8f..cdde7a96928e3 100644 --- a/google/cloud/developerconnect/v1/internal/developer_connect_metadata_decorator.cc +++ b/google/cloud/developerconnect/v1/internal/developer_connect_metadata_decorator.cc @@ -254,6 +254,24 @@ DeveloperConnectMetadata::FetchGitRefs( return child_->FetchGitRefs(context, options, request); } +StatusOr +DeveloperConnectMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +DeveloperConnectMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> DeveloperConnectMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/developerconnect/v1/internal/developer_connect_metadata_decorator.h b/google/cloud/developerconnect/v1/internal/developer_connect_metadata_decorator.h index 7e27133fe299b..ca899f17a8f20 100644 --- a/google/cloud/developerconnect/v1/internal/developer_connect_metadata_decorator.h +++ b/google/cloud/developerconnect/v1/internal/developer_connect_metadata_decorator.h @@ -154,6 +154,14 @@ class DeveloperConnectMetadata : public DeveloperConnectStub { google::cloud::developerconnect::v1::FetchGitRefsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/developerconnect/v1/internal/developer_connect_stub.cc b/google/cloud/developerconnect/v1/internal/developer_connect_stub.cc index 1881fe070b43a..5168b2309b174 100644 --- a/google/cloud/developerconnect/v1/internal/developer_connect_stub.cc +++ b/google/cloud/developerconnect/v1/internal/developer_connect_stub.cc @@ -318,6 +318,30 @@ DefaultDeveloperConnectStub::FetchGitRefs( return response; } +StatusOr +DefaultDeveloperConnectStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDeveloperConnectStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultDeveloperConnectStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/developerconnect/v1/internal/developer_connect_stub.h b/google/cloud/developerconnect/v1/internal/developer_connect_stub.h index a986da8a0b392..9a0c0eaa8662b 100644 --- a/google/cloud/developerconnect/v1/internal/developer_connect_stub.h +++ b/google/cloud/developerconnect/v1/internal/developer_connect_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -159,6 +161,15 @@ class DeveloperConnectStub { google::cloud::developerconnect::v1::FetchGitRefsRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -178,9 +189,13 @@ class DefaultDeveloperConnectStub : public DeveloperConnectStub { std::unique_ptr< google::cloud::developerconnect::v1::DeveloperConnect::StubInterface> grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListConnections( @@ -296,6 +311,14 @@ class DefaultDeveloperConnectStub : public DeveloperConnectStub { google::cloud::developerconnect::v1::FetchGitRefsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -312,6 +335,8 @@ class DefaultDeveloperConnectStub : public DeveloperConnectStub { std::unique_ptr< google::cloud::developerconnect::v1::DeveloperConnect::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/developerconnect/v1/internal/developer_connect_stub_factory.cc b/google/cloud/developerconnect/v1/internal/developer_connect_stub_factory.cc index 7549f05707b93..7acd6876253e6 100644 --- a/google/cloud/developerconnect/v1/internal/developer_connect_stub_factory.cc +++ b/google/cloud/developerconnect/v1/internal/developer_connect_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultDeveloperConnectStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::developerconnect::v1::DeveloperConnect::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/developerconnect/v1/internal/developer_connect_tracing_connection.cc b/google/cloud/developerconnect/v1/internal/developer_connect_tracing_connection.cc index 76f4156b85f0a..9b021be29e358 100644 --- a/google/cloud/developerconnect/v1/internal/developer_connect_tracing_connection.cc +++ b/google/cloud/developerconnect/v1/internal/developer_connect_tracing_connection.cc @@ -300,6 +300,26 @@ StreamRange DeveloperConnectTracingConnection::FetchGitRefs( std::move(sr)); } +StreamRange +DeveloperConnectTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "developerconnect_v1::DeveloperConnectConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DeveloperConnectTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "developerconnect_v1::DeveloperConnectConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/developerconnect/v1/internal/developer_connect_tracing_connection.h b/google/cloud/developerconnect/v1/internal/developer_connect_tracing_connection.h index 1eea93c938587..2baa18c9a6b6d 100644 --- a/google/cloud/developerconnect/v1/internal/developer_connect_tracing_connection.h +++ b/google/cloud/developerconnect/v1/internal/developer_connect_tracing_connection.h @@ -150,6 +150,12 @@ class DeveloperConnectTracingConnection google::cloud::developerconnect::v1::FetchGitRefsRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/developerconnect/v1/internal/developer_connect_tracing_stub.cc b/google/cloud/developerconnect/v1/internal/developer_connect_tracing_stub.cc index ace3fc2cb6364..ec262b3486a29 100644 --- a/google/cloud/developerconnect/v1/internal/developer_connect_tracing_stub.cc +++ b/google/cloud/developerconnect/v1/internal/developer_connect_tracing_stub.cc @@ -306,6 +306,30 @@ DeveloperConnectTracingStub::FetchGitRefs( child_->FetchGitRefs(context, options, request)); } +StatusOr +DeveloperConnectTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.developerconnect.v1.DeveloperConnect", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +DeveloperConnectTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.developerconnect.v1.DeveloperConnect", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> DeveloperConnectTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/developerconnect/v1/internal/developer_connect_tracing_stub.h b/google/cloud/developerconnect/v1/internal/developer_connect_tracing_stub.h index 38df5612d1abd..9b723e43818ec 100644 --- a/google/cloud/developerconnect/v1/internal/developer_connect_tracing_stub.h +++ b/google/cloud/developerconnect/v1/internal/developer_connect_tracing_stub.h @@ -153,6 +153,14 @@ class DeveloperConnectTracingStub : public DeveloperConnectStub { google::cloud::developerconnect::v1::FetchGitRefsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/developerconnect/v1/mocks/mock_developer_connect_connection.h b/google/cloud/developerconnect/v1/mocks/mock_developer_connect_connection.h index b20d697dd2f52..1b89c01dede89 100644 --- a/google/cloud/developerconnect/v1/mocks/mock_developer_connect_connection.h +++ b/google/cloud/developerconnect/v1/mocks/mock_developer_connect_connection.h @@ -312,6 +312,14 @@ class MockDeveloperConnectConnection (StreamRange), FetchGitRefs, (google::cloud::developerconnect::v1::FetchGitRefsRequest request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/BUILD.bazel b/google/cloud/dialogflow_cx/BUILD.bazel index 4c8a6bba0c1d8..0c64092c883ec 100644 --- a/google/cloud/dialogflow_cx/BUILD.bazel +++ b/google/cloud/dialogflow_cx/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = [""] googleapis_deps = [ "@com_google_googleapis//google/cloud/dialogflow/cx/v3:cx_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/dialogflow_cx/agents_client.cc b/google/cloud/dialogflow_cx/agents_client.cc index 90c6726121468..ed1d7055590f8 100644 --- a/google/cloud/dialogflow_cx/agents_client.cc +++ b/google/cloud/dialogflow_cx/agents_client.cc @@ -220,6 +220,18 @@ AgentsClient::UpdateGenerativeSettings( return connection_->UpdateGenerativeSettings(request); } +StreamRange AgentsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr AgentsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx } // namespace cloud diff --git a/google/cloud/dialogflow_cx/agents_client.h b/google/cloud/dialogflow_cx/agents_client.h index f11f703699b35..9b8ae1ed3e74a 100644 --- a/google/cloud/dialogflow_cx/agents_client.h +++ b/google/cloud/dialogflow_cx/agents_client.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -781,6 +782,76 @@ class AgentsClient { request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_cx/agents_connection.cc b/google/cloud/dialogflow_cx/agents_connection.cc index ec2e26c6de3d3..084195370841c 100644 --- a/google/cloud/dialogflow_cx/agents_connection.cc +++ b/google/cloud/dialogflow_cx/agents_connection.cc @@ -131,6 +131,18 @@ AgentsConnection::UpdateGenerativeSettings( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange AgentsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr AgentsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAgentsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include #include @@ -240,6 +241,12 @@ class AgentsConnection { UpdateGenerativeSettings( google::cloud::dialogflow::cx::v3::UpdateGenerativeSettingsRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_cx/agents_connection_idempotency_policy.cc b/google/cloud/dialogflow_cx/agents_connection_idempotency_policy.cc index 2064f5faf3f8e..75dc7d8c0aa2a 100644 --- a/google/cloud/dialogflow_cx/agents_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/agents_connection_idempotency_policy.cc @@ -89,6 +89,16 @@ Idempotency AgentsConnectionIdempotencyPolicy::UpdateGenerativeSettings( return Idempotency::kNonIdempotent; } +Idempotency AgentsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AgentsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultAgentsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_cx/agents_connection_idempotency_policy.h b/google/cloud/dialogflow_cx/agents_connection_idempotency_policy.h index ace4e588bd575..63e5a662190fd 100644 --- a/google/cloud/dialogflow_cx/agents_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/agents_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -71,6 +72,12 @@ class AgentsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency UpdateGenerativeSettings( google::cloud::dialogflow::cx::v3::UpdateGenerativeSettingsRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_cx/changelogs_client.cc b/google/cloud/dialogflow_cx/changelogs_client.cc index aa95fc1f36e71..9d7437576ca2f 100644 --- a/google/cloud/dialogflow_cx/changelogs_client.cc +++ b/google/cloud/dialogflow_cx/changelogs_client.cc @@ -64,6 +64,18 @@ ChangelogsClient::GetChangelog( return connection_->GetChangelog(request); } +StreamRange ChangelogsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr ChangelogsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx } // namespace cloud diff --git a/google/cloud/dialogflow_cx/changelogs_client.h b/google/cloud/dialogflow_cx/changelogs_client.h index 46366a2ac1a44..169758486b40c 100644 --- a/google/cloud/dialogflow_cx/changelogs_client.h +++ b/google/cloud/dialogflow_cx/changelogs_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -218,6 +219,76 @@ class ChangelogsClient { google::cloud::dialogflow::cx::v3::GetChangelogRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_cx/changelogs_connection.cc b/google/cloud/dialogflow_cx/changelogs_connection.cc index badc5cf62c060..9cc82c726af5d 100644 --- a/google/cloud/dialogflow_cx/changelogs_connection.cc +++ b/google/cloud/dialogflow_cx/changelogs_connection.cc @@ -52,6 +52,19 @@ ChangelogsConnection::GetChangelog( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +ChangelogsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ChangelogsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeChangelogsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include @@ -188,6 +189,12 @@ class ChangelogsConnection { virtual StatusOr GetChangelog( google::cloud::dialogflow::cx::v3::GetChangelogRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_cx/changelogs_connection_idempotency_policy.cc b/google/cloud/dialogflow_cx/changelogs_connection_idempotency_policy.cc index e944ba5adaa12..fcb9e28fee759 100644 --- a/google/cloud/dialogflow_cx/changelogs_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/changelogs_connection_idempotency_policy.cc @@ -44,6 +44,16 @@ Idempotency ChangelogsConnectionIdempotencyPolicy::GetChangelog( return Idempotency::kIdempotent; } +Idempotency ChangelogsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ChangelogsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultChangelogsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_cx/changelogs_connection_idempotency_policy.h b/google/cloud/dialogflow_cx/changelogs_connection_idempotency_policy.h index 88d0c7c49398d..a10f3d3bf1c26 100644 --- a/google/cloud/dialogflow_cx/changelogs_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/changelogs_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -41,6 +42,12 @@ class ChangelogsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GetChangelog( google::cloud::dialogflow::cx::v3::GetChangelogRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_cx/deployments_client.cc b/google/cloud/dialogflow_cx/deployments_client.cc index 732a1ff8cc0d0..96723db576747 100644 --- a/google/cloud/dialogflow_cx/deployments_client.cc +++ b/google/cloud/dialogflow_cx/deployments_client.cc @@ -64,6 +64,18 @@ DeploymentsClient::GetDeployment( return connection_->GetDeployment(request); } +StreamRange DeploymentsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr DeploymentsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx } // namespace cloud diff --git a/google/cloud/dialogflow_cx/deployments_client.h b/google/cloud/dialogflow_cx/deployments_client.h index 44205a09172fe..0328183a16831 100644 --- a/google/cloud/dialogflow_cx/deployments_client.h +++ b/google/cloud/dialogflow_cx/deployments_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -226,6 +227,76 @@ class DeploymentsClient { google::cloud::dialogflow::cx::v3::GetDeploymentRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_cx/deployments_connection.cc b/google/cloud/dialogflow_cx/deployments_connection.cc index 53e311a28207f..31c21877ed73f 100644 --- a/google/cloud/dialogflow_cx/deployments_connection.cc +++ b/google/cloud/dialogflow_cx/deployments_connection.cc @@ -52,6 +52,19 @@ DeploymentsConnection::GetDeployment( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +DeploymentsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr DeploymentsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDeploymentsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include @@ -188,6 +189,12 @@ class DeploymentsConnection { virtual StatusOr GetDeployment( google::cloud::dialogflow::cx::v3::GetDeploymentRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_cx/deployments_connection_idempotency_policy.cc b/google/cloud/dialogflow_cx/deployments_connection_idempotency_policy.cc index 790a01ddeb127..1fbf42c68b1c6 100644 --- a/google/cloud/dialogflow_cx/deployments_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/deployments_connection_idempotency_policy.cc @@ -44,6 +44,16 @@ Idempotency DeploymentsConnectionIdempotencyPolicy::GetDeployment( return Idempotency::kIdempotent; } +Idempotency DeploymentsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DeploymentsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultDeploymentsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_cx/deployments_connection_idempotency_policy.h b/google/cloud/dialogflow_cx/deployments_connection_idempotency_policy.h index 12044e63a466c..8bdc0e3eafc2a 100644 --- a/google/cloud/dialogflow_cx/deployments_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/deployments_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -41,6 +42,12 @@ class DeploymentsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GetDeployment( google::cloud::dialogflow::cx::v3::GetDeploymentRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_cx/entity_types_client.cc b/google/cloud/dialogflow_cx/entity_types_client.cc index 42230bf48ab31..3b418d993d021 100644 --- a/google/cloud/dialogflow_cx/entity_types_client.cc +++ b/google/cloud/dialogflow_cx/entity_types_client.cc @@ -164,6 +164,18 @@ EntityTypesClient::ImportEntityTypes( return connection_->ImportEntityTypes(operation); } +StreamRange EntityTypesClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr EntityTypesClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx } // namespace cloud diff --git a/google/cloud/dialogflow_cx/entity_types_client.h b/google/cloud/dialogflow_cx/entity_types_client.h index 8208123afb7f1..cd9bc83c22049 100644 --- a/google/cloud/dialogflow_cx/entity_types_client.h +++ b/google/cloud/dialogflow_cx/entity_types_client.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -555,6 +556,76 @@ class EntityTypesClient { ImportEntityTypes(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_cx/entity_types_connection.cc b/google/cloud/dialogflow_cx/entity_types_connection.cc index aed84faaf4e12..4630ad5f7a8d1 100644 --- a/google/cloud/dialogflow_cx/entity_types_connection.cc +++ b/google/cloud/dialogflow_cx/entity_types_connection.cc @@ -117,6 +117,19 @@ EntityTypesConnection::ImportEntityTypes( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +EntityTypesConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr EntityTypesConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeEntityTypesConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include #include @@ -236,6 +237,12 @@ class EntityTypesConnection { virtual future< StatusOr> ImportEntityTypes(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_cx/entity_types_connection_idempotency_policy.cc b/google/cloud/dialogflow_cx/entity_types_connection_idempotency_policy.cc index 7883e0554c556..5101fadea4d4e 100644 --- a/google/cloud/dialogflow_cx/entity_types_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/entity_types_connection_idempotency_policy.cc @@ -69,6 +69,16 @@ Idempotency EntityTypesConnectionIdempotencyPolicy::ImportEntityTypes( return Idempotency::kNonIdempotent; } +Idempotency EntityTypesConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency EntityTypesConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultEntityTypesConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_cx/entity_types_connection_idempotency_policy.h b/google/cloud/dialogflow_cx/entity_types_connection_idempotency_policy.h index 8d130cd02b97a..326a54b9a07c3 100644 --- a/google/cloud/dialogflow_cx/entity_types_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/entity_types_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -61,6 +62,12 @@ class EntityTypesConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ImportEntityTypes( google::cloud::dialogflow::cx::v3::ImportEntityTypesRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_cx/environments_client.cc b/google/cloud/dialogflow_cx/environments_client.cc index 11248bc3fe67f..79f6d9f22da4d 100644 --- a/google/cloud/dialogflow_cx/environments_client.cc +++ b/google/cloud/dialogflow_cx/environments_client.cc @@ -250,6 +250,19 @@ EnvironmentsClient::DeployFlow(google::longrunning::Operation const& operation, return connection_->DeployFlow(operation); } +StreamRange +EnvironmentsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr EnvironmentsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx } // namespace cloud diff --git a/google/cloud/dialogflow_cx/environments_client.h b/google/cloud/dialogflow_cx/environments_client.h index 2429c0699e72f..9832d2b15630d 100644 --- a/google/cloud/dialogflow_cx/environments_client.h +++ b/google/cloud/dialogflow_cx/environments_client.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -883,6 +884,76 @@ class EnvironmentsClient { DeployFlow(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_cx/environments_connection.cc b/google/cloud/dialogflow_cx/environments_connection.cc index 0c74f934db5bc..0fafc85b90c67 100644 --- a/google/cloud/dialogflow_cx/environments_connection.cc +++ b/google/cloud/dialogflow_cx/environments_connection.cc @@ -166,6 +166,19 @@ EnvironmentsConnection::DeployFlow(google::longrunning::Operation const&) { Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +EnvironmentsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr EnvironmentsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeEnvironmentsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include #include @@ -263,6 +264,12 @@ class EnvironmentsConnection { virtual future< StatusOr> DeployFlow(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_cx/environments_connection_idempotency_policy.cc b/google/cloud/dialogflow_cx/environments_connection_idempotency_policy.cc index f1a393cd49359..f19ab64a647bb 100644 --- a/google/cloud/dialogflow_cx/environments_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/environments_connection_idempotency_policy.cc @@ -81,6 +81,16 @@ Idempotency EnvironmentsConnectionIdempotencyPolicy::DeployFlow( return Idempotency::kNonIdempotent; } +Idempotency EnvironmentsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency EnvironmentsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultEnvironmentsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_cx/environments_connection_idempotency_policy.h b/google/cloud/dialogflow_cx/environments_connection_idempotency_policy.h index f7ba2c749f5ea..d0ff7997b2bde 100644 --- a/google/cloud/dialogflow_cx/environments_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/environments_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -69,6 +70,12 @@ class EnvironmentsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeployFlow( google::cloud::dialogflow::cx::v3::DeployFlowRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_cx/experiments_client.cc b/google/cloud/dialogflow_cx/experiments_client.cc index 7826bed92956f..e9d4d5080c4a7 100644 --- a/google/cloud/dialogflow_cx/experiments_client.cc +++ b/google/cloud/dialogflow_cx/experiments_client.cc @@ -150,6 +150,18 @@ ExperimentsClient::StopExperiment( return connection_->StopExperiment(request); } +StreamRange ExperimentsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr ExperimentsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx } // namespace cloud diff --git a/google/cloud/dialogflow_cx/experiments_client.h b/google/cloud/dialogflow_cx/experiments_client.h index 5356c9ece58e0..36b05db9699a8 100644 --- a/google/cloud/dialogflow_cx/experiments_client.h +++ b/google/cloud/dialogflow_cx/experiments_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -524,6 +525,76 @@ class ExperimentsClient { google::cloud::dialogflow::cx::v3::StopExperimentRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_cx/experiments_connection.cc b/google/cloud/dialogflow_cx/experiments_connection.cc index da95eadc79418..482c5536b244c 100644 --- a/google/cloud/dialogflow_cx/experiments_connection.cc +++ b/google/cloud/dialogflow_cx/experiments_connection.cc @@ -81,6 +81,19 @@ ExperimentsConnection::StopExperiment( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +ExperimentsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ExperimentsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeExperimentsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include @@ -210,6 +211,12 @@ class ExperimentsConnection { virtual StatusOr StopExperiment( google::cloud::dialogflow::cx::v3::StopExperimentRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_cx/experiments_connection_idempotency_policy.cc b/google/cloud/dialogflow_cx/experiments_connection_idempotency_policy.cc index be29aa6dfd660..8a31c0ae928f0 100644 --- a/google/cloud/dialogflow_cx/experiments_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/experiments_connection_idempotency_policy.cc @@ -69,6 +69,16 @@ Idempotency ExperimentsConnectionIdempotencyPolicy::StopExperiment( return Idempotency::kNonIdempotent; } +Idempotency ExperimentsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ExperimentsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultExperimentsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_cx/experiments_connection_idempotency_policy.h b/google/cloud/dialogflow_cx/experiments_connection_idempotency_policy.h index 19f86fafc4222..7922cfc8add96 100644 --- a/google/cloud/dialogflow_cx/experiments_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/experiments_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -59,6 +60,12 @@ class ExperimentsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency StopExperiment( google::cloud::dialogflow::cx::v3::StopExperimentRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_cx/flows_client.cc b/google/cloud/dialogflow_cx/flows_client.cc index f41fd9a2f79d5..da4469bb4154f 100644 --- a/google/cloud/dialogflow_cx/flows_client.cc +++ b/google/cloud/dialogflow_cx/flows_client.cc @@ -217,6 +217,18 @@ FlowsClient::ExportFlow(google::longrunning::Operation const& operation, return connection_->ExportFlow(operation); } +StreamRange FlowsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr FlowsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx } // namespace cloud diff --git a/google/cloud/dialogflow_cx/flows_client.h b/google/cloud/dialogflow_cx/flows_client.h index dbcf977538405..60a77eaeb7ed4 100644 --- a/google/cloud/dialogflow_cx/flows_client.h +++ b/google/cloud/dialogflow_cx/flows_client.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -802,6 +803,76 @@ class FlowsClient { ExportFlow(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_cx/flows_connection.cc b/google/cloud/dialogflow_cx/flows_connection.cc index 3a0a53de8c8a2..9a12b046f6a27 100644 --- a/google/cloud/dialogflow_cx/flows_connection.cc +++ b/google/cloud/dialogflow_cx/flows_connection.cc @@ -137,6 +137,18 @@ FlowsConnection::ExportFlow(google::longrunning::Operation const&) { Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange FlowsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr FlowsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeFlowsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include #include @@ -243,6 +244,12 @@ class FlowsConnection { virtual future< StatusOr> ExportFlow(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_cx/flows_connection_idempotency_policy.cc b/google/cloud/dialogflow_cx/flows_connection_idempotency_policy.cc index 5a03208b4445d..1f86b4b178a5b 100644 --- a/google/cloud/dialogflow_cx/flows_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/flows_connection_idempotency_policy.cc @@ -83,6 +83,16 @@ Idempotency FlowsConnectionIdempotencyPolicy::ExportFlow( return Idempotency::kNonIdempotent; } +Idempotency FlowsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency FlowsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultFlowsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_cx/flows_connection_idempotency_policy.h b/google/cloud/dialogflow_cx/flows_connection_idempotency_policy.h index b8f023a97b2ef..4e6165cd8888f 100644 --- a/google/cloud/dialogflow_cx/flows_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/flows_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -66,6 +67,12 @@ class FlowsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ExportFlow( google::cloud::dialogflow::cx::v3::ExportFlowRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_cx/generators_client.cc b/google/cloud/dialogflow_cx/generators_client.cc index 41996a46a813c..fb5ddb3157daa 100644 --- a/google/cloud/dialogflow_cx/generators_client.cc +++ b/google/cloud/dialogflow_cx/generators_client.cc @@ -118,6 +118,18 @@ Status GeneratorsClient::DeleteGenerator( return connection_->DeleteGenerator(request); } +StreamRange GeneratorsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr GeneratorsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx } // namespace cloud diff --git a/google/cloud/dialogflow_cx/generators_client.h b/google/cloud/dialogflow_cx/generators_client.h index 55d234d0c1531..8896fa6d69321 100644 --- a/google/cloud/dialogflow_cx/generators_client.h +++ b/google/cloud/dialogflow_cx/generators_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -387,6 +388,76 @@ class GeneratorsClient { google::cloud::dialogflow::cx::v3::DeleteGeneratorRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_cx/generators_connection.cc b/google/cloud/dialogflow_cx/generators_connection.cc index d3b7480ce4bc6..59ddb5904b068 100644 --- a/google/cloud/dialogflow_cx/generators_connection.cc +++ b/google/cloud/dialogflow_cx/generators_connection.cc @@ -69,6 +69,19 @@ Status GeneratorsConnection::DeleteGenerator( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +GeneratorsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr GeneratorsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeGeneratorsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include @@ -199,6 +200,12 @@ class GeneratorsConnection { virtual Status DeleteGenerator( google::cloud::dialogflow::cx::v3::DeleteGeneratorRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_cx/generators_connection_idempotency_policy.cc b/google/cloud/dialogflow_cx/generators_connection_idempotency_policy.cc index 4530daea3c031..4a56a5042ca2e 100644 --- a/google/cloud/dialogflow_cx/generators_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/generators_connection_idempotency_policy.cc @@ -59,6 +59,16 @@ Idempotency GeneratorsConnectionIdempotencyPolicy::DeleteGenerator( return Idempotency::kNonIdempotent; } +Idempotency GeneratorsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency GeneratorsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultGeneratorsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_cx/generators_connection_idempotency_policy.h b/google/cloud/dialogflow_cx/generators_connection_idempotency_policy.h index 35edeca6bc66b..7b5749bf23cc3 100644 --- a/google/cloud/dialogflow_cx/generators_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/generators_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -50,6 +51,12 @@ class GeneratorsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteGenerator( google::cloud::dialogflow::cx::v3::DeleteGeneratorRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_cx/intents_client.cc b/google/cloud/dialogflow_cx/intents_client.cc index 24402a535fc9c..ac804fbacc981 100644 --- a/google/cloud/dialogflow_cx/intents_client.cc +++ b/google/cloud/dialogflow_cx/intents_client.cc @@ -157,6 +157,18 @@ IntentsClient::ExportIntents(google::longrunning::Operation const& operation, return connection_->ExportIntents(operation); } +StreamRange IntentsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr IntentsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx } // namespace cloud diff --git a/google/cloud/dialogflow_cx/intents_client.h b/google/cloud/dialogflow_cx/intents_client.h index ff184e73db016..563b24fa8bf92 100644 --- a/google/cloud/dialogflow_cx/intents_client.h +++ b/google/cloud/dialogflow_cx/intents_client.h @@ -570,6 +570,76 @@ class IntentsClient { ExportIntents(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_cx/intents_connection.cc b/google/cloud/dialogflow_cx/intents_connection.cc index 60c7e0d4d118e..14c4775ad69a0 100644 --- a/google/cloud/dialogflow_cx/intents_connection.cc +++ b/google/cloud/dialogflow_cx/intents_connection.cc @@ -113,6 +113,18 @@ IntentsConnection::ExportIntents(google::longrunning::Operation const&) { Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange IntentsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr IntentsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeIntentsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include #include @@ -224,6 +225,12 @@ class IntentsConnection { virtual future< StatusOr> ExportIntents(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_cx/intents_connection_idempotency_policy.cc b/google/cloud/dialogflow_cx/intents_connection_idempotency_policy.cc index 83b04116e9ac6..30fdab85bcb52 100644 --- a/google/cloud/dialogflow_cx/intents_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/intents_connection_idempotency_policy.cc @@ -69,6 +69,16 @@ Idempotency IntentsConnectionIdempotencyPolicy::ExportIntents( return Idempotency::kNonIdempotent; } +Idempotency IntentsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency IntentsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultIntentsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_cx/intents_connection_idempotency_policy.h b/google/cloud/dialogflow_cx/intents_connection_idempotency_policy.h index 619ee3ce17375..d6f6ad9472061 100644 --- a/google/cloud/dialogflow_cx/intents_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/intents_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -56,6 +57,12 @@ class IntentsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ExportIntents( google::cloud::dialogflow::cx::v3::ExportIntentsRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_cx/internal/agents_auth_decorator.cc b/google/cloud/dialogflow_cx/internal/agents_auth_decorator.cc index 3eea558192335..bbf9f5ae39558 100644 --- a/google/cloud/dialogflow_cx/internal/agents_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/agents_auth_decorator.cc @@ -165,6 +165,23 @@ AgentsAuth::UpdateGenerativeSettings( return child_->UpdateGenerativeSettings(context, options, request); } +StatusOr +AgentsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr AgentsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> AgentsAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/agents_auth_decorator.h b/google/cloud/dialogflow_cx/internal/agents_auth_decorator.h index 3dff5bd181f11..b42aae838132b 100644 --- a/google/cloud/dialogflow_cx/internal/agents_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/agents_auth_decorator.h @@ -111,6 +111,14 @@ class AgentsAuth : public AgentsStub { google::cloud::dialogflow::cx::v3::UpdateGenerativeSettingsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/agents_connection_impl.cc b/google/cloud/dialogflow_cx/internal/agents_connection_impl.cc index 5853a18595b75..9c97a198ec75d 100644 --- a/google/cloud/dialogflow_cx/internal/agents_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/agents_connection_impl.cc @@ -398,6 +398,53 @@ AgentsConnectionImpl::UpdateGenerativeSettings( *current, request, __func__); } +StreamRange +AgentsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr AgentsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/agents_connection_impl.h b/google/cloud/dialogflow_cx/internal/agents_connection_impl.h index 7b89086693dbf..fc47aeef7400a 100644 --- a/google/cloud/dialogflow_cx/internal/agents_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/agents_connection_impl.h @@ -113,6 +113,12 @@ class AgentsConnectionImpl : public dialogflow_cx::AgentsConnection { google::cloud::dialogflow::cx::v3::UpdateGenerativeSettingsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_cx/internal/agents_logging_decorator.cc b/google/cloud/dialogflow_cx/internal/agents_logging_decorator.cc index cba712cba2f4c..1af6590222d4b 100644 --- a/google/cloud/dialogflow_cx/internal/agents_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/agents_logging_decorator.cc @@ -214,6 +214,29 @@ AgentsLogging::UpdateGenerativeSettings( context, options, request, __func__, tracing_options_); } +StatusOr +AgentsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AgentsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> AgentsLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/agents_logging_decorator.h b/google/cloud/dialogflow_cx/internal/agents_logging_decorator.h index dda3b8ac5be62..d30cee657f733 100644 --- a/google/cloud/dialogflow_cx/internal/agents_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/agents_logging_decorator.h @@ -111,6 +111,14 @@ class AgentsLogging : public AgentsStub { google::cloud::dialogflow::cx::v3::UpdateGenerativeSettingsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/agents_metadata_decorator.cc b/google/cloud/dialogflow_cx/internal/agents_metadata_decorator.cc index b82d986b8b2da..dd8ff96b73d33 100644 --- a/google/cloud/dialogflow_cx/internal/agents_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/agents_metadata_decorator.cc @@ -167,6 +167,23 @@ AgentsMetadata::UpdateGenerativeSettings( return child_->UpdateGenerativeSettings(context, options, request); } +StatusOr +AgentsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr AgentsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> AgentsMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/agents_metadata_decorator.h b/google/cloud/dialogflow_cx/internal/agents_metadata_decorator.h index 24a088dd15168..61764179daca3 100644 --- a/google/cloud/dialogflow_cx/internal/agents_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/agents_metadata_decorator.h @@ -111,6 +111,14 @@ class AgentsMetadata : public AgentsStub { google::cloud::dialogflow::cx::v3::UpdateGenerativeSettingsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/agents_stub.cc b/google/cloud/dialogflow_cx/internal/agents_stub.cc index 1d5876fb2951d..fa1abba5b7979 100644 --- a/google/cloud/dialogflow_cx/internal/agents_stub.cc +++ b/google/cloud/dialogflow_cx/internal/agents_stub.cc @@ -202,6 +202,29 @@ DefaultAgentsStub::UpdateGenerativeSettings( return response; } +StatusOr +DefaultAgentsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAgentsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultAgentsStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/agents_stub.h b/google/cloud/dialogflow_cx/internal/agents_stub.h index 995e0203b49c7..194e15b3cf1f9 100644 --- a/google/cloud/dialogflow_cx/internal/agents_stub.h +++ b/google/cloud/dialogflow_cx/internal/agents_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -105,6 +107,15 @@ class AgentsStub { google::cloud::dialogflow::cx::v3::UpdateGenerativeSettingsRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -123,9 +134,13 @@ class DefaultAgentsStub : public AgentsStub { DefaultAgentsStub( std::unique_ptr grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListAgents( grpc::ClientContext& context, Options const& options, @@ -199,6 +214,14 @@ class DefaultAgentsStub : public AgentsStub { google::cloud::dialogflow::cx::v3::UpdateGenerativeSettingsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -214,6 +237,8 @@ class DefaultAgentsStub : public AgentsStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/dialogflow_cx/internal/agents_stub_factory.cc b/google/cloud/dialogflow_cx/internal/agents_stub_factory.cc index 7fe45ac5a4990..1d859b6b56b48 100644 --- a/google/cloud/dialogflow_cx/internal/agents_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/agents_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,8 +45,10 @@ std::shared_ptr CreateDefaultAgentsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::Agents::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/dialogflow_cx/internal/agents_tracing_connection.cc b/google/cloud/dialogflow_cx/internal/agents_tracing_connection.cc index 41b92af0b23a0..805d65be9703c 100644 --- a/google/cloud/dialogflow_cx/internal/agents_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/agents_tracing_connection.cc @@ -170,6 +170,26 @@ AgentsTracingConnection::UpdateGenerativeSettings( return internal::EndSpan(*span, child_->UpdateGenerativeSettings(request)); } +StreamRange +AgentsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_cx::AgentsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AgentsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::AgentsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeAgentsTracingConnection( diff --git a/google/cloud/dialogflow_cx/internal/agents_tracing_connection.h b/google/cloud/dialogflow_cx/internal/agents_tracing_connection.h index c12203422e674..2b6021c5c3a3e 100644 --- a/google/cloud/dialogflow_cx/internal/agents_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/agents_tracing_connection.h @@ -101,6 +101,12 @@ class AgentsTracingConnection : public dialogflow_cx::AgentsConnection { google::cloud::dialogflow::cx::v3::UpdateGenerativeSettingsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_cx/internal/agents_tracing_stub.cc b/google/cloud/dialogflow_cx/internal/agents_tracing_stub.cc index 6e2efcfef106c..8f036b6e20896 100644 --- a/google/cloud/dialogflow_cx/internal/agents_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/agents_tracing_stub.cc @@ -192,6 +192,29 @@ AgentsTracingStub::UpdateGenerativeSettings( child_->UpdateGenerativeSettings(context, options, request)); } +StatusOr +AgentsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Agents", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr AgentsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Agents", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> AgentsTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/agents_tracing_stub.h b/google/cloud/dialogflow_cx/internal/agents_tracing_stub.h index 7d083d6a9ae2f..30d1aa5e325fb 100644 --- a/google/cloud/dialogflow_cx/internal/agents_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/agents_tracing_stub.h @@ -110,6 +110,14 @@ class AgentsTracingStub : public AgentsStub { google::cloud::dialogflow::cx::v3::UpdateGenerativeSettingsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/changelogs_auth_decorator.cc b/google/cloud/dialogflow_cx/internal/changelogs_auth_decorator.cc index 3ee6912d91f88..055f6755bd5f9 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/changelogs_auth_decorator.cc @@ -49,6 +49,23 @@ ChangelogsAuth::GetChangelog( return child_->GetChangelog(context, options, request); } +StatusOr +ChangelogsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr ChangelogsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/changelogs_auth_decorator.h b/google/cloud/dialogflow_cx/internal/changelogs_auth_decorator.h index 2ed6a0c0857ce..e6ed50dd0d469 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/changelogs_auth_decorator.h @@ -48,6 +48,14 @@ class ChangelogsAuth : public ChangelogsStub { google::cloud::dialogflow::cx::v3::GetChangelogRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/dialogflow_cx/internal/changelogs_connection_impl.cc b/google/cloud/dialogflow_cx/internal/changelogs_connection_impl.cc index 883ee6de0db9a..b1d4e7707fca6 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/changelogs_connection_impl.cc @@ -109,6 +109,54 @@ ChangelogsConnectionImpl::GetChangelog( *current, request, __func__); } +StreamRange +ChangelogsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ChangelogsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/changelogs_connection_impl.h b/google/cloud/dialogflow_cx/internal/changelogs_connection_impl.h index c75576573c172..9b579ab9c9f7d 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/changelogs_connection_impl.h @@ -56,6 +56,12 @@ class ChangelogsConnectionImpl : public dialogflow_cx::ChangelogsConnection { google::cloud::dialogflow::cx::v3::GetChangelogRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_cx/internal/changelogs_logging_decorator.cc b/google/cloud/dialogflow_cx/internal/changelogs_logging_decorator.cc index 291d6e8fefb96..965d7fa67a327 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/changelogs_logging_decorator.cc @@ -61,6 +61,29 @@ ChangelogsLogging::GetChangelog( context, options, request, __func__, tracing_options_); } +StatusOr +ChangelogsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ChangelogsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/changelogs_logging_decorator.h b/google/cloud/dialogflow_cx/internal/changelogs_logging_decorator.h index 1d608e50c4a96..889bcdd4fe610 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/changelogs_logging_decorator.h @@ -48,6 +48,14 @@ class ChangelogsLogging : public ChangelogsStub { google::cloud::dialogflow::cx::v3::GetChangelogRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/dialogflow_cx/internal/changelogs_metadata_decorator.cc b/google/cloud/dialogflow_cx/internal/changelogs_metadata_decorator.cc index 763849ed342d1..a095e64880ae9 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/changelogs_metadata_decorator.cc @@ -62,6 +62,23 @@ ChangelogsMetadata::GetChangelog( return child_->GetChangelog(context, options, request); } +StatusOr +ChangelogsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr ChangelogsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void ChangelogsMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/dialogflow_cx/internal/changelogs_metadata_decorator.h b/google/cloud/dialogflow_cx/internal/changelogs_metadata_decorator.h index f5e24c4ac8d01..28ef344e1ffbd 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/changelogs_metadata_decorator.h @@ -48,6 +48,14 @@ class ChangelogsMetadata : public ChangelogsStub { google::cloud::dialogflow::cx::v3::GetChangelogRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/dialogflow_cx/internal/changelogs_stub.cc b/google/cloud/dialogflow_cx/internal/changelogs_stub.cc index 84b50de14879b..e64ca2b225bd1 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_stub.cc +++ b/google/cloud/dialogflow_cx/internal/changelogs_stub.cc @@ -54,6 +54,29 @@ DefaultChangelogsStub::GetChangelog( return response; } +StatusOr +DefaultChangelogsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultChangelogsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/changelogs_stub.h b/google/cloud/dialogflow_cx/internal/changelogs_stub.h index 4f47f47695bd0..bcda67926f17e 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_stub.h +++ b/google/cloud/dialogflow_cx/internal/changelogs_stub.h @@ -23,6 +23,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -44,6 +46,15 @@ class ChangelogsStub { grpc::ClientContext& context, Options const& options, google::cloud::dialogflow::cx::v3::GetChangelogRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultChangelogsStub : public ChangelogsStub { @@ -51,8 +62,11 @@ class DefaultChangelogsStub : public ChangelogsStub { explicit DefaultChangelogsStub( std::unique_ptr< google::cloud::dialogflow::cx::v3::Changelogs::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListChangelogs(grpc::ClientContext& context, Options const& options, @@ -64,9 +78,19 @@ class DefaultChangelogsStub : public ChangelogsStub { google::cloud::dialogflow::cx::v3::GetChangelogRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/internal/changelogs_stub_factory.cc b/google/cloud/dialogflow_cx/internal/changelogs_stub_factory.cc index 5792a3ab9d162..68187a68dd7ee 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/changelogs_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,8 +45,11 @@ std::shared_ptr CreateDefaultChangelogsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::Changelogs::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + std::make_shared( + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), std::move(stub)); diff --git a/google/cloud/dialogflow_cx/internal/changelogs_tracing_connection.cc b/google/cloud/dialogflow_cx/internal/changelogs_tracing_connection.cc index 30dcff1f900d1..cf376d1e8e996 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/changelogs_tracing_connection.cc @@ -54,6 +54,26 @@ ChangelogsTracingConnection::GetChangelog( return internal::EndSpan(*span, child_->GetChangelog(request)); } +StreamRange +ChangelogsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_cx::ChangelogsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ChangelogsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::ChangelogsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_cx/internal/changelogs_tracing_connection.h b/google/cloud/dialogflow_cx/internal/changelogs_tracing_connection.h index 3625196c34ca9..4beb1d50601f3 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/changelogs_tracing_connection.h @@ -47,6 +47,12 @@ class ChangelogsTracingConnection : public dialogflow_cx::ChangelogsConnection { google::cloud::dialogflow::cx::v3::GetChangelogRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_cx/internal/changelogs_tracing_stub.cc b/google/cloud/dialogflow_cx/internal/changelogs_tracing_stub.cc index 5678c9ced9bd0..ddc20e6af28d9 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/changelogs_tracing_stub.cc @@ -56,6 +56,29 @@ ChangelogsTracingStub::GetChangelog( child_->GetChangelog(context, options, request)); } +StatusOr +ChangelogsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Changelogs", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr ChangelogsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Changelogs", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeChangelogsTracingStub( diff --git a/google/cloud/dialogflow_cx/internal/changelogs_tracing_stub.h b/google/cloud/dialogflow_cx/internal/changelogs_tracing_stub.h index d657ebe32f0ad..6ffcfb7502425 100644 --- a/google/cloud/dialogflow_cx/internal/changelogs_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/changelogs_tracing_stub.h @@ -48,6 +48,14 @@ class ChangelogsTracingStub : public ChangelogsStub { google::cloud::dialogflow::cx::v3::GetChangelogRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/dialogflow_cx/internal/deployments_auth_decorator.cc b/google/cloud/dialogflow_cx/internal/deployments_auth_decorator.cc index 4b4a1c8fd0c2d..31663f306de83 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/deployments_auth_decorator.cc @@ -49,6 +49,23 @@ DeploymentsAuth::GetDeployment( return child_->GetDeployment(context, options, request); } +StatusOr +DeploymentsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr DeploymentsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/deployments_auth_decorator.h b/google/cloud/dialogflow_cx/internal/deployments_auth_decorator.h index fad7a244a1e3a..8a79cf4572335 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/deployments_auth_decorator.h @@ -49,6 +49,14 @@ class DeploymentsAuth : public DeploymentsStub { google::cloud::dialogflow::cx::v3::GetDeploymentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/dialogflow_cx/internal/deployments_connection_impl.cc b/google/cloud/dialogflow_cx/internal/deployments_connection_impl.cc index 17fe7f0bb5bd6..963ba4e62f845 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/deployments_connection_impl.cc @@ -109,6 +109,54 @@ DeploymentsConnectionImpl::GetDeployment( *current, request, __func__); } +StreamRange +DeploymentsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DeploymentsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/deployments_connection_impl.h b/google/cloud/dialogflow_cx/internal/deployments_connection_impl.h index ace6ef2e1abbe..cd5dbe8420510 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/deployments_connection_impl.h @@ -56,6 +56,12 @@ class DeploymentsConnectionImpl : public dialogflow_cx::DeploymentsConnection { google::cloud::dialogflow::cx::v3::GetDeploymentRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_cx/internal/deployments_logging_decorator.cc b/google/cloud/dialogflow_cx/internal/deployments_logging_decorator.cc index ffa8518ea4340..87a94c6a8351d 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/deployments_logging_decorator.cc @@ -61,6 +61,29 @@ DeploymentsLogging::GetDeployment( context, options, request, __func__, tracing_options_); } +StatusOr +DeploymentsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DeploymentsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/deployments_logging_decorator.h b/google/cloud/dialogflow_cx/internal/deployments_logging_decorator.h index 731f0c696a26a..c219d3a812785 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/deployments_logging_decorator.h @@ -49,6 +49,14 @@ class DeploymentsLogging : public DeploymentsStub { google::cloud::dialogflow::cx::v3::GetDeploymentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/dialogflow_cx/internal/deployments_metadata_decorator.cc b/google/cloud/dialogflow_cx/internal/deployments_metadata_decorator.cc index 818c1f261aaea..7045630de9c89 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/deployments_metadata_decorator.cc @@ -62,6 +62,23 @@ DeploymentsMetadata::GetDeployment( return child_->GetDeployment(context, options, request); } +StatusOr +DeploymentsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr DeploymentsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void DeploymentsMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/dialogflow_cx/internal/deployments_metadata_decorator.h b/google/cloud/dialogflow_cx/internal/deployments_metadata_decorator.h index 681c8e639d8b9..3bb5452615f20 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/deployments_metadata_decorator.h @@ -49,6 +49,14 @@ class DeploymentsMetadata : public DeploymentsStub { google::cloud::dialogflow::cx::v3::GetDeploymentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/dialogflow_cx/internal/deployments_stub.cc b/google/cloud/dialogflow_cx/internal/deployments_stub.cc index f4467242bec55..0e2a69075305d 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_stub.cc +++ b/google/cloud/dialogflow_cx/internal/deployments_stub.cc @@ -54,6 +54,29 @@ DefaultDeploymentsStub::GetDeployment( return response; } +StatusOr +DefaultDeploymentsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultDeploymentsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/deployments_stub.h b/google/cloud/dialogflow_cx/internal/deployments_stub.h index 4ee7b40dd28d9..e1fb3c809d9a1 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_stub.h +++ b/google/cloud/dialogflow_cx/internal/deployments_stub.h @@ -23,6 +23,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -45,6 +47,15 @@ class DeploymentsStub { grpc::ClientContext& context, Options const& options, google::cloud::dialogflow::cx::v3::GetDeploymentRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultDeploymentsStub : public DeploymentsStub { @@ -52,8 +63,11 @@ class DefaultDeploymentsStub : public DeploymentsStub { explicit DefaultDeploymentsStub( std::unique_ptr< google::cloud::dialogflow::cx::v3::Deployments::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListDeployments( @@ -66,9 +80,19 @@ class DefaultDeploymentsStub : public DeploymentsStub { google::cloud::dialogflow::cx::v3::GetDeploymentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/internal/deployments_stub_factory.cc b/google/cloud/dialogflow_cx/internal/deployments_stub_factory.cc index ed9dac1095626..2e5e6b3891748 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/deployments_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,8 +45,11 @@ std::shared_ptr CreateDefaultDeploymentsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::Deployments::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + std::make_shared( + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), std::move(stub)); diff --git a/google/cloud/dialogflow_cx/internal/deployments_tracing_connection.cc b/google/cloud/dialogflow_cx/internal/deployments_tracing_connection.cc index 643570f17b0c0..869953be4b68b 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/deployments_tracing_connection.cc @@ -54,6 +54,26 @@ DeploymentsTracingConnection::GetDeployment( return internal::EndSpan(*span, child_->GetDeployment(request)); } +StreamRange +DeploymentsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_cx::DeploymentsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DeploymentsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::DeploymentsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_cx/internal/deployments_tracing_connection.h b/google/cloud/dialogflow_cx/internal/deployments_tracing_connection.h index d567d4800e108..4334faea84964 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/deployments_tracing_connection.h @@ -48,6 +48,12 @@ class DeploymentsTracingConnection google::cloud::dialogflow::cx::v3::GetDeploymentRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_cx/internal/deployments_tracing_stub.cc b/google/cloud/dialogflow_cx/internal/deployments_tracing_stub.cc index 60eadf1d93d24..57528107232b5 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/deployments_tracing_stub.cc @@ -56,6 +56,29 @@ DeploymentsTracingStub::GetDeployment( child_->GetDeployment(context, options, request)); } +StatusOr +DeploymentsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.Deployments", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr DeploymentsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.Deployments", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeDeploymentsTracingStub( diff --git a/google/cloud/dialogflow_cx/internal/deployments_tracing_stub.h b/google/cloud/dialogflow_cx/internal/deployments_tracing_stub.h index 33d04c622da4e..a2573ede664ef 100644 --- a/google/cloud/dialogflow_cx/internal/deployments_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/deployments_tracing_stub.h @@ -49,6 +49,14 @@ class DeploymentsTracingStub : public DeploymentsStub { google::cloud::dialogflow::cx::v3::GetDeploymentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/dialogflow_cx/internal/entity_types_auth_decorator.cc b/google/cloud/dialogflow_cx/internal/entity_types_auth_decorator.cc index 93f5796730b2d..7d49ee72ae588 100644 --- a/google/cloud/dialogflow_cx/internal/entity_types_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/entity_types_auth_decorator.cc @@ -135,6 +135,23 @@ StatusOr EntityTypesAuth::ImportEntityTypes( return child_->ImportEntityTypes(context, options, request); } +StatusOr +EntityTypesAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr EntityTypesAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> EntityTypesAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/entity_types_auth_decorator.h b/google/cloud/dialogflow_cx/internal/entity_types_auth_decorator.h index f297accece6c6..e4e2d24607b78 100644 --- a/google/cloud/dialogflow_cx/internal/entity_types_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/entity_types_auth_decorator.h @@ -89,6 +89,14 @@ class EntityTypesAuth : public EntityTypesStub { google::cloud::dialogflow::cx::v3::ImportEntityTypesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/entity_types_connection_impl.cc b/google/cloud/dialogflow_cx/internal/entity_types_connection_impl.cc index a31830c87c599..1279a56f497c0 100644 --- a/google/cloud/dialogflow_cx/internal/entity_types_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/entity_types_connection_impl.cc @@ -350,6 +350,54 @@ EntityTypesConnectionImpl::ImportEntityTypes( polling_policy(*current), __func__); } +StreamRange +EntityTypesConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +EntityTypesConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/entity_types_connection_impl.h b/google/cloud/dialogflow_cx/internal/entity_types_connection_impl.h index db07386891db6..744ff11eb3413 100644 --- a/google/cloud/dialogflow_cx/internal/entity_types_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/entity_types_connection_impl.h @@ -97,6 +97,12 @@ class EntityTypesConnectionImpl : public dialogflow_cx::EntityTypesConnection { future> ImportEntityTypes(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_cx/internal/entity_types_logging_decorator.cc b/google/cloud/dialogflow_cx/internal/entity_types_logging_decorator.cc index 44e00932618ab..3a16fff161dd5 100644 --- a/google/cloud/dialogflow_cx/internal/entity_types_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/entity_types_logging_decorator.cc @@ -165,6 +165,29 @@ StatusOr EntityTypesLogging::ImportEntityTypes( context, options, request, __func__, tracing_options_); } +StatusOr +EntityTypesLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EntityTypesLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> EntityTypesLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/entity_types_logging_decorator.h b/google/cloud/dialogflow_cx/internal/entity_types_logging_decorator.h index ec775521eff4e..c8fa7e8dcf4ce 100644 --- a/google/cloud/dialogflow_cx/internal/entity_types_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/entity_types_logging_decorator.h @@ -89,6 +89,14 @@ class EntityTypesLogging : public EntityTypesStub { google::cloud::dialogflow::cx::v3::ImportEntityTypesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/entity_types_metadata_decorator.cc b/google/cloud/dialogflow_cx/internal/entity_types_metadata_decorator.cc index f512fc2484b53..7fd55b73c9520 100644 --- a/google/cloud/dialogflow_cx/internal/entity_types_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/entity_types_metadata_decorator.cc @@ -133,6 +133,23 @@ StatusOr EntityTypesMetadata::ImportEntityTypes( return child_->ImportEntityTypes(context, options, request); } +StatusOr +EntityTypesMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr EntityTypesMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> EntityTypesMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/entity_types_metadata_decorator.h b/google/cloud/dialogflow_cx/internal/entity_types_metadata_decorator.h index 07476b4c87a91..ac19676d4b743 100644 --- a/google/cloud/dialogflow_cx/internal/entity_types_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/entity_types_metadata_decorator.h @@ -89,6 +89,14 @@ class EntityTypesMetadata : public EntityTypesStub { google::cloud::dialogflow::cx::v3::ImportEntityTypesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/entity_types_stub.cc b/google/cloud/dialogflow_cx/internal/entity_types_stub.cc index 5af7a244d1d68..670782851805b 100644 --- a/google/cloud/dialogflow_cx/internal/entity_types_stub.cc +++ b/google/cloud/dialogflow_cx/internal/entity_types_stub.cc @@ -156,6 +156,29 @@ DefaultEntityTypesStub::ImportEntityTypes( return response; } +StatusOr +DefaultEntityTypesStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultEntityTypesStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultEntityTypesStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/entity_types_stub.h b/google/cloud/dialogflow_cx/internal/entity_types_stub.h index 48d9e8ec52b0b..98ec5e7367aa6 100644 --- a/google/cloud/dialogflow_cx/internal/entity_types_stub.h +++ b/google/cloud/dialogflow_cx/internal/entity_types_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -92,6 +94,15 @@ class EntityTypesStub { google::cloud::dialogflow::cx::v3::ImportEntityTypesRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -111,9 +122,13 @@ class DefaultEntityTypesStub : public EntityTypesStub { std::unique_ptr< google::cloud::dialogflow::cx::v3::EntityTypes::StubInterface> grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr GetEntityType( grpc::ClientContext& context, Options const& options, @@ -165,6 +180,14 @@ class DefaultEntityTypesStub : public EntityTypesStub { google::cloud::dialogflow::cx::v3::ImportEntityTypesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -180,6 +203,8 @@ class DefaultEntityTypesStub : public EntityTypesStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/dialogflow_cx/internal/entity_types_stub_factory.cc b/google/cloud/dialogflow_cx/internal/entity_types_stub_factory.cc index e0658d4df68db..4d5394a929190 100644 --- a/google/cloud/dialogflow_cx/internal/entity_types_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/entity_types_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultEntityTypesStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::EntityTypes::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/dialogflow_cx/internal/entity_types_tracing_connection.cc b/google/cloud/dialogflow_cx/internal/entity_types_tracing_connection.cc index 946c15f1a31a7..3a1ffc43f8abd 100644 --- a/google/cloud/dialogflow_cx/internal/entity_types_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/entity_types_tracing_connection.cc @@ -144,6 +144,26 @@ EntityTypesTracingConnection::ImportEntityTypes( child_->ImportEntityTypes(operation)); } +StreamRange +EntityTypesTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_cx::EntityTypesConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +EntityTypesTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::EntityTypesConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_cx/internal/entity_types_tracing_connection.h b/google/cloud/dialogflow_cx/internal/entity_types_tracing_connection.h index 0b6952cb773ec..2ddd4477a4a90 100644 --- a/google/cloud/dialogflow_cx/internal/entity_types_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/entity_types_tracing_connection.h @@ -86,6 +86,12 @@ class EntityTypesTracingConnection future> ImportEntityTypes(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_cx/internal/entity_types_tracing_stub.cc b/google/cloud/dialogflow_cx/internal/entity_types_tracing_stub.cc index 31f027991aba0..ed33424e5b7ba 100644 --- a/google/cloud/dialogflow_cx/internal/entity_types_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/entity_types_tracing_stub.cc @@ -149,6 +149,29 @@ EntityTypesTracingStub::ImportEntityTypes( context, *span, child_->ImportEntityTypes(context, options, request)); } +StatusOr +EntityTypesTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.EntityTypes", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr EntityTypesTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.EntityTypes", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> EntityTypesTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/entity_types_tracing_stub.h b/google/cloud/dialogflow_cx/internal/entity_types_tracing_stub.h index 0afc268dca7e2..4a8c47267bc95 100644 --- a/google/cloud/dialogflow_cx/internal/entity_types_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/entity_types_tracing_stub.h @@ -88,6 +88,14 @@ class EntityTypesTracingStub : public EntityTypesStub { google::cloud::dialogflow::cx::v3::ImportEntityTypesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/environments_auth_decorator.cc b/google/cloud/dialogflow_cx/internal/environments_auth_decorator.cc index 9531646030524..844176502a8fb 100644 --- a/google/cloud/dialogflow_cx/internal/environments_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/environments_auth_decorator.cc @@ -196,6 +196,23 @@ StatusOr EnvironmentsAuth::DeployFlow( return child_->DeployFlow(context, options, request); } +StatusOr +EnvironmentsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr EnvironmentsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> EnvironmentsAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/environments_auth_decorator.h b/google/cloud/dialogflow_cx/internal/environments_auth_decorator.h index 606b15e96d1ca..0bb8e992196f6 100644 --- a/google/cloud/dialogflow_cx/internal/environments_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/environments_auth_decorator.h @@ -115,6 +115,14 @@ class EnvironmentsAuth : public EnvironmentsStub { google::cloud::dialogflow::cx::v3::DeployFlowRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/environments_connection_impl.cc b/google/cloud/dialogflow_cx/internal/environments_connection_impl.cc index 85edbd5494edb..b4757ab1ce758 100644 --- a/google/cloud/dialogflow_cx/internal/environments_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/environments_connection_impl.cc @@ -580,6 +580,54 @@ EnvironmentsConnectionImpl::DeployFlow( polling_policy(*current), __func__); } +StreamRange +EnvironmentsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +EnvironmentsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/environments_connection_impl.h b/google/cloud/dialogflow_cx/internal/environments_connection_impl.h index 2545e7b54a973..45f53c0f15e47 100644 --- a/google/cloud/dialogflow_cx/internal/environments_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/environments_connection_impl.h @@ -125,6 +125,12 @@ class EnvironmentsConnectionImpl future> DeployFlow(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_cx/internal/environments_logging_decorator.cc b/google/cloud/dialogflow_cx/internal/environments_logging_decorator.cc index d090388cf4e8c..d19d12f8d8c09 100644 --- a/google/cloud/dialogflow_cx/internal/environments_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/environments_logging_decorator.cc @@ -232,6 +232,29 @@ StatusOr EnvironmentsLogging::DeployFlow( context, options, request, __func__, tracing_options_); } +StatusOr +EnvironmentsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EnvironmentsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> EnvironmentsLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/environments_logging_decorator.h b/google/cloud/dialogflow_cx/internal/environments_logging_decorator.h index d3cbb30f3058d..c7f6991834b2d 100644 --- a/google/cloud/dialogflow_cx/internal/environments_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/environments_logging_decorator.h @@ -115,6 +115,14 @@ class EnvironmentsLogging : public EnvironmentsStub { google::cloud::dialogflow::cx::v3::DeployFlowRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/environments_metadata_decorator.cc b/google/cloud/dialogflow_cx/internal/environments_metadata_decorator.cc index 605a56a2bbdb2..106ed2152cb22 100644 --- a/google/cloud/dialogflow_cx/internal/environments_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/environments_metadata_decorator.cc @@ -186,6 +186,23 @@ StatusOr EnvironmentsMetadata::DeployFlow( return child_->DeployFlow(context, options, request); } +StatusOr +EnvironmentsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr EnvironmentsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> EnvironmentsMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/environments_metadata_decorator.h b/google/cloud/dialogflow_cx/internal/environments_metadata_decorator.h index ee346c6fff4cb..3c6e3479565a2 100644 --- a/google/cloud/dialogflow_cx/internal/environments_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/environments_metadata_decorator.h @@ -115,6 +115,14 @@ class EnvironmentsMetadata : public EnvironmentsStub { google::cloud::dialogflow::cx::v3::DeployFlowRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/environments_stub.cc b/google/cloud/dialogflow_cx/internal/environments_stub.cc index c34b4cc189d51..ec2511ebcb285 100644 --- a/google/cloud/dialogflow_cx/internal/environments_stub.cc +++ b/google/cloud/dialogflow_cx/internal/environments_stub.cc @@ -224,6 +224,30 @@ StatusOr DefaultEnvironmentsStub::DeployFlow( return response; } +StatusOr +DefaultEnvironmentsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultEnvironmentsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultEnvironmentsStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/environments_stub.h b/google/cloud/dialogflow_cx/internal/environments_stub.h index 4d1f4a4c31561..0361c6f159434 100644 --- a/google/cloud/dialogflow_cx/internal/environments_stub.h +++ b/google/cloud/dialogflow_cx/internal/environments_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -118,6 +120,15 @@ class EnvironmentsStub { grpc::ClientContext& context, Options options, google::cloud::dialogflow::cx::v3::DeployFlowRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -137,9 +148,13 @@ class DefaultEnvironmentsStub : public EnvironmentsStub { std::unique_ptr< google::cloud::dialogflow::cx::v3::Environments::StubInterface> grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListEnvironments( @@ -217,6 +232,14 @@ class DefaultEnvironmentsStub : public EnvironmentsStub { google::cloud::dialogflow::cx::v3::DeployFlowRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -233,6 +256,8 @@ class DefaultEnvironmentsStub : public EnvironmentsStub { std::unique_ptr< google::cloud::dialogflow::cx::v3::Environments::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/dialogflow_cx/internal/environments_stub_factory.cc b/google/cloud/dialogflow_cx/internal/environments_stub_factory.cc index fd20b72a587e9..7fbecbcea9b2f 100644 --- a/google/cloud/dialogflow_cx/internal/environments_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/environments_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultEnvironmentsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::Environments::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/dialogflow_cx/internal/environments_tracing_connection.cc b/google/cloud/dialogflow_cx/internal/environments_tracing_connection.cc index d266cd61a8087..5ec5be6dd14ba 100644 --- a/google/cloud/dialogflow_cx/internal/environments_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/environments_tracing_connection.cc @@ -213,6 +213,26 @@ EnvironmentsTracingConnection::DeployFlow( return internal::EndSpan(std::move(span), child_->DeployFlow(operation)); } +StreamRange +EnvironmentsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_cx::EnvironmentsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +EnvironmentsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::EnvironmentsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_cx/internal/environments_tracing_connection.h b/google/cloud/dialogflow_cx/internal/environments_tracing_connection.h index 9d7040348e35b..0da10a12e04df 100644 --- a/google/cloud/dialogflow_cx/internal/environments_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/environments_tracing_connection.h @@ -113,6 +113,12 @@ class EnvironmentsTracingConnection future> DeployFlow(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_cx/internal/environments_tracing_stub.cc b/google/cloud/dialogflow_cx/internal/environments_tracing_stub.cc index f12beb2e8620f..d3edb27627b6f 100644 --- a/google/cloud/dialogflow_cx/internal/environments_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/environments_tracing_stub.cc @@ -209,6 +209,30 @@ StatusOr EnvironmentsTracingStub::DeployFlow( child_->DeployFlow(context, options, request)); } +StatusOr +EnvironmentsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.Environments", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +EnvironmentsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.Environments", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> EnvironmentsTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/environments_tracing_stub.h b/google/cloud/dialogflow_cx/internal/environments_tracing_stub.h index 364bf7c66559b..d3f3f9afcd36a 100644 --- a/google/cloud/dialogflow_cx/internal/environments_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/environments_tracing_stub.h @@ -114,6 +114,14 @@ class EnvironmentsTracingStub : public EnvironmentsStub { google::cloud::dialogflow::cx::v3::DeployFlowRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/experiments_auth_decorator.cc b/google/cloud/dialogflow_cx/internal/experiments_auth_decorator.cc index b3f2e91e16ca1..43492ebcfdf53 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/experiments_auth_decorator.cc @@ -93,6 +93,23 @@ ExperimentsAuth::StopExperiment( return child_->StopExperiment(context, options, request); } +StatusOr +ExperimentsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr ExperimentsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/experiments_auth_decorator.h b/google/cloud/dialogflow_cx/internal/experiments_auth_decorator.h index 109266799609d..01a6c557ae6f9 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/experiments_auth_decorator.h @@ -74,6 +74,14 @@ class ExperimentsAuth : public ExperimentsStub { google::cloud::dialogflow::cx::v3::StopExperimentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/dialogflow_cx/internal/experiments_connection_impl.cc b/google/cloud/dialogflow_cx/internal/experiments_connection_impl.cc index edf6b246f6e72..6970e42fc3eeb 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/experiments_connection_impl.cc @@ -183,6 +183,54 @@ ExperimentsConnectionImpl::StopExperiment( *current, request, __func__); } +StreamRange +ExperimentsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ExperimentsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/experiments_connection_impl.h b/google/cloud/dialogflow_cx/internal/experiments_connection_impl.h index 22ad8e63d7f72..057cf56889d37 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/experiments_connection_impl.h @@ -76,6 +76,12 @@ class ExperimentsConnectionImpl : public dialogflow_cx::ExperimentsConnection { google::cloud::dialogflow::cx::v3::StopExperimentRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_cx/internal/experiments_logging_decorator.cc b/google/cloud/dialogflow_cx/internal/experiments_logging_decorator.cc index 883ecc85ab515..ce8259435f50e 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/experiments_logging_decorator.cc @@ -125,6 +125,29 @@ ExperimentsLogging::StopExperiment( context, options, request, __func__, tracing_options_); } +StatusOr +ExperimentsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ExperimentsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/experiments_logging_decorator.h b/google/cloud/dialogflow_cx/internal/experiments_logging_decorator.h index 97489761077dd..4f364ddb10d21 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/experiments_logging_decorator.h @@ -74,6 +74,14 @@ class ExperimentsLogging : public ExperimentsStub { google::cloud::dialogflow::cx::v3::StopExperimentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/dialogflow_cx/internal/experiments_metadata_decorator.cc b/google/cloud/dialogflow_cx/internal/experiments_metadata_decorator.cc index 77cb4793bf24b..2690a6092e5e7 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/experiments_metadata_decorator.cc @@ -107,6 +107,23 @@ ExperimentsMetadata::StopExperiment( return child_->StopExperiment(context, options, request); } +StatusOr +ExperimentsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr ExperimentsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void ExperimentsMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/dialogflow_cx/internal/experiments_metadata_decorator.h b/google/cloud/dialogflow_cx/internal/experiments_metadata_decorator.h index 668630bb0f495..663e4d813f920 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/experiments_metadata_decorator.h @@ -74,6 +74,14 @@ class ExperimentsMetadata : public ExperimentsStub { google::cloud::dialogflow::cx::v3::StopExperimentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/dialogflow_cx/internal/experiments_stub.cc b/google/cloud/dialogflow_cx/internal/experiments_stub.cc index 28341c53787cf..2b7c421b87a11 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_stub.cc +++ b/google/cloud/dialogflow_cx/internal/experiments_stub.cc @@ -113,6 +113,29 @@ DefaultExperimentsStub::StopExperiment( return response; } +StatusOr +DefaultExperimentsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultExperimentsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/experiments_stub.h b/google/cloud/dialogflow_cx/internal/experiments_stub.h index bd06998d7d419..9778fb0245802 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_stub.h +++ b/google/cloud/dialogflow_cx/internal/experiments_stub.h @@ -23,6 +23,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -73,6 +75,15 @@ class ExperimentsStub { StopExperiment(grpc::ClientContext& context, Options const& options, google::cloud::dialogflow::cx::v3::StopExperimentRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultExperimentsStub : public ExperimentsStub { @@ -80,8 +91,11 @@ class DefaultExperimentsStub : public ExperimentsStub { explicit DefaultExperimentsStub( std::unique_ptr< google::cloud::dialogflow::cx::v3::Experiments::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListExperiments( @@ -119,9 +133,19 @@ class DefaultExperimentsStub : public ExperimentsStub { google::cloud::dialogflow::cx::v3::StopExperimentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/internal/experiments_stub_factory.cc b/google/cloud/dialogflow_cx/internal/experiments_stub_factory.cc index 41b82ad91cd32..eac5f8b7bb78a 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/experiments_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,8 +45,11 @@ std::shared_ptr CreateDefaultExperimentsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::Experiments::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + std::make_shared( + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), std::move(stub)); diff --git a/google/cloud/dialogflow_cx/internal/experiments_tracing_connection.cc b/google/cloud/dialogflow_cx/internal/experiments_tracing_connection.cc index dd954b02ebfaa..c45da134e7c2e 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/experiments_tracing_connection.cc @@ -98,6 +98,26 @@ ExperimentsTracingConnection::StopExperiment( return internal::EndSpan(*span, child_->StopExperiment(request)); } +StreamRange +ExperimentsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_cx::ExperimentsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ExperimentsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::ExperimentsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_cx/internal/experiments_tracing_connection.h b/google/cloud/dialogflow_cx/internal/experiments_tracing_connection.h index 165c8a3062004..688ba792745a1 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/experiments_tracing_connection.h @@ -68,6 +68,12 @@ class ExperimentsTracingConnection google::cloud::dialogflow::cx::v3::StopExperimentRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_cx/internal/experiments_tracing_stub.cc b/google/cloud/dialogflow_cx/internal/experiments_tracing_stub.cc index c1da4810e5a86..081528ed1e7de 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/experiments_tracing_stub.cc @@ -115,6 +115,29 @@ ExperimentsTracingStub::StopExperiment( child_->StopExperiment(context, options, request)); } +StatusOr +ExperimentsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.Experiments", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr ExperimentsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.Experiments", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeExperimentsTracingStub( diff --git a/google/cloud/dialogflow_cx/internal/experiments_tracing_stub.h b/google/cloud/dialogflow_cx/internal/experiments_tracing_stub.h index a997710a25442..ffcfbadd4af84 100644 --- a/google/cloud/dialogflow_cx/internal/experiments_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/experiments_tracing_stub.h @@ -74,6 +74,14 @@ class ExperimentsTracingStub : public ExperimentsStub { google::cloud::dialogflow::cx::v3::StopExperimentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/dialogflow_cx/internal/flows_auth_decorator.cc b/google/cloud/dialogflow_cx/internal/flows_auth_decorator.cc index 6176ad1d6e6a1..9f5657640d03c 100644 --- a/google/cloud/dialogflow_cx/internal/flows_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/flows_auth_decorator.cc @@ -172,6 +172,23 @@ StatusOr FlowsAuth::ExportFlow( return child_->ExportFlow(context, options, request); } +StatusOr +FlowsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr FlowsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> FlowsAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/flows_auth_decorator.h b/google/cloud/dialogflow_cx/internal/flows_auth_decorator.h index 0277f6de4555d..19183ecc36053 100644 --- a/google/cloud/dialogflow_cx/internal/flows_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/flows_auth_decorator.h @@ -110,6 +110,14 @@ class FlowsAuth : public FlowsStub { google::cloud::dialogflow::cx::v3::ExportFlowRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/flows_connection_impl.cc b/google/cloud/dialogflow_cx/internal/flows_connection_impl.cc index 062b3edaa2ee9..c78c38d43b7a9 100644 --- a/google/cloud/dialogflow_cx/internal/flows_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/flows_connection_impl.cc @@ -450,6 +450,53 @@ FlowsConnectionImpl::ExportFlow( polling_policy(*current), __func__); } +StreamRange +FlowsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr FlowsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/flows_connection_impl.h b/google/cloud/dialogflow_cx/internal/flows_connection_impl.h index 35247e080a9eb..b2f710692f46a 100644 --- a/google/cloud/dialogflow_cx/internal/flows_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/flows_connection_impl.h @@ -113,6 +113,12 @@ class FlowsConnectionImpl : public dialogflow_cx::FlowsConnection { future> ExportFlow(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_cx/internal/flows_logging_decorator.cc b/google/cloud/dialogflow_cx/internal/flows_logging_decorator.cc index 9d78706b33c5d..83a20754cbdf9 100644 --- a/google/cloud/dialogflow_cx/internal/flows_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/flows_logging_decorator.cc @@ -212,6 +212,29 @@ StatusOr FlowsLogging::ExportFlow( context, options, request, __func__, tracing_options_); } +StatusOr +FlowsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr FlowsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> FlowsLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/flows_logging_decorator.h b/google/cloud/dialogflow_cx/internal/flows_logging_decorator.h index 004fb1cf580a0..1ada48c07d0d4 100644 --- a/google/cloud/dialogflow_cx/internal/flows_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/flows_logging_decorator.h @@ -109,6 +109,14 @@ class FlowsLogging : public FlowsStub { google::cloud::dialogflow::cx::v3::ExportFlowRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/flows_metadata_decorator.cc b/google/cloud/dialogflow_cx/internal/flows_metadata_decorator.cc index aeaa20bbd8e99..e4fd983ab4291 100644 --- a/google/cloud/dialogflow_cx/internal/flows_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/flows_metadata_decorator.cc @@ -162,6 +162,23 @@ StatusOr FlowsMetadata::ExportFlow( return child_->ExportFlow(context, options, request); } +StatusOr +FlowsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr FlowsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> FlowsMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/flows_metadata_decorator.h b/google/cloud/dialogflow_cx/internal/flows_metadata_decorator.h index 5eec8a2578a61..c9e09f361aa52 100644 --- a/google/cloud/dialogflow_cx/internal/flows_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/flows_metadata_decorator.h @@ -110,6 +110,14 @@ class FlowsMetadata : public FlowsStub { google::cloud::dialogflow::cx::v3::ExportFlowRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/flows_stub.cc b/google/cloud/dialogflow_cx/internal/flows_stub.cc index a8c1acebab4b8..791e6fd24f2f4 100644 --- a/google/cloud/dialogflow_cx/internal/flows_stub.cc +++ b/google/cloud/dialogflow_cx/internal/flows_stub.cc @@ -202,6 +202,29 @@ StatusOr DefaultFlowsStub::ExportFlow( return response; } +StatusOr +DefaultFlowsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultFlowsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultFlowsStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/flows_stub.h b/google/cloud/dialogflow_cx/internal/flows_stub.h index c0b3eaec18d84..7482e55fea120 100644 --- a/google/cloud/dialogflow_cx/internal/flows_stub.h +++ b/google/cloud/dialogflow_cx/internal/flows_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -101,6 +103,15 @@ class FlowsStub { grpc::ClientContext& context, Options options, google::cloud::dialogflow::cx::v3::ExportFlowRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -119,9 +130,13 @@ class DefaultFlowsStub : public FlowsStub { DefaultFlowsStub( std::unique_ptr grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr CreateFlow( grpc::ClientContext& context, Options const& options, @@ -194,6 +209,14 @@ class DefaultFlowsStub : public FlowsStub { google::cloud::dialogflow::cx::v3::ExportFlowRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -209,6 +232,8 @@ class DefaultFlowsStub : public FlowsStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/dialogflow_cx/internal/flows_stub_factory.cc b/google/cloud/dialogflow_cx/internal/flows_stub_factory.cc index c71a67fb9b94a..7c25dcab9793f 100644 --- a/google/cloud/dialogflow_cx/internal/flows_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/flows_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,8 +45,10 @@ std::shared_ptr CreateDefaultFlowsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::Flows::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/dialogflow_cx/internal/flows_tracing_connection.cc b/google/cloud/dialogflow_cx/internal/flows_tracing_connection.cc index 8b8877347d9d3..a477f31d19022 100644 --- a/google/cloud/dialogflow_cx/internal/flows_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/flows_tracing_connection.cc @@ -163,6 +163,24 @@ FlowsTracingConnection::ExportFlow( return internal::EndSpan(std::move(span), child_->ExportFlow(operation)); } +StreamRange +FlowsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_cx::FlowsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr FlowsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan("dialogflow_cx::FlowsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeFlowsTracingConnection( diff --git a/google/cloud/dialogflow_cx/internal/flows_tracing_connection.h b/google/cloud/dialogflow_cx/internal/flows_tracing_connection.h index f636283ea288b..82f61b6051035 100644 --- a/google/cloud/dialogflow_cx/internal/flows_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/flows_tracing_connection.h @@ -102,6 +102,12 @@ class FlowsTracingConnection : public dialogflow_cx::FlowsConnection { future> ExportFlow(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_cx/internal/flows_tracing_stub.cc b/google/cloud/dialogflow_cx/internal/flows_tracing_stub.cc index 3c3c7714b5e6b..8b31bf609de6b 100644 --- a/google/cloud/dialogflow_cx/internal/flows_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/flows_tracing_stub.cc @@ -188,6 +188,29 @@ StatusOr FlowsTracingStub::ExportFlow( child_->ExportFlow(context, options, request)); } +StatusOr +FlowsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Flows", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr FlowsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Flows", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> FlowsTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/flows_tracing_stub.h b/google/cloud/dialogflow_cx/internal/flows_tracing_stub.h index db192efbce613..c46d82489a3e0 100644 --- a/google/cloud/dialogflow_cx/internal/flows_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/flows_tracing_stub.h @@ -109,6 +109,14 @@ class FlowsTracingStub : public FlowsStub { google::cloud::dialogflow::cx::v3::ExportFlowRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/generators_auth_decorator.cc b/google/cloud/dialogflow_cx/internal/generators_auth_decorator.cc index b4c547929ecad..8c8fba20f4ba4 100644 --- a/google/cloud/dialogflow_cx/internal/generators_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/generators_auth_decorator.cc @@ -75,6 +75,23 @@ Status GeneratorsAuth::DeleteGenerator( return child_->DeleteGenerator(context, options, request); } +StatusOr +GeneratorsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr GeneratorsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/generators_auth_decorator.h b/google/cloud/dialogflow_cx/internal/generators_auth_decorator.h index f269733aad0c7..2be84321925b7 100644 --- a/google/cloud/dialogflow_cx/internal/generators_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/generators_auth_decorator.h @@ -63,6 +63,14 @@ class GeneratorsAuth : public GeneratorsStub { google::cloud::dialogflow::cx::v3::DeleteGeneratorRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/dialogflow_cx/internal/generators_connection_impl.cc b/google/cloud/dialogflow_cx/internal/generators_connection_impl.cc index a2a8a704c15bb..2f6b379857b68 100644 --- a/google/cloud/dialogflow_cx/internal/generators_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/generators_connection_impl.cc @@ -153,6 +153,54 @@ Status GeneratorsConnectionImpl::DeleteGenerator( *current, request, __func__); } +StreamRange +GeneratorsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +GeneratorsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/generators_connection_impl.h b/google/cloud/dialogflow_cx/internal/generators_connection_impl.h index 70a61afc69db6..801de7735a21b 100644 --- a/google/cloud/dialogflow_cx/internal/generators_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/generators_connection_impl.h @@ -68,6 +68,12 @@ class GeneratorsConnectionImpl : public dialogflow_cx::GeneratorsConnection { google::cloud::dialogflow::cx::v3::DeleteGeneratorRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_cx/internal/generators_logging_decorator.cc b/google/cloud/dialogflow_cx/internal/generators_logging_decorator.cc index dd862296b6eee..bad0238cd91f0 100644 --- a/google/cloud/dialogflow_cx/internal/generators_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/generators_logging_decorator.cc @@ -99,6 +99,29 @@ Status GeneratorsLogging::DeleteGenerator( context, options, request, __func__, tracing_options_); } +StatusOr +GeneratorsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr GeneratorsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/generators_logging_decorator.h b/google/cloud/dialogflow_cx/internal/generators_logging_decorator.h index 891f38dca5e1a..25017ef02c08b 100644 --- a/google/cloud/dialogflow_cx/internal/generators_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/generators_logging_decorator.h @@ -63,6 +63,14 @@ class GeneratorsLogging : public GeneratorsStub { google::cloud::dialogflow::cx::v3::DeleteGeneratorRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/dialogflow_cx/internal/generators_metadata_decorator.cc b/google/cloud/dialogflow_cx/internal/generators_metadata_decorator.cc index 2ce30b57a81d3..8f080d80b366c 100644 --- a/google/cloud/dialogflow_cx/internal/generators_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/generators_metadata_decorator.cc @@ -89,6 +89,23 @@ Status GeneratorsMetadata::DeleteGenerator( return child_->DeleteGenerator(context, options, request); } +StatusOr +GeneratorsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr GeneratorsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void GeneratorsMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/dialogflow_cx/internal/generators_metadata_decorator.h b/google/cloud/dialogflow_cx/internal/generators_metadata_decorator.h index 004c5f21bc194..8ff4339ed601a 100644 --- a/google/cloud/dialogflow_cx/internal/generators_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/generators_metadata_decorator.h @@ -63,6 +63,14 @@ class GeneratorsMetadata : public GeneratorsStub { google::cloud::dialogflow::cx::v3::DeleteGeneratorRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/dialogflow_cx/internal/generators_stub.cc b/google/cloud/dialogflow_cx/internal/generators_stub.cc index 024adfe6c7d5c..b16e7b8f06fbc 100644 --- a/google/cloud/dialogflow_cx/internal/generators_stub.cc +++ b/google/cloud/dialogflow_cx/internal/generators_stub.cc @@ -89,6 +89,29 @@ Status DefaultGeneratorsStub::DeleteGenerator( return google::cloud::Status(); } +StatusOr +DefaultGeneratorsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultGeneratorsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/generators_stub.h b/google/cloud/dialogflow_cx/internal/generators_stub.h index 268deb003487c..9400d22013248 100644 --- a/google/cloud/dialogflow_cx/internal/generators_stub.h +++ b/google/cloud/dialogflow_cx/internal/generators_stub.h @@ -23,6 +23,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -61,6 +63,15 @@ class GeneratorsStub { grpc::ClientContext& context, Options const& options, google::cloud::dialogflow::cx::v3::DeleteGeneratorRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultGeneratorsStub : public GeneratorsStub { @@ -68,8 +79,11 @@ class DefaultGeneratorsStub : public GeneratorsStub { explicit DefaultGeneratorsStub( std::unique_ptr< google::cloud::dialogflow::cx::v3::Generators::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListGenerators(grpc::ClientContext& context, Options const& options, @@ -96,9 +110,19 @@ class DefaultGeneratorsStub : public GeneratorsStub { google::cloud::dialogflow::cx::v3::DeleteGeneratorRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/internal/generators_stub_factory.cc b/google/cloud/dialogflow_cx/internal/generators_stub_factory.cc index 1380f9951d169..7a3e7cc5beb8f 100644 --- a/google/cloud/dialogflow_cx/internal/generators_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/generators_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,8 +45,11 @@ std::shared_ptr CreateDefaultGeneratorsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::Generators::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + std::make_shared( + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), std::move(stub)); diff --git a/google/cloud/dialogflow_cx/internal/generators_tracing_connection.cc b/google/cloud/dialogflow_cx/internal/generators_tracing_connection.cc index 070c286a6177b..4747aad819d65 100644 --- a/google/cloud/dialogflow_cx/internal/generators_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/generators_tracing_connection.cc @@ -80,6 +80,26 @@ Status GeneratorsTracingConnection::DeleteGenerator( return internal::EndSpan(*span, child_->DeleteGenerator(request)); } +StreamRange +GeneratorsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_cx::GeneratorsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +GeneratorsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::GeneratorsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_cx/internal/generators_tracing_connection.h b/google/cloud/dialogflow_cx/internal/generators_tracing_connection.h index fd8cc48b88a7d..25fd4f5adc495 100644 --- a/google/cloud/dialogflow_cx/internal/generators_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/generators_tracing_connection.h @@ -59,6 +59,12 @@ class GeneratorsTracingConnection : public dialogflow_cx::GeneratorsConnection { google::cloud::dialogflow::cx::v3::DeleteGeneratorRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_cx/internal/generators_tracing_stub.cc b/google/cloud/dialogflow_cx/internal/generators_tracing_stub.cc index 9d8db5b318c40..53e1c2d3693d9 100644 --- a/google/cloud/dialogflow_cx/internal/generators_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/generators_tracing_stub.cc @@ -91,6 +91,29 @@ Status GeneratorsTracingStub::DeleteGenerator( child_->DeleteGenerator(context, options, request)); } +StatusOr +GeneratorsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Generators", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr GeneratorsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Generators", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeGeneratorsTracingStub( diff --git a/google/cloud/dialogflow_cx/internal/generators_tracing_stub.h b/google/cloud/dialogflow_cx/internal/generators_tracing_stub.h index d1cfd4b1bf850..4d7d3bc53075c 100644 --- a/google/cloud/dialogflow_cx/internal/generators_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/generators_tracing_stub.h @@ -63,6 +63,14 @@ class GeneratorsTracingStub : public GeneratorsStub { google::cloud::dialogflow::cx::v3::DeleteGeneratorRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/dialogflow_cx/internal/intents_auth_decorator.cc b/google/cloud/dialogflow_cx/internal/intents_auth_decorator.cc index 9654f65347974..c6b7593b750fe 100644 --- a/google/cloud/dialogflow_cx/internal/intents_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/intents_auth_decorator.cc @@ -128,6 +128,23 @@ StatusOr IntentsAuth::ExportIntents( return child_->ExportIntents(context, options, request); } +StatusOr +IntentsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr IntentsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> IntentsAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/intents_auth_decorator.h b/google/cloud/dialogflow_cx/internal/intents_auth_decorator.h index aa1d07cb585d4..1662c5086ecc4 100644 --- a/google/cloud/dialogflow_cx/internal/intents_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/intents_auth_decorator.h @@ -88,6 +88,14 @@ class IntentsAuth : public IntentsStub { google::cloud::dialogflow::cx::v3::ExportIntentsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/intents_connection_impl.cc b/google/cloud/dialogflow_cx/internal/intents_connection_impl.cc index 41f111a8ba761..bedef7131f466 100644 --- a/google/cloud/dialogflow_cx/internal/intents_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/intents_connection_impl.cc @@ -341,6 +341,53 @@ IntentsConnectionImpl::ExportIntents( polling_policy(*current), __func__); } +StreamRange +IntentsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr IntentsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/intents_connection_impl.h b/google/cloud/dialogflow_cx/internal/intents_connection_impl.h index ee421803e4e60..bff5a3e1d467b 100644 --- a/google/cloud/dialogflow_cx/internal/intents_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/intents_connection_impl.h @@ -94,6 +94,12 @@ class IntentsConnectionImpl : public dialogflow_cx::IntentsConnection { future> ExportIntents(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_cx/internal/intents_logging_decorator.cc b/google/cloud/dialogflow_cx/internal/intents_logging_decorator.cc index a91f3e9984171..e403a5194581d 100644 --- a/google/cloud/dialogflow_cx/internal/intents_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/intents_logging_decorator.cc @@ -160,6 +160,29 @@ StatusOr IntentsLogging::ExportIntents( context, options, request, __func__, tracing_options_); } +StatusOr +IntentsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr IntentsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> IntentsLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/intents_logging_decorator.h b/google/cloud/dialogflow_cx/internal/intents_logging_decorator.h index a5221e6aa6bf3..65984e11f4b32 100644 --- a/google/cloud/dialogflow_cx/internal/intents_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/intents_logging_decorator.h @@ -88,6 +88,14 @@ class IntentsLogging : public IntentsStub { google::cloud::dialogflow::cx::v3::ExportIntentsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/intents_metadata_decorator.cc b/google/cloud/dialogflow_cx/internal/intents_metadata_decorator.cc index 9c24074bd9259..75daabd08648f 100644 --- a/google/cloud/dialogflow_cx/internal/intents_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/intents_metadata_decorator.cc @@ -128,6 +128,23 @@ StatusOr IntentsMetadata::ExportIntents( return child_->ExportIntents(context, options, request); } +StatusOr +IntentsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr IntentsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> IntentsMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/intents_metadata_decorator.h b/google/cloud/dialogflow_cx/internal/intents_metadata_decorator.h index 2440ec432acf0..e1c131985bbca 100644 --- a/google/cloud/dialogflow_cx/internal/intents_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/intents_metadata_decorator.h @@ -88,6 +88,14 @@ class IntentsMetadata : public IntentsStub { google::cloud::dialogflow::cx::v3::ExportIntentsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/intents_stub.cc b/google/cloud/dialogflow_cx/internal/intents_stub.cc index 69c27ba27cc05..18e7b043fea13 100644 --- a/google/cloud/dialogflow_cx/internal/intents_stub.cc +++ b/google/cloud/dialogflow_cx/internal/intents_stub.cc @@ -150,6 +150,29 @@ StatusOr DefaultIntentsStub::ExportIntents( return response; } +StatusOr +DefaultIntentsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultIntentsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultIntentsStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/intents_stub.h b/google/cloud/dialogflow_cx/internal/intents_stub.h index 4b69d36ab3da2..17ed98ddded03 100644 --- a/google/cloud/dialogflow_cx/internal/intents_stub.h +++ b/google/cloud/dialogflow_cx/internal/intents_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -86,6 +88,15 @@ class IntentsStub { google::cloud::dialogflow::cx::v3::ExportIntentsRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -104,9 +115,13 @@ class DefaultIntentsStub : public IntentsStub { DefaultIntentsStub( std::unique_ptr grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListIntents( grpc::ClientContext& context, Options const& options, @@ -157,6 +172,14 @@ class DefaultIntentsStub : public IntentsStub { google::cloud::dialogflow::cx::v3::ExportIntentsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -172,6 +195,8 @@ class DefaultIntentsStub : public IntentsStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/dialogflow_cx/internal/intents_stub_factory.cc b/google/cloud/dialogflow_cx/internal/intents_stub_factory.cc index 47828f7716464..c5256e625f3d5 100644 --- a/google/cloud/dialogflow_cx/internal/intents_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/intents_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,8 +45,10 @@ std::shared_ptr CreateDefaultIntentsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::Intents::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/dialogflow_cx/internal/intents_tracing_connection.cc b/google/cloud/dialogflow_cx/internal/intents_tracing_connection.cc index be10183b4fb96..564d8a3d6819d 100644 --- a/google/cloud/dialogflow_cx/internal/intents_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/intents_tracing_connection.cc @@ -135,6 +135,26 @@ IntentsTracingConnection::ExportIntents( return internal::EndSpan(std::move(span), child_->ExportIntents(operation)); } +StreamRange +IntentsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_cx::IntentsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +IntentsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::IntentsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeIntentsTracingConnection( diff --git a/google/cloud/dialogflow_cx/internal/intents_tracing_connection.h b/google/cloud/dialogflow_cx/internal/intents_tracing_connection.h index bb655b283c9a9..b0df1f64e5376 100644 --- a/google/cloud/dialogflow_cx/internal/intents_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/intents_tracing_connection.h @@ -82,6 +82,12 @@ class IntentsTracingConnection : public dialogflow_cx::IntentsConnection { future> ExportIntents(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_cx/internal/intents_tracing_stub.cc b/google/cloud/dialogflow_cx/internal/intents_tracing_stub.cc index 3cf10cd68b048..f1ef5e55c9715 100644 --- a/google/cloud/dialogflow_cx/internal/intents_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/intents_tracing_stub.cc @@ -140,6 +140,29 @@ StatusOr IntentsTracingStub::ExportIntents( child_->ExportIntents(context, options, request)); } +StatusOr +IntentsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Intents", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr IntentsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Intents", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> IntentsTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/intents_tracing_stub.h b/google/cloud/dialogflow_cx/internal/intents_tracing_stub.h index 1db5bdbe9bd49..5f7fb79ed6994 100644 --- a/google/cloud/dialogflow_cx/internal/intents_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/intents_tracing_stub.h @@ -87,6 +87,14 @@ class IntentsTracingStub : public IntentsStub { google::cloud::dialogflow::cx::v3::ExportIntentsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/pages_auth_decorator.cc b/google/cloud/dialogflow_cx/internal/pages_auth_decorator.cc index 0fe9106619842..8496af543f8f6 100644 --- a/google/cloud/dialogflow_cx/internal/pages_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/pages_auth_decorator.cc @@ -72,6 +72,23 @@ Status PagesAuth::DeletePage( return child_->DeletePage(context, options, request); } +StatusOr +PagesAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr PagesAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/pages_auth_decorator.h b/google/cloud/dialogflow_cx/internal/pages_auth_decorator.h index 55b1b2a81f388..4d608e1e614f2 100644 --- a/google/cloud/dialogflow_cx/internal/pages_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/pages_auth_decorator.h @@ -62,6 +62,14 @@ class PagesAuth : public PagesStub { google::cloud::dialogflow::cx::v3::DeletePageRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/dialogflow_cx/internal/pages_connection_impl.cc b/google/cloud/dialogflow_cx/internal/pages_connection_impl.cc index 8794cf6fb6ff2..1e170ede16bad 100644 --- a/google/cloud/dialogflow_cx/internal/pages_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/pages_connection_impl.cc @@ -148,6 +148,53 @@ Status PagesConnectionImpl::DeletePage( *current, request, __func__); } +StreamRange +PagesConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr PagesConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/pages_connection_impl.h b/google/cloud/dialogflow_cx/internal/pages_connection_impl.h index 8c3cf2ba3f619..77c14ada07939 100644 --- a/google/cloud/dialogflow_cx/internal/pages_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/pages_connection_impl.h @@ -65,6 +65,12 @@ class PagesConnectionImpl : public dialogflow_cx::PagesConnection { Status DeletePage(google::cloud::dialogflow::cx::v3::DeletePageRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_cx/internal/pages_logging_decorator.cc b/google/cloud/dialogflow_cx/internal/pages_logging_decorator.cc index ec6d78965f01c..f26098f2efb2b 100644 --- a/google/cloud/dialogflow_cx/internal/pages_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/pages_logging_decorator.cc @@ -95,6 +95,29 @@ Status PagesLogging::DeletePage( context, options, request, __func__, tracing_options_); } +StatusOr +PagesLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr PagesLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/pages_logging_decorator.h b/google/cloud/dialogflow_cx/internal/pages_logging_decorator.h index e75549500c372..89586d62e1614 100644 --- a/google/cloud/dialogflow_cx/internal/pages_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/pages_logging_decorator.h @@ -61,6 +61,14 @@ class PagesLogging : public PagesStub { google::cloud::dialogflow::cx::v3::DeletePageRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/dialogflow_cx/internal/pages_metadata_decorator.cc b/google/cloud/dialogflow_cx/internal/pages_metadata_decorator.cc index a7db27302f9ef..20d0238a00665 100644 --- a/google/cloud/dialogflow_cx/internal/pages_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/pages_metadata_decorator.cc @@ -86,6 +86,23 @@ Status PagesMetadata::DeletePage( return child_->DeletePage(context, options, request); } +StatusOr +PagesMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr PagesMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void PagesMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/dialogflow_cx/internal/pages_metadata_decorator.h b/google/cloud/dialogflow_cx/internal/pages_metadata_decorator.h index 9784435fc7289..945ba88bc5aa9 100644 --- a/google/cloud/dialogflow_cx/internal/pages_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/pages_metadata_decorator.h @@ -62,6 +62,14 @@ class PagesMetadata : public PagesStub { google::cloud::dialogflow::cx::v3::DeletePageRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/dialogflow_cx/internal/pages_stub.cc b/google/cloud/dialogflow_cx/internal/pages_stub.cc index eb5b0529065ca..bbe3da75c8103 100644 --- a/google/cloud/dialogflow_cx/internal/pages_stub.cc +++ b/google/cloud/dialogflow_cx/internal/pages_stub.cc @@ -86,6 +86,29 @@ Status DefaultPagesStub::DeletePage( return google::cloud::Status(); } +StatusOr +DefaultPagesStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultPagesStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/pages_stub.h b/google/cloud/dialogflow_cx/internal/pages_stub.h index 794b55e017d32..dab23477bb292 100644 --- a/google/cloud/dialogflow_cx/internal/pages_stub.h +++ b/google/cloud/dialogflow_cx/internal/pages_stub.h @@ -23,6 +23,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -55,14 +57,26 @@ class PagesStub { virtual Status DeletePage( grpc::ClientContext& context, Options const& options, google::cloud::dialogflow::cx::v3::DeletePageRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultPagesStub : public PagesStub { public: explicit DefaultPagesStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListPages( grpc::ClientContext& context, Options const& options, @@ -88,9 +102,19 @@ class DefaultPagesStub : public PagesStub { google::cloud::dialogflow::cx::v3::DeletePageRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/internal/pages_stub_factory.cc b/google/cloud/dialogflow_cx/internal/pages_stub_factory.cc index d1cae410ac8a2..72826bf7d8766 100644 --- a/google/cloud/dialogflow_cx/internal/pages_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/pages_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,8 +45,10 @@ std::shared_ptr CreateDefaultPagesStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::Pages::NewStub(channel); - std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); + std::shared_ptr stub = std::make_shared( + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), std::move(stub)); diff --git a/google/cloud/dialogflow_cx/internal/pages_tracing_connection.cc b/google/cloud/dialogflow_cx/internal/pages_tracing_connection.cc index 53b67ed72b030..3cdb44ce99766 100644 --- a/google/cloud/dialogflow_cx/internal/pages_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/pages_tracing_connection.cc @@ -74,6 +74,24 @@ Status PagesTracingConnection::DeletePage( return internal::EndSpan(*span, child_->DeletePage(request)); } +StreamRange +PagesTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_cx::PagesConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr PagesTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan("dialogflow_cx::PagesConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakePagesTracingConnection( diff --git a/google/cloud/dialogflow_cx/internal/pages_tracing_connection.h b/google/cloud/dialogflow_cx/internal/pages_tracing_connection.h index a43aa5c71ff9c..47c2e048a6a86 100644 --- a/google/cloud/dialogflow_cx/internal/pages_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/pages_tracing_connection.h @@ -57,6 +57,12 @@ class PagesTracingConnection : public dialogflow_cx::PagesConnection { Status DeletePage(google::cloud::dialogflow::cx::v3::DeletePageRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_cx/internal/pages_tracing_stub.cc b/google/cloud/dialogflow_cx/internal/pages_tracing_stub.cc index 4d38e57f581aa..5eed86e82ab3c 100644 --- a/google/cloud/dialogflow_cx/internal/pages_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/pages_tracing_stub.cc @@ -87,6 +87,29 @@ Status PagesTracingStub::DeletePage( child_->DeletePage(context, options, request)); } +StatusOr +PagesTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Pages", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr PagesTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Pages", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakePagesTracingStub( diff --git a/google/cloud/dialogflow_cx/internal/pages_tracing_stub.h b/google/cloud/dialogflow_cx/internal/pages_tracing_stub.h index cf904fe96a3b9..515354d94c68b 100644 --- a/google/cloud/dialogflow_cx/internal/pages_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/pages_tracing_stub.h @@ -62,6 +62,14 @@ class PagesTracingStub : public PagesStub { google::cloud::dialogflow::cx::v3::DeletePageRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/dialogflow_cx/internal/security_settings_auth_decorator.cc b/google/cloud/dialogflow_cx/internal/security_settings_auth_decorator.cc index 212ba46999a49..31d6164a96649 100644 --- a/google/cloud/dialogflow_cx/internal/security_settings_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/security_settings_auth_decorator.cc @@ -80,6 +80,24 @@ Status SecuritySettingsServiceAuth::DeleteSecuritySettings( return child_->DeleteSecuritySettings(context, options, request); } +StatusOr +SecuritySettingsServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +SecuritySettingsServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/security_settings_auth_decorator.h b/google/cloud/dialogflow_cx/internal/security_settings_auth_decorator.h index 55f2879ef9208..a8b6e57cf2da9 100644 --- a/google/cloud/dialogflow_cx/internal/security_settings_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/security_settings_auth_decorator.h @@ -67,6 +67,14 @@ class SecuritySettingsServiceAuth : public SecuritySettingsServiceStub { google::cloud::dialogflow::cx::v3::DeleteSecuritySettingsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/dialogflow_cx/internal/security_settings_connection_impl.cc b/google/cloud/dialogflow_cx/internal/security_settings_connection_impl.cc index d0922048ef33b..a4a54bc5cda5f 100644 --- a/google/cloud/dialogflow_cx/internal/security_settings_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/security_settings_connection_impl.cc @@ -165,6 +165,55 @@ Status SecuritySettingsServiceConnectionImpl::DeleteSecuritySettings( *current, request, __func__); } +StreamRange +SecuritySettingsServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = + std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +SecuritySettingsServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/security_settings_connection_impl.h b/google/cloud/dialogflow_cx/internal/security_settings_connection_impl.h index 7bad51ef37932..e522636fb0a36 100644 --- a/google/cloud/dialogflow_cx/internal/security_settings_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/security_settings_connection_impl.h @@ -73,6 +73,12 @@ class SecuritySettingsServiceConnectionImpl google::cloud::dialogflow::cx::v3::DeleteSecuritySettingsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_cx/internal/security_settings_logging_decorator.cc b/google/cloud/dialogflow_cx/internal/security_settings_logging_decorator.cc index 0514bd2c1c8b3..2e6555bffae8a 100644 --- a/google/cloud/dialogflow_cx/internal/security_settings_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/security_settings_logging_decorator.cc @@ -106,6 +106,30 @@ Status SecuritySettingsServiceLogging::DeleteSecuritySettings( context, options, request, __func__, tracing_options_); } +StatusOr +SecuritySettingsServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +SecuritySettingsServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/security_settings_logging_decorator.h b/google/cloud/dialogflow_cx/internal/security_settings_logging_decorator.h index 80f029fc3c68b..02e79fb3837b4 100644 --- a/google/cloud/dialogflow_cx/internal/security_settings_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/security_settings_logging_decorator.h @@ -67,6 +67,14 @@ class SecuritySettingsServiceLogging : public SecuritySettingsServiceStub { google::cloud::dialogflow::cx::v3::DeleteSecuritySettingsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/dialogflow_cx/internal/security_settings_metadata_decorator.cc b/google/cloud/dialogflow_cx/internal/security_settings_metadata_decorator.cc index ad794d3f63464..9c1984ffde379 100644 --- a/google/cloud/dialogflow_cx/internal/security_settings_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/security_settings_metadata_decorator.cc @@ -95,6 +95,24 @@ Status SecuritySettingsServiceMetadata::DeleteSecuritySettings( return child_->DeleteSecuritySettings(context, options, request); } +StatusOr +SecuritySettingsServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +SecuritySettingsServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void SecuritySettingsServiceMetadata::SetMetadata( grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/dialogflow_cx/internal/security_settings_metadata_decorator.h b/google/cloud/dialogflow_cx/internal/security_settings_metadata_decorator.h index c54936251d5d1..5a21d1dd867f4 100644 --- a/google/cloud/dialogflow_cx/internal/security_settings_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/security_settings_metadata_decorator.h @@ -68,6 +68,14 @@ class SecuritySettingsServiceMetadata : public SecuritySettingsServiceStub { google::cloud::dialogflow::cx::v3::DeleteSecuritySettingsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/dialogflow_cx/internal/security_settings_stub.cc b/google/cloud/dialogflow_cx/internal/security_settings_stub.cc index 1af80ad6fd2e4..20af6a6b5786e 100644 --- a/google/cloud/dialogflow_cx/internal/security_settings_stub.cc +++ b/google/cloud/dialogflow_cx/internal/security_settings_stub.cc @@ -97,6 +97,30 @@ Status DefaultSecuritySettingsServiceStub::DeleteSecuritySettings( return google::cloud::Status(); } +StatusOr +DefaultSecuritySettingsServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultSecuritySettingsServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/security_settings_stub.h b/google/cloud/dialogflow_cx/internal/security_settings_stub.h index 559adf17affff..dc9a545ca4c2b 100644 --- a/google/cloud/dialogflow_cx/internal/security_settings_stub.h +++ b/google/cloud/dialogflow_cx/internal/security_settings_stub.h @@ -23,6 +23,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -64,6 +66,15 @@ class SecuritySettingsServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::dialogflow::cx::v3::DeleteSecuritySettingsRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultSecuritySettingsServiceStub : public SecuritySettingsServiceStub { @@ -71,8 +82,11 @@ class DefaultSecuritySettingsServiceStub : public SecuritySettingsServiceStub { explicit DefaultSecuritySettingsServiceStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr CreateSecuritySettings( @@ -103,10 +117,20 @@ class DefaultSecuritySettingsServiceStub : public SecuritySettingsServiceStub { google::cloud::dialogflow::cx::v3::DeleteSecuritySettingsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr< google::cloud::dialogflow::cx::v3::SecuritySettingsService::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/internal/security_settings_stub_factory.cc b/google/cloud/dialogflow_cx/internal/security_settings_stub_factory.cc index 358e216997771..4f57a3294ad86 100644 --- a/google/cloud/dialogflow_cx/internal/security_settings_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/security_settings_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -46,9 +47,11 @@ CreateDefaultSecuritySettingsServiceStub( auto service_grpc_stub = google::cloud::dialogflow::cx::v3::SecuritySettingsService::NewStub( channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/dialogflow_cx/internal/security_settings_tracing_connection.cc b/google/cloud/dialogflow_cx/internal/security_settings_tracing_connection.cc index f6240953a50fd..60a6e87d01468 100644 --- a/google/cloud/dialogflow_cx/internal/security_settings_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/security_settings_tracing_connection.cc @@ -88,6 +88,26 @@ Status SecuritySettingsServiceTracingConnection::DeleteSecuritySettings( return internal::EndSpan(*span, child_->DeleteSecuritySettings(request)); } +StreamRange +SecuritySettingsServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_cx::SecuritySettingsServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SecuritySettingsServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_cx::SecuritySettingsServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_cx/internal/security_settings_tracing_connection.h b/google/cloud/dialogflow_cx/internal/security_settings_tracing_connection.h index d06c231bb31f1..7578d82b0747d 100644 --- a/google/cloud/dialogflow_cx/internal/security_settings_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/security_settings_tracing_connection.h @@ -64,6 +64,12 @@ class SecuritySettingsServiceTracingConnection google::cloud::dialogflow::cx::v3::DeleteSecuritySettingsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_cx/internal/security_settings_tracing_stub.cc b/google/cloud/dialogflow_cx/internal/security_settings_tracing_stub.cc index 723d66deb49e6..df38f3df7ea3c 100644 --- a/google/cloud/dialogflow_cx/internal/security_settings_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/security_settings_tracing_stub.cc @@ -104,6 +104,30 @@ Status SecuritySettingsServiceTracingStub::DeleteSecuritySettings( child_->DeleteSecuritySettings(context, options, request)); } +StatusOr +SecuritySettingsServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.SecuritySettingsService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +SecuritySettingsServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.SecuritySettingsService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_cx/internal/security_settings_tracing_stub.h b/google/cloud/dialogflow_cx/internal/security_settings_tracing_stub.h index 7d9c92763cb1a..b45cd3f22cd9c 100644 --- a/google/cloud/dialogflow_cx/internal/security_settings_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/security_settings_tracing_stub.h @@ -68,6 +68,14 @@ class SecuritySettingsServiceTracingStub : public SecuritySettingsServiceStub { google::cloud::dialogflow::cx::v3::DeleteSecuritySettingsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/dialogflow_cx/internal/session_entity_types_auth_decorator.cc b/google/cloud/dialogflow_cx/internal/session_entity_types_auth_decorator.cc index edcc65532457b..50f8183223292 100644 --- a/google/cloud/dialogflow_cx/internal/session_entity_types_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/session_entity_types_auth_decorator.cc @@ -80,6 +80,23 @@ Status SessionEntityTypesAuth::DeleteSessionEntityType( return child_->DeleteSessionEntityType(context, options, request); } +StatusOr +SessionEntityTypesAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr SessionEntityTypesAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/session_entity_types_auth_decorator.h b/google/cloud/dialogflow_cx/internal/session_entity_types_auth_decorator.h index 57627b7a58121..1ce868f2f2d39 100644 --- a/google/cloud/dialogflow_cx/internal/session_entity_types_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/session_entity_types_auth_decorator.h @@ -67,6 +67,14 @@ class SessionEntityTypesAuth : public SessionEntityTypesStub { google::cloud::dialogflow::cx::v3::DeleteSessionEntityTypeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/dialogflow_cx/internal/session_entity_types_connection_impl.cc b/google/cloud/dialogflow_cx/internal/session_entity_types_connection_impl.cc index d50105babd859..bd7d9b4a9c836 100644 --- a/google/cloud/dialogflow_cx/internal/session_entity_types_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/session_entity_types_connection_impl.cc @@ -160,6 +160,54 @@ Status SessionEntityTypesConnectionImpl::DeleteSessionEntityType( *current, request, __func__); } +StreamRange +SessionEntityTypesConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +SessionEntityTypesConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/session_entity_types_connection_impl.h b/google/cloud/dialogflow_cx/internal/session_entity_types_connection_impl.h index b1d312334060c..9cbde988dbb37 100644 --- a/google/cloud/dialogflow_cx/internal/session_entity_types_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/session_entity_types_connection_impl.h @@ -73,6 +73,12 @@ class SessionEntityTypesConnectionImpl google::cloud::dialogflow::cx::v3::DeleteSessionEntityTypeRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_cx/internal/session_entity_types_logging_decorator.cc b/google/cloud/dialogflow_cx/internal/session_entity_types_logging_decorator.cc index f5965e3d3ff4b..974eacaf71130 100644 --- a/google/cloud/dialogflow_cx/internal/session_entity_types_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/session_entity_types_logging_decorator.cc @@ -105,6 +105,30 @@ Status SessionEntityTypesLogging::DeleteSessionEntityType( context, options, request, __func__, tracing_options_); } +StatusOr +SessionEntityTypesLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +SessionEntityTypesLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/session_entity_types_logging_decorator.h b/google/cloud/dialogflow_cx/internal/session_entity_types_logging_decorator.h index 969f4ebacbbb2..4e59849dc8400 100644 --- a/google/cloud/dialogflow_cx/internal/session_entity_types_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/session_entity_types_logging_decorator.h @@ -67,6 +67,14 @@ class SessionEntityTypesLogging : public SessionEntityTypesStub { google::cloud::dialogflow::cx::v3::DeleteSessionEntityTypeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/dialogflow_cx/internal/session_entity_types_metadata_decorator.cc b/google/cloud/dialogflow_cx/internal/session_entity_types_metadata_decorator.cc index 129104f96308f..714e6c10faf95 100644 --- a/google/cloud/dialogflow_cx/internal/session_entity_types_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/session_entity_types_metadata_decorator.cc @@ -95,6 +95,24 @@ Status SessionEntityTypesMetadata::DeleteSessionEntityType( return child_->DeleteSessionEntityType(context, options, request); } +StatusOr +SessionEntityTypesMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +SessionEntityTypesMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void SessionEntityTypesMetadata::SetMetadata( grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/dialogflow_cx/internal/session_entity_types_metadata_decorator.h b/google/cloud/dialogflow_cx/internal/session_entity_types_metadata_decorator.h index 1bff280a16d27..444601e94df39 100644 --- a/google/cloud/dialogflow_cx/internal/session_entity_types_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/session_entity_types_metadata_decorator.h @@ -68,6 +68,14 @@ class SessionEntityTypesMetadata : public SessionEntityTypesStub { google::cloud::dialogflow::cx::v3::DeleteSessionEntityTypeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/dialogflow_cx/internal/session_entity_types_stub.cc b/google/cloud/dialogflow_cx/internal/session_entity_types_stub.cc index c1549fc8a55e6..5d1ca5c6b29bb 100644 --- a/google/cloud/dialogflow_cx/internal/session_entity_types_stub.cc +++ b/google/cloud/dialogflow_cx/internal/session_entity_types_stub.cc @@ -98,6 +98,30 @@ Status DefaultSessionEntityTypesStub::DeleteSessionEntityType( return google::cloud::Status(); } +StatusOr +DefaultSessionEntityTypesStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultSessionEntityTypesStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/session_entity_types_stub.h b/google/cloud/dialogflow_cx/internal/session_entity_types_stub.h index 136122a75cdbb..a82564e9e35db 100644 --- a/google/cloud/dialogflow_cx/internal/session_entity_types_stub.h +++ b/google/cloud/dialogflow_cx/internal/session_entity_types_stub.h @@ -23,6 +23,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -64,6 +66,15 @@ class SessionEntityTypesStub { grpc::ClientContext& context, Options const& options, google::cloud::dialogflow::cx::v3::DeleteSessionEntityTypeRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultSessionEntityTypesStub : public SessionEntityTypesStub { @@ -71,8 +82,11 @@ class DefaultSessionEntityTypesStub : public SessionEntityTypesStub { explicit DefaultSessionEntityTypesStub( std::unique_ptr< google::cloud::dialogflow::cx::v3::SessionEntityTypes::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListSessionEntityTypes( @@ -103,10 +117,20 @@ class DefaultSessionEntityTypesStub : public SessionEntityTypesStub { google::cloud::dialogflow::cx::v3::DeleteSessionEntityTypeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr< google::cloud::dialogflow::cx::v3::SessionEntityTypes::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/internal/session_entity_types_stub_factory.cc b/google/cloud/dialogflow_cx/internal/session_entity_types_stub_factory.cc index 23a24d6b8e3ea..4be2a9b95fe6a 100644 --- a/google/cloud/dialogflow_cx/internal/session_entity_types_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/session_entity_types_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultSessionEntityTypesStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::SessionEntityTypes::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/dialogflow_cx/internal/session_entity_types_tracing_connection.cc b/google/cloud/dialogflow_cx/internal/session_entity_types_tracing_connection.cc index aa1ddbf7f408b..f9fcd75649887 100644 --- a/google/cloud/dialogflow_cx/internal/session_entity_types_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/session_entity_types_tracing_connection.cc @@ -84,6 +84,26 @@ Status SessionEntityTypesTracingConnection::DeleteSessionEntityType( return internal::EndSpan(*span, child_->DeleteSessionEntityType(request)); } +StreamRange +SessionEntityTypesTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_cx::SessionEntityTypesConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SessionEntityTypesTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_cx::SessionEntityTypesConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_cx/internal/session_entity_types_tracing_connection.h b/google/cloud/dialogflow_cx/internal/session_entity_types_tracing_connection.h index dcc8b8c951d29..7a2151f8a208b 100644 --- a/google/cloud/dialogflow_cx/internal/session_entity_types_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/session_entity_types_tracing_connection.h @@ -64,6 +64,12 @@ class SessionEntityTypesTracingConnection google::cloud::dialogflow::cx::v3::DeleteSessionEntityTypeRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_cx/internal/session_entity_types_tracing_stub.cc b/google/cloud/dialogflow_cx/internal/session_entity_types_tracing_stub.cc index ebca283faa1fd..0fbfac1a876b2 100644 --- a/google/cloud/dialogflow_cx/internal/session_entity_types_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/session_entity_types_tracing_stub.cc @@ -105,6 +105,30 @@ Status SessionEntityTypesTracingStub::DeleteSessionEntityType( child_->DeleteSessionEntityType(context, options, request)); } +StatusOr +SessionEntityTypesTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.SessionEntityTypes", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +SessionEntityTypesTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.SessionEntityTypes", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeSessionEntityTypesTracingStub( diff --git a/google/cloud/dialogflow_cx/internal/session_entity_types_tracing_stub.h b/google/cloud/dialogflow_cx/internal/session_entity_types_tracing_stub.h index fe743d6e1f47a..46811e5b9a930 100644 --- a/google/cloud/dialogflow_cx/internal/session_entity_types_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/session_entity_types_tracing_stub.h @@ -68,6 +68,14 @@ class SessionEntityTypesTracingStub : public SessionEntityTypesStub { google::cloud::dialogflow::cx::v3::DeleteSessionEntityTypeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/dialogflow_cx/internal/sessions_auth_decorator.cc b/google/cloud/dialogflow_cx/internal/sessions_auth_decorator.cc index ce3cd48250911..800d1b3630b98 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/sessions_auth_decorator.cc @@ -101,6 +101,23 @@ SessionsAuth::SubmitAnswerFeedback( return child_->SubmitAnswerFeedback(context, options, request); } +StatusOr +SessionsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr SessionsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/sessions_auth_decorator.h b/google/cloud/dialogflow_cx/internal/sessions_auth_decorator.h index 65bc31836ec26..c6fb452d05a0d 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/sessions_auth_decorator.h @@ -74,6 +74,14 @@ class SessionsAuth : public SessionsStub { google::cloud::dialogflow::cx::v3::SubmitAnswerFeedbackRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/dialogflow_cx/internal/sessions_connection_impl.cc b/google/cloud/dialogflow_cx/internal/sessions_connection_impl.cc index e20895bdb7530..68711488867a7 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/sessions_connection_impl.cc @@ -21,6 +21,7 @@ #include "google/cloud/background_threads.h" #include "google/cloud/common_options.h" #include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/resumable_streaming_read_rpc.h" #include "google/cloud/internal/retry_loop.h" #include "google/cloud/internal/streaming_read_rpc_logging.h" @@ -156,6 +157,53 @@ SessionsConnectionImpl::SubmitAnswerFeedback( *current, request, __func__); } +StreamRange +SessionsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr SessionsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/sessions_connection_impl.h b/google/cloud/dialogflow_cx/internal/sessions_connection_impl.h index c4711d26a0ce0..af78a1dae89aa 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/sessions_connection_impl.h @@ -80,6 +80,12 @@ class SessionsConnectionImpl : public dialogflow_cx::SessionsConnection { google::cloud::dialogflow::cx::v3::SubmitAnswerFeedbackRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_cx/internal/sessions_logging_decorator.cc b/google/cloud/dialogflow_cx/internal/sessions_logging_decorator.cc index 372f2f291fbc2..f9494798dc2d9 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/sessions_logging_decorator.cc @@ -141,6 +141,29 @@ SessionsLogging::SubmitAnswerFeedback( context, options, request, __func__, tracing_options_); } +StatusOr +SessionsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr SessionsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/sessions_logging_decorator.h b/google/cloud/dialogflow_cx/internal/sessions_logging_decorator.h index cfc3bb681f412..6ac127e550895 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/sessions_logging_decorator.h @@ -74,6 +74,14 @@ class SessionsLogging : public SessionsStub { google::cloud::dialogflow::cx::v3::SubmitAnswerFeedbackRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/dialogflow_cx/internal/sessions_metadata_decorator.cc b/google/cloud/dialogflow_cx/internal/sessions_metadata_decorator.cc index ef486136e43fa..b555a6e35773f 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/sessions_metadata_decorator.cc @@ -106,6 +106,23 @@ SessionsMetadata::SubmitAnswerFeedback( return child_->SubmitAnswerFeedback(context, options, request); } +StatusOr +SessionsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr SessionsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void SessionsMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/dialogflow_cx/internal/sessions_metadata_decorator.h b/google/cloud/dialogflow_cx/internal/sessions_metadata_decorator.h index a9f9759dde35f..8b3ac781d5e4f 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/sessions_metadata_decorator.h @@ -74,6 +74,14 @@ class SessionsMetadata : public SessionsStub { google::cloud::dialogflow::cx::v3::SubmitAnswerFeedbackRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/dialogflow_cx/internal/sessions_stub.cc b/google/cloud/dialogflow_cx/internal/sessions_stub.cc index c7bec89245ec1..098fdb99f8883 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_stub.cc +++ b/google/cloud/dialogflow_cx/internal/sessions_stub.cc @@ -107,6 +107,29 @@ DefaultSessionsStub::SubmitAnswerFeedback( return response; } +StatusOr +DefaultSessionsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultSessionsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/sessions_stub.h b/google/cloud/dialogflow_cx/internal/sessions_stub.h index efa4e65786932..18a1846638411 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_stub.h +++ b/google/cloud/dialogflow_cx/internal/sessions_stub.h @@ -26,6 +26,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -73,6 +75,15 @@ class SessionsStub { grpc::ClientContext& context, Options const& options, google::cloud::dialogflow::cx::v3::SubmitAnswerFeedbackRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultSessionsStub : public SessionsStub { @@ -80,8 +91,11 @@ class DefaultSessionsStub : public SessionsStub { explicit DefaultSessionsStub( std::unique_ptr< google::cloud::dialogflow::cx::v3::Sessions::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr DetectIntent(grpc::ClientContext& context, Options const& options, @@ -119,9 +133,19 @@ class DefaultSessionsStub : public SessionsStub { google::cloud::dialogflow::cx::v3::SubmitAnswerFeedbackRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/internal/sessions_stub_factory.cc b/google/cloud/dialogflow_cx/internal/sessions_stub_factory.cc index 8413795ea92b8..7818518c9c40c 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/sessions_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,8 +45,10 @@ std::shared_ptr CreateDefaultSessionsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::Sessions::NewStub(channel); - std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); + std::shared_ptr stub = std::make_shared( + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), std::move(stub)); diff --git a/google/cloud/dialogflow_cx/internal/sessions_tracing_connection.cc b/google/cloud/dialogflow_cx/internal/sessions_tracing_connection.cc index 873ffa563b679..2aea039a0f7f2 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/sessions_tracing_connection.cc @@ -88,6 +88,26 @@ SessionsTracingConnection::SubmitAnswerFeedback( return internal::EndSpan(*span, child_->SubmitAnswerFeedback(request)); } +StreamRange +SessionsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_cx::SessionsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SessionsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::SessionsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_cx/internal/sessions_tracing_connection.h b/google/cloud/dialogflow_cx/internal/sessions_tracing_connection.h index d9a12a5020af8..25debd6e7c47f 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/sessions_tracing_connection.h @@ -66,6 +66,12 @@ class SessionsTracingConnection : public dialogflow_cx::SessionsConnection { google::cloud::dialogflow::cx::v3::SubmitAnswerFeedbackRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_cx/internal/sessions_tracing_stub.cc b/google/cloud/dialogflow_cx/internal/sessions_tracing_stub.cc index b5e7d62990075..edccf6781bb6e 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/sessions_tracing_stub.cc @@ -115,6 +115,29 @@ SessionsTracingStub::SubmitAnswerFeedback( context, *span, child_->SubmitAnswerFeedback(context, options, request)); } +StatusOr +SessionsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Sessions", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr SessionsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Sessions", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeSessionsTracingStub( diff --git a/google/cloud/dialogflow_cx/internal/sessions_tracing_stub.h b/google/cloud/dialogflow_cx/internal/sessions_tracing_stub.h index 843a2db57fe34..cd950f5563693 100644 --- a/google/cloud/dialogflow_cx/internal/sessions_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/sessions_tracing_stub.h @@ -74,6 +74,14 @@ class SessionsTracingStub : public SessionsStub { google::cloud::dialogflow::cx::v3::SubmitAnswerFeedbackRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/dialogflow_cx/internal/test_cases_auth_decorator.cc b/google/cloud/dialogflow_cx/internal/test_cases_auth_decorator.cc index a18b746238c9e..923a7b8809f12 100644 --- a/google/cloud/dialogflow_cx/internal/test_cases_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/test_cases_auth_decorator.cc @@ -220,6 +220,23 @@ TestCasesAuth::GetTestCaseResult( return child_->GetTestCaseResult(context, options, request); } +StatusOr +TestCasesAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr TestCasesAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> TestCasesAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/test_cases_auth_decorator.h b/google/cloud/dialogflow_cx/internal/test_cases_auth_decorator.h index 331546404c1a9..59cba47bb2d06 100644 --- a/google/cloud/dialogflow_cx/internal/test_cases_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/test_cases_auth_decorator.h @@ -129,6 +129,14 @@ class TestCasesAuth : public TestCasesStub { google::cloud::dialogflow::cx::v3::GetTestCaseResultRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/test_cases_connection_impl.cc b/google/cloud/dialogflow_cx/internal/test_cases_connection_impl.cc index 5049547b5ea06..9278732ff30bf 100644 --- a/google/cloud/dialogflow_cx/internal/test_cases_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/test_cases_connection_impl.cc @@ -604,6 +604,54 @@ TestCasesConnectionImpl::GetTestCaseResult( *current, request, __func__); } +StreamRange +TestCasesConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +TestCasesConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/test_cases_connection_impl.h b/google/cloud/dialogflow_cx/internal/test_cases_connection_impl.h index 387eed39e7626..a79186c8e91dc 100644 --- a/google/cloud/dialogflow_cx/internal/test_cases_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/test_cases_connection_impl.h @@ -135,6 +135,12 @@ class TestCasesConnectionImpl : public dialogflow_cx::TestCasesConnection { google::cloud::dialogflow::cx::v3::GetTestCaseResultRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_cx/internal/test_cases_logging_decorator.cc b/google/cloud/dialogflow_cx/internal/test_cases_logging_decorator.cc index a367274d2a449..451700d517901 100644 --- a/google/cloud/dialogflow_cx/internal/test_cases_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/test_cases_logging_decorator.cc @@ -270,6 +270,29 @@ TestCasesLogging::GetTestCaseResult( context, options, request, __func__, tracing_options_); } +StatusOr +TestCasesLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr TestCasesLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> TestCasesLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/test_cases_logging_decorator.h b/google/cloud/dialogflow_cx/internal/test_cases_logging_decorator.h index cc27fb79d4350..65c7d65894b6c 100644 --- a/google/cloud/dialogflow_cx/internal/test_cases_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/test_cases_logging_decorator.h @@ -129,6 +129,14 @@ class TestCasesLogging : public TestCasesStub { google::cloud::dialogflow::cx::v3::GetTestCaseResultRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/test_cases_metadata_decorator.cc b/google/cloud/dialogflow_cx/internal/test_cases_metadata_decorator.cc index b02f517bbb10d..efd98bf560692 100644 --- a/google/cloud/dialogflow_cx/internal/test_cases_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/test_cases_metadata_decorator.cc @@ -202,6 +202,23 @@ TestCasesMetadata::GetTestCaseResult( return child_->GetTestCaseResult(context, options, request); } +StatusOr +TestCasesMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr TestCasesMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> TestCasesMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/test_cases_metadata_decorator.h b/google/cloud/dialogflow_cx/internal/test_cases_metadata_decorator.h index 786f973b3ac07..aea0ccc38deaf 100644 --- a/google/cloud/dialogflow_cx/internal/test_cases_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/test_cases_metadata_decorator.h @@ -129,6 +129,14 @@ class TestCasesMetadata : public TestCasesStub { google::cloud::dialogflow::cx::v3::GetTestCaseResultRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/test_cases_stub.cc b/google/cloud/dialogflow_cx/internal/test_cases_stub.cc index f73eb390bc698..0e1e6b02f26a5 100644 --- a/google/cloud/dialogflow_cx/internal/test_cases_stub.cc +++ b/google/cloud/dialogflow_cx/internal/test_cases_stub.cc @@ -253,6 +253,29 @@ DefaultTestCasesStub::GetTestCaseResult( return response; } +StatusOr +DefaultTestCasesStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultTestCasesStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultTestCasesStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/test_cases_stub.h b/google/cloud/dialogflow_cx/internal/test_cases_stub.h index 038cf997ac165..4fd1c54a8016f 100644 --- a/google/cloud/dialogflow_cx/internal/test_cases_stub.h +++ b/google/cloud/dialogflow_cx/internal/test_cases_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -128,6 +130,15 @@ class TestCasesStub { google::cloud::dialogflow::cx::v3::GetTestCaseResultRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -147,9 +158,13 @@ class DefaultTestCasesStub : public TestCasesStub { std::unique_ptr< google::cloud::dialogflow::cx::v3::TestCases::StubInterface> grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListTestCases(grpc::ClientContext& context, Options const& options, @@ -241,6 +256,14 @@ class DefaultTestCasesStub : public TestCasesStub { google::cloud::dialogflow::cx::v3::GetTestCaseResultRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -256,6 +279,8 @@ class DefaultTestCasesStub : public TestCasesStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/dialogflow_cx/internal/test_cases_stub_factory.cc b/google/cloud/dialogflow_cx/internal/test_cases_stub_factory.cc index 73bc6d2d59878..7557ccbd474de 100644 --- a/google/cloud/dialogflow_cx/internal/test_cases_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/test_cases_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,8 +45,10 @@ std::shared_ptr CreateDefaultTestCasesStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::TestCases::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/dialogflow_cx/internal/test_cases_tracing_connection.cc b/google/cloud/dialogflow_cx/internal/test_cases_tracing_connection.cc index c389cea43ef6b..99a83d7e39b20 100644 --- a/google/cloud/dialogflow_cx/internal/test_cases_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/test_cases_tracing_connection.cc @@ -231,6 +231,26 @@ TestCasesTracingConnection::GetTestCaseResult( return internal::EndSpan(*span, child_->GetTestCaseResult(request)); } +StreamRange +TestCasesTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_cx::TestCasesConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +TestCasesTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::TestCasesConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_cx/internal/test_cases_tracing_connection.h b/google/cloud/dialogflow_cx/internal/test_cases_tracing_connection.h index 111f5bad68931..22ec2deb36fe9 100644 --- a/google/cloud/dialogflow_cx/internal/test_cases_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/test_cases_tracing_connection.h @@ -123,6 +123,12 @@ class TestCasesTracingConnection : public dialogflow_cx::TestCasesConnection { google::cloud::dialogflow::cx::v3::GetTestCaseResultRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_cx/internal/test_cases_tracing_stub.cc b/google/cloud/dialogflow_cx/internal/test_cases_tracing_stub.cc index 272929a596528..f6cffef57e685 100644 --- a/google/cloud/dialogflow_cx/internal/test_cases_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/test_cases_tracing_stub.cc @@ -236,6 +236,29 @@ TestCasesTracingStub::GetTestCaseResult( context, *span, child_->GetTestCaseResult(context, options, request)); } +StatusOr +TestCasesTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.TestCases", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr TestCasesTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.TestCases", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> TestCasesTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/test_cases_tracing_stub.h b/google/cloud/dialogflow_cx/internal/test_cases_tracing_stub.h index 530eb1f34917f..e4c6bcd84bc28 100644 --- a/google/cloud/dialogflow_cx/internal/test_cases_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/test_cases_tracing_stub.h @@ -128,6 +128,14 @@ class TestCasesTracingStub : public TestCasesStub { google::cloud::dialogflow::cx::v3::GetTestCaseResultRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/transition_route_groups_auth_decorator.cc b/google/cloud/dialogflow_cx/internal/transition_route_groups_auth_decorator.cc index 2707e4af9a27e..10687f7c66de2 100644 --- a/google/cloud/dialogflow_cx/internal/transition_route_groups_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/transition_route_groups_auth_decorator.cc @@ -80,6 +80,24 @@ Status TransitionRouteGroupsAuth::DeleteTransitionRouteGroup( return child_->DeleteTransitionRouteGroup(context, options, request); } +StatusOr +TransitionRouteGroupsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +TransitionRouteGroupsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/transition_route_groups_auth_decorator.h b/google/cloud/dialogflow_cx/internal/transition_route_groups_auth_decorator.h index ff7e5e655b466..5f54945adaf5c 100644 --- a/google/cloud/dialogflow_cx/internal/transition_route_groups_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/transition_route_groups_auth_decorator.h @@ -67,6 +67,14 @@ class TransitionRouteGroupsAuth : public TransitionRouteGroupsStub { google::cloud::dialogflow::cx::v3:: DeleteTransitionRouteGroupRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/dialogflow_cx/internal/transition_route_groups_connection_impl.cc b/google/cloud/dialogflow_cx/internal/transition_route_groups_connection_impl.cc index 6bd3d25fa5616..13d7addd78c96 100644 --- a/google/cloud/dialogflow_cx/internal/transition_route_groups_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/transition_route_groups_connection_impl.cc @@ -163,6 +163,54 @@ Status TransitionRouteGroupsConnectionImpl::DeleteTransitionRouteGroup( *current, request, __func__); } +StreamRange +TransitionRouteGroupsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +TransitionRouteGroupsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/transition_route_groups_connection_impl.h b/google/cloud/dialogflow_cx/internal/transition_route_groups_connection_impl.h index e4e457d7c3f20..a16f0c9d507cb 100644 --- a/google/cloud/dialogflow_cx/internal/transition_route_groups_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/transition_route_groups_connection_impl.h @@ -73,6 +73,12 @@ class TransitionRouteGroupsConnectionImpl google::cloud::dialogflow::cx::v3:: DeleteTransitionRouteGroupRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_cx/internal/transition_route_groups_logging_decorator.cc b/google/cloud/dialogflow_cx/internal/transition_route_groups_logging_decorator.cc index e701a16f2277d..a7104fb864084 100644 --- a/google/cloud/dialogflow_cx/internal/transition_route_groups_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/transition_route_groups_logging_decorator.cc @@ -104,6 +104,30 @@ Status TransitionRouteGroupsLogging::DeleteTransitionRouteGroup( context, options, request, __func__, tracing_options_); } +StatusOr +TransitionRouteGroupsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +TransitionRouteGroupsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/transition_route_groups_logging_decorator.h b/google/cloud/dialogflow_cx/internal/transition_route_groups_logging_decorator.h index 5240d843866ed..aababe7058a2f 100644 --- a/google/cloud/dialogflow_cx/internal/transition_route_groups_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/transition_route_groups_logging_decorator.h @@ -67,6 +67,14 @@ class TransitionRouteGroupsLogging : public TransitionRouteGroupsStub { google::cloud::dialogflow::cx::v3:: DeleteTransitionRouteGroupRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/dialogflow_cx/internal/transition_route_groups_metadata_decorator.cc b/google/cloud/dialogflow_cx/internal/transition_route_groups_metadata_decorator.cc index 46771906d678f..028aa81aab47b 100644 --- a/google/cloud/dialogflow_cx/internal/transition_route_groups_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/transition_route_groups_metadata_decorator.cc @@ -95,6 +95,24 @@ Status TransitionRouteGroupsMetadata::DeleteTransitionRouteGroup( return child_->DeleteTransitionRouteGroup(context, options, request); } +StatusOr +TransitionRouteGroupsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +TransitionRouteGroupsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void TransitionRouteGroupsMetadata::SetMetadata( grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/dialogflow_cx/internal/transition_route_groups_metadata_decorator.h b/google/cloud/dialogflow_cx/internal/transition_route_groups_metadata_decorator.h index 6ed331e8b0bd6..d8bf4a2e978dd 100644 --- a/google/cloud/dialogflow_cx/internal/transition_route_groups_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/transition_route_groups_metadata_decorator.h @@ -68,6 +68,14 @@ class TransitionRouteGroupsMetadata : public TransitionRouteGroupsStub { google::cloud::dialogflow::cx::v3:: DeleteTransitionRouteGroupRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/dialogflow_cx/internal/transition_route_groups_stub.cc b/google/cloud/dialogflow_cx/internal/transition_route_groups_stub.cc index 26ab9285aee1f..8b777cbd45407 100644 --- a/google/cloud/dialogflow_cx/internal/transition_route_groups_stub.cc +++ b/google/cloud/dialogflow_cx/internal/transition_route_groups_stub.cc @@ -99,6 +99,30 @@ Status DefaultTransitionRouteGroupsStub::DeleteTransitionRouteGroup( return google::cloud::Status(); } +StatusOr +DefaultTransitionRouteGroupsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultTransitionRouteGroupsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/transition_route_groups_stub.h b/google/cloud/dialogflow_cx/internal/transition_route_groups_stub.h index 87d4d5bfc4e40..39854f7f076cf 100644 --- a/google/cloud/dialogflow_cx/internal/transition_route_groups_stub.h +++ b/google/cloud/dialogflow_cx/internal/transition_route_groups_stub.h @@ -23,6 +23,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -64,6 +66,15 @@ class TransitionRouteGroupsStub { grpc::ClientContext& context, Options const& options, google::cloud::dialogflow::cx::v3:: DeleteTransitionRouteGroupRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultTransitionRouteGroupsStub : public TransitionRouteGroupsStub { @@ -71,8 +82,11 @@ class DefaultTransitionRouteGroupsStub : public TransitionRouteGroupsStub { explicit DefaultTransitionRouteGroupsStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListTransitionRouteGroups( @@ -103,10 +117,20 @@ class DefaultTransitionRouteGroupsStub : public TransitionRouteGroupsStub { google::cloud::dialogflow::cx::v3:: DeleteTransitionRouteGroupRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr< google::cloud::dialogflow::cx::v3::TransitionRouteGroups::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/internal/transition_route_groups_stub_factory.cc b/google/cloud/dialogflow_cx/internal/transition_route_groups_stub_factory.cc index 976057bd1ed99..2a9b0e4886bc2 100644 --- a/google/cloud/dialogflow_cx/internal/transition_route_groups_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/transition_route_groups_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -46,9 +47,11 @@ CreateDefaultTransitionRouteGroupsStub( auto service_grpc_stub = google::cloud::dialogflow::cx::v3::TransitionRouteGroups::NewStub( channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/dialogflow_cx/internal/transition_route_groups_tracing_connection.cc b/google/cloud/dialogflow_cx/internal/transition_route_groups_tracing_connection.cc index b8acf7f8608cb..b4773f48808a3 100644 --- a/google/cloud/dialogflow_cx/internal/transition_route_groups_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/transition_route_groups_tracing_connection.cc @@ -90,6 +90,26 @@ Status TransitionRouteGroupsTracingConnection::DeleteTransitionRouteGroup( return internal::EndSpan(*span, child_->DeleteTransitionRouteGroup(request)); } +StreamRange +TransitionRouteGroupsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_cx::TransitionRouteGroupsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +TransitionRouteGroupsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_cx::TransitionRouteGroupsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_cx/internal/transition_route_groups_tracing_connection.h b/google/cloud/dialogflow_cx/internal/transition_route_groups_tracing_connection.h index 403c0eccca4ed..ebc8a589684e4 100644 --- a/google/cloud/dialogflow_cx/internal/transition_route_groups_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/transition_route_groups_tracing_connection.h @@ -64,6 +64,12 @@ class TransitionRouteGroupsTracingConnection google::cloud::dialogflow::cx::v3:: DeleteTransitionRouteGroupRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_cx/internal/transition_route_groups_tracing_stub.cc b/google/cloud/dialogflow_cx/internal/transition_route_groups_tracing_stub.cc index d60b900f72761..f7899fa68dcd9 100644 --- a/google/cloud/dialogflow_cx/internal/transition_route_groups_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/transition_route_groups_tracing_stub.cc @@ -106,6 +106,30 @@ Status TransitionRouteGroupsTracingStub::DeleteTransitionRouteGroup( child_->DeleteTransitionRouteGroup(context, options, request)); } +StatusOr +TransitionRouteGroupsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.TransitionRouteGroups", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +TransitionRouteGroupsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.cx.v3.TransitionRouteGroups", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeTransitionRouteGroupsTracingStub( diff --git a/google/cloud/dialogflow_cx/internal/transition_route_groups_tracing_stub.h b/google/cloud/dialogflow_cx/internal/transition_route_groups_tracing_stub.h index 79c6a94bec1cd..2c147137bb9c6 100644 --- a/google/cloud/dialogflow_cx/internal/transition_route_groups_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/transition_route_groups_tracing_stub.h @@ -68,6 +68,14 @@ class TransitionRouteGroupsTracingStub : public TransitionRouteGroupsStub { google::cloud::dialogflow::cx::v3:: DeleteTransitionRouteGroupRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/dialogflow_cx/internal/versions_auth_decorator.cc b/google/cloud/dialogflow_cx/internal/versions_auth_decorator.cc index 49f8eb2ea3fa3..3d4b55da11ee1 100644 --- a/google/cloud/dialogflow_cx/internal/versions_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/versions_auth_decorator.cc @@ -129,6 +129,23 @@ VersionsAuth::CompareVersions( return child_->CompareVersions(context, options, request); } +StatusOr +VersionsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr VersionsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> VersionsAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/versions_auth_decorator.h b/google/cloud/dialogflow_cx/internal/versions_auth_decorator.h index b45e72f621510..7eca0524d23cd 100644 --- a/google/cloud/dialogflow_cx/internal/versions_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/versions_auth_decorator.h @@ -89,6 +89,14 @@ class VersionsAuth : public VersionsStub { google::cloud::dialogflow::cx::v3::CompareVersionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/versions_connection_impl.cc b/google/cloud/dialogflow_cx/internal/versions_connection_impl.cc index 7350b1131912b..6d22bf71156ed 100644 --- a/google/cloud/dialogflow_cx/internal/versions_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/versions_connection_impl.cc @@ -337,6 +337,53 @@ VersionsConnectionImpl::CompareVersions( *current, request, __func__); } +StreamRange +VersionsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr VersionsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/versions_connection_impl.h b/google/cloud/dialogflow_cx/internal/versions_connection_impl.h index ff1fb5ed56741..43ddbe5f8d82c 100644 --- a/google/cloud/dialogflow_cx/internal/versions_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/versions_connection_impl.h @@ -95,6 +95,12 @@ class VersionsConnectionImpl : public dialogflow_cx::VersionsConnection { google::cloud::dialogflow::cx::v3::CompareVersionsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_cx/internal/versions_logging_decorator.cc b/google/cloud/dialogflow_cx/internal/versions_logging_decorator.cc index 1aa44acc7584f..b28435e90fe87 100644 --- a/google/cloud/dialogflow_cx/internal/versions_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/versions_logging_decorator.cc @@ -161,6 +161,29 @@ VersionsLogging::CompareVersions( context, options, request, __func__, tracing_options_); } +StatusOr +VersionsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr VersionsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> VersionsLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/versions_logging_decorator.h b/google/cloud/dialogflow_cx/internal/versions_logging_decorator.h index 52e7835a3de80..d523f0a058b78 100644 --- a/google/cloud/dialogflow_cx/internal/versions_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/versions_logging_decorator.h @@ -89,6 +89,14 @@ class VersionsLogging : public VersionsStub { google::cloud::dialogflow::cx::v3::CompareVersionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/versions_metadata_decorator.cc b/google/cloud/dialogflow_cx/internal/versions_metadata_decorator.cc index 02644ee716690..4f7e302714297 100644 --- a/google/cloud/dialogflow_cx/internal/versions_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/versions_metadata_decorator.cc @@ -130,6 +130,23 @@ VersionsMetadata::CompareVersions( return child_->CompareVersions(context, options, request); } +StatusOr +VersionsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr VersionsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> VersionsMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/versions_metadata_decorator.h b/google/cloud/dialogflow_cx/internal/versions_metadata_decorator.h index e5b09f2d5b07b..be9f37fe6dedd 100644 --- a/google/cloud/dialogflow_cx/internal/versions_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/versions_metadata_decorator.h @@ -89,6 +89,14 @@ class VersionsMetadata : public VersionsStub { google::cloud::dialogflow::cx::v3::CompareVersionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/versions_stub.cc b/google/cloud/dialogflow_cx/internal/versions_stub.cc index 5661c5b35227b..470ebaa1e4ef3 100644 --- a/google/cloud/dialogflow_cx/internal/versions_stub.cc +++ b/google/cloud/dialogflow_cx/internal/versions_stub.cc @@ -150,6 +150,29 @@ DefaultVersionsStub::CompareVersions( return response; } +StatusOr +DefaultVersionsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultVersionsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultVersionsStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/versions_stub.h b/google/cloud/dialogflow_cx/internal/versions_stub.h index 48dc60c38a2cb..ee000cefc3703 100644 --- a/google/cloud/dialogflow_cx/internal/versions_stub.h +++ b/google/cloud/dialogflow_cx/internal/versions_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -86,6 +88,15 @@ class VersionsStub { google::cloud::dialogflow::cx::v3::CompareVersionsRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -105,9 +116,13 @@ class DefaultVersionsStub : public VersionsStub { std::unique_ptr< google::cloud::dialogflow::cx::v3::Versions::StubInterface> grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListVersions(grpc::ClientContext& context, Options const& options, @@ -159,6 +174,14 @@ class DefaultVersionsStub : public VersionsStub { google::cloud::dialogflow::cx::v3::CompareVersionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -174,6 +197,8 @@ class DefaultVersionsStub : public VersionsStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/dialogflow_cx/internal/versions_stub_factory.cc b/google/cloud/dialogflow_cx/internal/versions_stub_factory.cc index ec4d7ebd5beaf..3f3d6b79cf561 100644 --- a/google/cloud/dialogflow_cx/internal/versions_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/versions_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,8 +45,10 @@ std::shared_ptr CreateDefaultVersionsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::Versions::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/dialogflow_cx/internal/versions_tracing_connection.cc b/google/cloud/dialogflow_cx/internal/versions_tracing_connection.cc index 81788d7502871..f2d978cfbd29c 100644 --- a/google/cloud/dialogflow_cx/internal/versions_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/versions_tracing_connection.cc @@ -135,6 +135,26 @@ VersionsTracingConnection::CompareVersions( return internal::EndSpan(*span, child_->CompareVersions(request)); } +StreamRange +VersionsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_cx::VersionsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +VersionsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::VersionsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_cx/internal/versions_tracing_connection.h b/google/cloud/dialogflow_cx/internal/versions_tracing_connection.h index 01d771eb2abb8..fb3486b0d386e 100644 --- a/google/cloud/dialogflow_cx/internal/versions_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/versions_tracing_connection.h @@ -83,6 +83,12 @@ class VersionsTracingConnection : public dialogflow_cx::VersionsConnection { google::cloud::dialogflow::cx::v3::CompareVersionsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_cx/internal/versions_tracing_stub.cc b/google/cloud/dialogflow_cx/internal/versions_tracing_stub.cc index 48107c6a1c7c0..5f9759f9831bc 100644 --- a/google/cloud/dialogflow_cx/internal/versions_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/versions_tracing_stub.cc @@ -140,6 +140,29 @@ VersionsTracingStub::CompareVersions( child_->CompareVersions(context, options, request)); } +StatusOr +VersionsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Versions", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr VersionsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Versions", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> VersionsTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_cx/internal/versions_tracing_stub.h b/google/cloud/dialogflow_cx/internal/versions_tracing_stub.h index 24c6b9791f5d1..4ea6d0c4f40db 100644 --- a/google/cloud/dialogflow_cx/internal/versions_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/versions_tracing_stub.h @@ -88,6 +88,14 @@ class VersionsTracingStub : public VersionsStub { google::cloud::dialogflow::cx::v3::CompareVersionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_cx/internal/webhooks_auth_decorator.cc b/google/cloud/dialogflow_cx/internal/webhooks_auth_decorator.cc index d11fa3a7810b1..30239334b06a9 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_auth_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/webhooks_auth_decorator.cc @@ -74,6 +74,23 @@ Status WebhooksAuth::DeleteWebhook( return child_->DeleteWebhook(context, options, request); } +StatusOr +WebhooksAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr WebhooksAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/webhooks_auth_decorator.h b/google/cloud/dialogflow_cx/internal/webhooks_auth_decorator.h index eb950274760a6..a5f52ea1ef0a6 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_auth_decorator.h +++ b/google/cloud/dialogflow_cx/internal/webhooks_auth_decorator.h @@ -63,6 +63,14 @@ class WebhooksAuth : public WebhooksStub { google::cloud::dialogflow::cx::v3::DeleteWebhookRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/dialogflow_cx/internal/webhooks_connection_impl.cc b/google/cloud/dialogflow_cx/internal/webhooks_connection_impl.cc index da4a9b4c271f7..7d97f593f94b0 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_connection_impl.cc +++ b/google/cloud/dialogflow_cx/internal/webhooks_connection_impl.cc @@ -151,6 +151,53 @@ Status WebhooksConnectionImpl::DeleteWebhook( *current, request, __func__); } +StreamRange +WebhooksConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr WebhooksConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/webhooks_connection_impl.h b/google/cloud/dialogflow_cx/internal/webhooks_connection_impl.h index cdf883db1f04f..21e91763852b1 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_connection_impl.h +++ b/google/cloud/dialogflow_cx/internal/webhooks_connection_impl.h @@ -67,6 +67,12 @@ class WebhooksConnectionImpl : public dialogflow_cx::WebhooksConnection { google::cloud::dialogflow::cx::v3::DeleteWebhookRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_cx/internal/webhooks_logging_decorator.cc b/google/cloud/dialogflow_cx/internal/webhooks_logging_decorator.cc index 11a1f6c17dfb7..f3263b53341d8 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_logging_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/webhooks_logging_decorator.cc @@ -99,6 +99,29 @@ Status WebhooksLogging::DeleteWebhook( context, options, request, __func__, tracing_options_); } +StatusOr +WebhooksLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr WebhooksLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/webhooks_logging_decorator.h b/google/cloud/dialogflow_cx/internal/webhooks_logging_decorator.h index 86fdcf1310aab..0812acb15a50a 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_logging_decorator.h +++ b/google/cloud/dialogflow_cx/internal/webhooks_logging_decorator.h @@ -63,6 +63,14 @@ class WebhooksLogging : public WebhooksStub { google::cloud::dialogflow::cx::v3::DeleteWebhookRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/dialogflow_cx/internal/webhooks_metadata_decorator.cc b/google/cloud/dialogflow_cx/internal/webhooks_metadata_decorator.cc index 500857f15f48a..f8fcd34d489cb 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_metadata_decorator.cc +++ b/google/cloud/dialogflow_cx/internal/webhooks_metadata_decorator.cc @@ -89,6 +89,23 @@ Status WebhooksMetadata::DeleteWebhook( return child_->DeleteWebhook(context, options, request); } +StatusOr +WebhooksMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr WebhooksMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void WebhooksMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/dialogflow_cx/internal/webhooks_metadata_decorator.h b/google/cloud/dialogflow_cx/internal/webhooks_metadata_decorator.h index 2fae4475a5eea..369e3b881c5be 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_metadata_decorator.h +++ b/google/cloud/dialogflow_cx/internal/webhooks_metadata_decorator.h @@ -63,6 +63,14 @@ class WebhooksMetadata : public WebhooksStub { google::cloud::dialogflow::cx::v3::DeleteWebhookRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/dialogflow_cx/internal/webhooks_stub.cc b/google/cloud/dialogflow_cx/internal/webhooks_stub.cc index 040301b179d26..85181dd7f38ae 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_stub.cc +++ b/google/cloud/dialogflow_cx/internal/webhooks_stub.cc @@ -89,6 +89,29 @@ Status DefaultWebhooksStub::DeleteWebhook( return google::cloud::Status(); } +StatusOr +DefaultWebhooksStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultWebhooksStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx_internal } // namespace cloud diff --git a/google/cloud/dialogflow_cx/internal/webhooks_stub.h b/google/cloud/dialogflow_cx/internal/webhooks_stub.h index 492f34fbdffff..667ccc118278b 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_stub.h +++ b/google/cloud/dialogflow_cx/internal/webhooks_stub.h @@ -23,6 +23,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -58,6 +60,15 @@ class WebhooksStub { grpc::ClientContext& context, Options const& options, google::cloud::dialogflow::cx::v3::DeleteWebhookRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultWebhooksStub : public WebhooksStub { @@ -65,8 +76,11 @@ class DefaultWebhooksStub : public WebhooksStub { explicit DefaultWebhooksStub( std::unique_ptr< google::cloud::dialogflow::cx::v3::Webhooks::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListWebhooks(grpc::ClientContext& context, Options const& options, @@ -93,9 +107,19 @@ class DefaultWebhooksStub : public WebhooksStub { google::cloud::dialogflow::cx::v3::DeleteWebhookRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/internal/webhooks_stub_factory.cc b/google/cloud/dialogflow_cx/internal/webhooks_stub_factory.cc index 73e9db19dd178..341128824e90a 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_stub_factory.cc +++ b/google/cloud/dialogflow_cx/internal/webhooks_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,8 +45,10 @@ std::shared_ptr CreateDefaultWebhooksStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::cx::v3::Webhooks::NewStub(channel); - std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); + std::shared_ptr stub = std::make_shared( + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), std::move(stub)); diff --git a/google/cloud/dialogflow_cx/internal/webhooks_tracing_connection.cc b/google/cloud/dialogflow_cx/internal/webhooks_tracing_connection.cc index 60ac51f6ec5a2..54d0fd7e466bd 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_tracing_connection.cc +++ b/google/cloud/dialogflow_cx/internal/webhooks_tracing_connection.cc @@ -80,6 +80,26 @@ Status WebhooksTracingConnection::DeleteWebhook( return internal::EndSpan(*span, child_->DeleteWebhook(request)); } +StreamRange +WebhooksTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_cx::WebhooksConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +WebhooksTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_cx::WebhooksConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_cx/internal/webhooks_tracing_connection.h b/google/cloud/dialogflow_cx/internal/webhooks_tracing_connection.h index 8bce5b12981b0..c33509ff4273a 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_tracing_connection.h +++ b/google/cloud/dialogflow_cx/internal/webhooks_tracing_connection.h @@ -58,6 +58,12 @@ class WebhooksTracingConnection : public dialogflow_cx::WebhooksConnection { google::cloud::dialogflow::cx::v3::DeleteWebhookRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_cx/internal/webhooks_tracing_stub.cc b/google/cloud/dialogflow_cx/internal/webhooks_tracing_stub.cc index 105fa80dec4fb..c36e0f108d18d 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_tracing_stub.cc +++ b/google/cloud/dialogflow_cx/internal/webhooks_tracing_stub.cc @@ -90,6 +90,29 @@ Status WebhooksTracingStub::DeleteWebhook( child_->DeleteWebhook(context, options, request)); } +StatusOr +WebhooksTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Webhooks", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr WebhooksTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.cx.v3.Webhooks", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeWebhooksTracingStub( diff --git a/google/cloud/dialogflow_cx/internal/webhooks_tracing_stub.h b/google/cloud/dialogflow_cx/internal/webhooks_tracing_stub.h index a29f949afe72d..6ac8ce02593d7 100644 --- a/google/cloud/dialogflow_cx/internal/webhooks_tracing_stub.h +++ b/google/cloud/dialogflow_cx/internal/webhooks_tracing_stub.h @@ -63,6 +63,14 @@ class WebhooksTracingStub : public WebhooksStub { google::cloud::dialogflow::cx::v3::DeleteWebhookRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/dialogflow_cx/mocks/mock_agents_connection.h b/google/cloud/dialogflow_cx/mocks/mock_agents_connection.h index ef107f766d956..fa537e123b328 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_agents_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_agents_connection.h @@ -174,6 +174,14 @@ class MockAgentsConnection : public dialogflow_cx::AgentsConnection { (google::cloud::dialogflow::cx::v3::UpdateGenerativeSettingsRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/mocks/mock_changelogs_connection.h b/google/cloud/dialogflow_cx/mocks/mock_changelogs_connection.h index 03c242e35b0b9..16c19d3e537bc 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_changelogs_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_changelogs_connection.h @@ -56,6 +56,14 @@ class MockChangelogsConnection : public dialogflow_cx::ChangelogsConnection { StatusOr, GetChangelog, (google::cloud::dialogflow::cx::v3::GetChangelogRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/mocks/mock_deployments_connection.h b/google/cloud/dialogflow_cx/mocks/mock_deployments_connection.h index 21f5f4bed642e..576395c7a5540 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_deployments_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_deployments_connection.h @@ -56,6 +56,14 @@ class MockDeploymentsConnection : public dialogflow_cx::DeploymentsConnection { StatusOr, GetDeployment, (google::cloud::dialogflow::cx::v3::GetDeploymentRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/mocks/mock_entity_types_connection.h b/google/cloud/dialogflow_cx/mocks/mock_entity_types_connection.h index ad1715b27ea34..a91e859b366f6 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_entity_types_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_entity_types_connection.h @@ -161,6 +161,14 @@ class MockEntityTypesConnection : public dialogflow_cx::EntityTypesConnection { google::cloud::dialogflow::cx::v3::ImportEntityTypesResponse>>, ImportEntityTypes, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/mocks/mock_environments_connection.h b/google/cloud/dialogflow_cx/mocks/mock_environments_connection.h index cd491f7d4c5ef..6a31599361d6f 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_environments_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_environments_connection.h @@ -243,6 +243,14 @@ class MockEnvironmentsConnection future>, DeployFlow, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/mocks/mock_experiments_connection.h b/google/cloud/dialogflow_cx/mocks/mock_experiments_connection.h index ff92a71ebf308..198c417df6824 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_experiments_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_experiments_connection.h @@ -84,6 +84,14 @@ class MockExperimentsConnection : public dialogflow_cx::ExperimentsConnection { StatusOr, StopExperiment, (google::cloud::dialogflow::cx::v3::StopExperimentRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/mocks/mock_flows_connection.h b/google/cloud/dialogflow_cx/mocks/mock_flows_connection.h index f7e3cb0beb4cf..57f0cbfc94d33 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_flows_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_flows_connection.h @@ -199,6 +199,14 @@ class MockFlowsConnection : public dialogflow_cx::FlowsConnection { future>, ExportFlow, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/mocks/mock_generators_connection.h b/google/cloud/dialogflow_cx/mocks/mock_generators_connection.h index 70eb029da0569..49c9ec7fa8877 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_generators_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_generators_connection.h @@ -73,6 +73,14 @@ class MockGeneratorsConnection : public dialogflow_cx::GeneratorsConnection { (google::cloud::dialogflow::cx::v3::DeleteGeneratorRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/mocks/mock_intents_connection.h b/google/cloud/dialogflow_cx/mocks/mock_intents_connection.h index 84fffa5af5e3b..9f67aa3e397fc 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_intents_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_intents_connection.h @@ -154,6 +154,14 @@ class MockIntentsConnection : public dialogflow_cx::IntentsConnection { StatusOr>, ExportIntents, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/mocks/mock_pages_connection.h b/google/cloud/dialogflow_cx/mocks/mock_pages_connection.h index 071af1685017b..e744d3d5be6cc 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_pages_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_pages_connection.h @@ -69,6 +69,14 @@ class MockPagesConnection : public dialogflow_cx::PagesConnection { Status, DeletePage, (google::cloud::dialogflow::cx::v3::DeletePageRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/mocks/mock_security_settings_connection.h b/google/cloud/dialogflow_cx/mocks/mock_security_settings_connection.h index e2f7f36da5b86..93c7a562aa41a 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_security_settings_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_security_settings_connection.h @@ -79,6 +79,14 @@ class MockSecuritySettingsServiceConnection (google::cloud::dialogflow::cx::v3::DeleteSecuritySettingsRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/mocks/mock_session_entity_types_connection.h b/google/cloud/dialogflow_cx/mocks/mock_session_entity_types_connection.h index d6bf1cd853287..9641deeaa363e 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_session_entity_types_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_session_entity_types_connection.h @@ -80,6 +80,14 @@ class MockSessionEntityTypesConnection (google::cloud::dialogflow::cx::v3::DeleteSessionEntityTypeRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/mocks/mock_sessions_connection.h b/google/cloud/dialogflow_cx/mocks/mock_sessions_connection.h index 0669f803ee344..fba46ffeffe23 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_sessions_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_sessions_connection.h @@ -82,6 +82,14 @@ class MockSessionsConnection : public dialogflow_cx::SessionsConnection { (google::cloud::dialogflow::cx::v3::SubmitAnswerFeedbackRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/mocks/mock_test_cases_connection.h b/google/cloud/dialogflow_cx/mocks/mock_test_cases_connection.h index 84344c3e09a76..2e480865afa2b 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_test_cases_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_test_cases_connection.h @@ -261,6 +261,14 @@ class MockTestCasesConnection : public dialogflow_cx::TestCasesConnection { (google::cloud::dialogflow::cx::v3::GetTestCaseResultRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/mocks/mock_transition_route_groups_connection.h b/google/cloud/dialogflow_cx/mocks/mock_transition_route_groups_connection.h index dedc7ca9e948f..5f33d01df0f54 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_transition_route_groups_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_transition_route_groups_connection.h @@ -77,6 +77,14 @@ class MockTransitionRouteGroupsConnection (google::cloud::dialogflow::cx::v3:: DeleteTransitionRouteGroupRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/mocks/mock_versions_connection.h b/google/cloud/dialogflow_cx/mocks/mock_versions_connection.h index 46602755985a3..c2279507a3999 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_versions_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_versions_connection.h @@ -148,6 +148,14 @@ class MockVersionsConnection : public dialogflow_cx::VersionsConnection { (google::cloud::dialogflow::cx::v3::CompareVersionsRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/mocks/mock_webhooks_connection.h b/google/cloud/dialogflow_cx/mocks/mock_webhooks_connection.h index 984cfffeb9822..a4d72b6af9037 100644 --- a/google/cloud/dialogflow_cx/mocks/mock_webhooks_connection.h +++ b/google/cloud/dialogflow_cx/mocks/mock_webhooks_connection.h @@ -70,6 +70,14 @@ class MockWebhooksConnection : public dialogflow_cx::WebhooksConnection { Status, DeleteWebhook, (google::cloud::dialogflow::cx::v3::DeleteWebhookRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_cx/pages_client.cc b/google/cloud/dialogflow_cx/pages_client.cc index 6266cac47424e..17e3437cb188a 100644 --- a/google/cloud/dialogflow_cx/pages_client.cc +++ b/google/cloud/dialogflow_cx/pages_client.cc @@ -109,6 +109,18 @@ Status PagesClient::DeletePage( return connection_->DeletePage(request); } +StreamRange PagesClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr PagesClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx } // namespace cloud diff --git a/google/cloud/dialogflow_cx/pages_client.h b/google/cloud/dialogflow_cx/pages_client.h index a31eae6abee43..b6866dd8a842e 100644 --- a/google/cloud/dialogflow_cx/pages_client.h +++ b/google/cloud/dialogflow_cx/pages_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -410,6 +411,76 @@ class PagesClient { google::cloud::dialogflow::cx::v3::DeletePageRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_cx/pages_connection.cc b/google/cloud/dialogflow_cx/pages_connection.cc index fbc8cbb24da77..85ad6539fc36d 100644 --- a/google/cloud/dialogflow_cx/pages_connection.cc +++ b/google/cloud/dialogflow_cx/pages_connection.cc @@ -65,6 +65,18 @@ Status PagesConnection::DeletePage( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange PagesConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr PagesConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakePagesConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include @@ -193,6 +194,12 @@ class PagesConnection { virtual Status DeletePage( google::cloud::dialogflow::cx::v3::DeletePageRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_cx/pages_connection_idempotency_policy.cc b/google/cloud/dialogflow_cx/pages_connection_idempotency_policy.cc index 9524cec37dc00..19e13963d3de5 100644 --- a/google/cloud/dialogflow_cx/pages_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/pages_connection_idempotency_policy.cc @@ -58,6 +58,16 @@ Idempotency PagesConnectionIdempotencyPolicy::DeletePage( return Idempotency::kNonIdempotent; } +Idempotency PagesConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency PagesConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultPagesConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_cx/pages_connection_idempotency_policy.h b/google/cloud/dialogflow_cx/pages_connection_idempotency_policy.h index 20dd95a3b4b37..62b6513d1c4e8 100644 --- a/google/cloud/dialogflow_cx/pages_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/pages_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -50,6 +51,12 @@ class PagesConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeletePage( google::cloud::dialogflow::cx::v3::DeletePageRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_cx/security_settings_client.cc b/google/cloud/dialogflow_cx/security_settings_client.cc index 9a0ae35a73df5..e322855b95641 100644 --- a/google/cloud/dialogflow_cx/security_settings_client.cc +++ b/google/cloud/dialogflow_cx/security_settings_client.cc @@ -126,6 +126,20 @@ Status SecuritySettingsServiceClient::DeleteSecuritySettings( return connection_->DeleteSecuritySettings(request); } +StreamRange +SecuritySettingsServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +SecuritySettingsServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx } // namespace cloud diff --git a/google/cloud/dialogflow_cx/security_settings_client.h b/google/cloud/dialogflow_cx/security_settings_client.h index 03df2f4f0bf6f..33fbe8a59b630 100644 --- a/google/cloud/dialogflow_cx/security_settings_client.h +++ b/google/cloud/dialogflow_cx/security_settings_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -414,6 +415,76 @@ class SecuritySettingsServiceClient { request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_cx/security_settings_connection.cc b/google/cloud/dialogflow_cx/security_settings_connection.cc index f482b9d752063..87c734f88b1bd 100644 --- a/google/cloud/dialogflow_cx/security_settings_connection.cc +++ b/google/cloud/dialogflow_cx/security_settings_connection.cc @@ -70,6 +70,20 @@ Status SecuritySettingsServiceConnection::DeleteSecuritySettings( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +SecuritySettingsServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +SecuritySettingsServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSecuritySettingsServiceConnection(std::string const& location, Options options) { diff --git a/google/cloud/dialogflow_cx/security_settings_connection.h b/google/cloud/dialogflow_cx/security_settings_connection.h index 283e05e7874d0..24aeeddb49a06 100644 --- a/google/cloud/dialogflow_cx/security_settings_connection.h +++ b/google/cloud/dialogflow_cx/security_settings_connection.h @@ -28,6 +28,7 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include #include #include @@ -213,6 +214,12 @@ class SecuritySettingsServiceConnection { virtual Status DeleteSecuritySettings( google::cloud::dialogflow::cx::v3::DeleteSecuritySettingsRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_cx/security_settings_connection_idempotency_policy.cc b/google/cloud/dialogflow_cx/security_settings_connection_idempotency_policy.cc index 502f444ea1e80..c517fd83d962b 100644 --- a/google/cloud/dialogflow_cx/security_settings_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/security_settings_connection_idempotency_policy.cc @@ -65,6 +65,16 @@ SecuritySettingsServiceConnectionIdempotencyPolicy::DeleteSecuritySettings( return Idempotency::kNonIdempotent; } +Idempotency SecuritySettingsServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SecuritySettingsServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultSecuritySettingsServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_cx/security_settings_connection_idempotency_policy.h b/google/cloud/dialogflow_cx/security_settings_connection_idempotency_policy.h index dea6e110c8950..b2f8769fa3c62 100644 --- a/google/cloud/dialogflow_cx/security_settings_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/security_settings_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -55,6 +56,12 @@ class SecuritySettingsServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteSecuritySettings( google::cloud::dialogflow::cx::v3::DeleteSecuritySettingsRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_cx/session_entity_types_client.cc b/google/cloud/dialogflow_cx/session_entity_types_client.cc index c57527f28e1b8..722fb27774c56 100644 --- a/google/cloud/dialogflow_cx/session_entity_types_client.cc +++ b/google/cloud/dialogflow_cx/session_entity_types_client.cc @@ -126,6 +126,20 @@ Status SessionEntityTypesClient::DeleteSessionEntityType( return connection_->DeleteSessionEntityType(request); } +StreamRange +SessionEntityTypesClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +SessionEntityTypesClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx } // namespace cloud diff --git a/google/cloud/dialogflow_cx/session_entity_types_client.h b/google/cloud/dialogflow_cx/session_entity_types_client.h index b81804d95192c..6010cd5a0aa0b 100644 --- a/google/cloud/dialogflow_cx/session_entity_types_client.h +++ b/google/cloud/dialogflow_cx/session_entity_types_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -414,6 +415,76 @@ class SessionEntityTypesClient { request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_cx/session_entity_types_connection.cc b/google/cloud/dialogflow_cx/session_entity_types_connection.cc index fc9664049b5b1..4e6ef0ef2f89b 100644 --- a/google/cloud/dialogflow_cx/session_entity_types_connection.cc +++ b/google/cloud/dialogflow_cx/session_entity_types_connection.cc @@ -69,6 +69,20 @@ Status SessionEntityTypesConnection::DeleteSessionEntityType( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +SessionEntityTypesConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +SessionEntityTypesConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSessionEntityTypesConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include @@ -208,6 +209,12 @@ class SessionEntityTypesConnection { virtual Status DeleteSessionEntityType( google::cloud::dialogflow::cx::v3::DeleteSessionEntityTypeRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_cx/session_entity_types_connection_idempotency_policy.cc b/google/cloud/dialogflow_cx/session_entity_types_connection_idempotency_policy.cc index c72a551a603c8..304f1f0aed3fe 100644 --- a/google/cloud/dialogflow_cx/session_entity_types_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/session_entity_types_connection_idempotency_policy.cc @@ -64,6 +64,16 @@ SessionEntityTypesConnectionIdempotencyPolicy::DeleteSessionEntityType( return Idempotency::kNonIdempotent; } +Idempotency SessionEntityTypesConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SessionEntityTypesConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultSessionEntityTypesConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_cx/session_entity_types_connection_idempotency_policy.h b/google/cloud/dialogflow_cx/session_entity_types_connection_idempotency_policy.h index 815185cc06a79..e6d1547078808 100644 --- a/google/cloud/dialogflow_cx/session_entity_types_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/session_entity_types_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -55,6 +56,12 @@ class SessionEntityTypesConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteSessionEntityType( google::cloud::dialogflow::cx::v3::DeleteSessionEntityTypeRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_cx/sessions_client.cc b/google/cloud/dialogflow_cx/sessions_client.cc index b40b7b992c7e0..cfbb60fefb375 100644 --- a/google/cloud/dialogflow_cx/sessions_client.cc +++ b/google/cloud/dialogflow_cx/sessions_client.cc @@ -81,6 +81,18 @@ SessionsClient::SubmitAnswerFeedback( return connection_->SubmitAnswerFeedback(request); } +StreamRange SessionsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr SessionsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx } // namespace cloud diff --git a/google/cloud/dialogflow_cx/sessions_client.h b/google/cloud/dialogflow_cx/sessions_client.h index d9a78321cdc23..fd632df8c493c 100644 --- a/google/cloud/dialogflow_cx/sessions_client.h +++ b/google/cloud/dialogflow_cx/sessions_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -306,6 +307,76 @@ class SessionsClient { request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_cx/sessions_connection.cc b/google/cloud/dialogflow_cx/sessions_connection.cc index e8b40438cb1d7..e628579977e83 100644 --- a/google/cloud/dialogflow_cx/sessions_connection.cc +++ b/google/cloud/dialogflow_cx/sessions_connection.cc @@ -26,6 +26,7 @@ #include "google/cloud/common_options.h" #include "google/cloud/credentials.h" #include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/unified_grpc_credentials.h" #include #include @@ -84,6 +85,19 @@ SessionsConnection::SubmitAnswerFeedback( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +SessionsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr SessionsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSessionsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include @@ -206,6 +207,12 @@ class SessionsConnection { SubmitAnswerFeedback( google::cloud::dialogflow::cx::v3::SubmitAnswerFeedbackRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_cx/sessions_connection_idempotency_policy.cc b/google/cloud/dialogflow_cx/sessions_connection_idempotency_policy.cc index 18ca2413eec9f..0e6f82ad907a9 100644 --- a/google/cloud/dialogflow_cx/sessions_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/sessions_connection_idempotency_policy.cc @@ -54,6 +54,16 @@ Idempotency SessionsConnectionIdempotencyPolicy::SubmitAnswerFeedback( return Idempotency::kNonIdempotent; } +Idempotency SessionsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SessionsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultSessionsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_cx/sessions_connection_idempotency_policy.h b/google/cloud/dialogflow_cx/sessions_connection_idempotency_policy.h index 35dabe30fa2c6..30ce954ed7237 100644 --- a/google/cloud/dialogflow_cx/sessions_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/sessions_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -48,6 +49,12 @@ class SessionsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency SubmitAnswerFeedback( google::cloud::dialogflow::cx::v3::SubmitAnswerFeedbackRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_cx/test_cases_client.cc b/google/cloud/dialogflow_cx/test_cases_client.cc index a73aa06cfac48..aadf0805787f0 100644 --- a/google/cloud/dialogflow_cx/test_cases_client.cc +++ b/google/cloud/dialogflow_cx/test_cases_client.cc @@ -251,6 +251,18 @@ TestCasesClient::GetTestCaseResult( return connection_->GetTestCaseResult(request); } +StreamRange TestCasesClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr TestCasesClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx } // namespace cloud diff --git a/google/cloud/dialogflow_cx/test_cases_client.h b/google/cloud/dialogflow_cx/test_cases_client.h index 649426f324029..7c55634898f8f 100644 --- a/google/cloud/dialogflow_cx/test_cases_client.h +++ b/google/cloud/dialogflow_cx/test_cases_client.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -884,6 +885,76 @@ class TestCasesClient { request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_cx/test_cases_connection.cc b/google/cloud/dialogflow_cx/test_cases_connection.cc index 6c30ce512a920..3588a652696d8 100644 --- a/google/cloud/dialogflow_cx/test_cases_connection.cc +++ b/google/cloud/dialogflow_cx/test_cases_connection.cc @@ -176,6 +176,19 @@ TestCasesConnection::GetTestCaseResult( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +TestCasesConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr TestCasesConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeTestCasesConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include #include @@ -270,6 +271,12 @@ class TestCasesConnection { GetTestCaseResult( google::cloud::dialogflow::cx::v3::GetTestCaseResultRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_cx/test_cases_connection_idempotency_policy.cc b/google/cloud/dialogflow_cx/test_cases_connection_idempotency_policy.cc index ed38258e46b44..97b9cf7bde024 100644 --- a/google/cloud/dialogflow_cx/test_cases_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/test_cases_connection_idempotency_policy.cc @@ -94,6 +94,16 @@ Idempotency TestCasesConnectionIdempotencyPolicy::GetTestCaseResult( return Idempotency::kIdempotent; } +Idempotency TestCasesConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency TestCasesConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultTestCasesConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_cx/test_cases_connection_idempotency_policy.h b/google/cloud/dialogflow_cx/test_cases_connection_idempotency_policy.h index 597221c49791f..1d060c0aa4ddd 100644 --- a/google/cloud/dialogflow_cx/test_cases_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/test_cases_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -75,6 +76,12 @@ class TestCasesConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GetTestCaseResult( google::cloud::dialogflow::cx::v3::GetTestCaseResultRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_cx/transition_route_groups_client.cc b/google/cloud/dialogflow_cx/transition_route_groups_client.cc index 163380eb52fe6..349b80885a0cd 100644 --- a/google/cloud/dialogflow_cx/transition_route_groups_client.cc +++ b/google/cloud/dialogflow_cx/transition_route_groups_client.cc @@ -126,6 +126,20 @@ Status TransitionRouteGroupsClient::DeleteTransitionRouteGroup( return connection_->DeleteTransitionRouteGroup(request); } +StreamRange +TransitionRouteGroupsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +TransitionRouteGroupsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx } // namespace cloud diff --git a/google/cloud/dialogflow_cx/transition_route_groups_client.h b/google/cloud/dialogflow_cx/transition_route_groups_client.h index f513ac58a4166..2dfedcf982ea9 100644 --- a/google/cloud/dialogflow_cx/transition_route_groups_client.h +++ b/google/cloud/dialogflow_cx/transition_route_groups_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -448,6 +449,76 @@ class TransitionRouteGroupsClient { DeleteTransitionRouteGroupRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_cx/transition_route_groups_connection.cc b/google/cloud/dialogflow_cx/transition_route_groups_connection.cc index ab013f4095120..0d36718e13f14 100644 --- a/google/cloud/dialogflow_cx/transition_route_groups_connection.cc +++ b/google/cloud/dialogflow_cx/transition_route_groups_connection.cc @@ -72,6 +72,20 @@ Status TransitionRouteGroupsConnection::DeleteTransitionRouteGroup( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +TransitionRouteGroupsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +TransitionRouteGroupsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeTransitionRouteGroupsConnection(std::string const& location, Options options) { diff --git a/google/cloud/dialogflow_cx/transition_route_groups_connection.h b/google/cloud/dialogflow_cx/transition_route_groups_connection.h index bf86c676c35c5..6b15f13c1a750 100644 --- a/google/cloud/dialogflow_cx/transition_route_groups_connection.h +++ b/google/cloud/dialogflow_cx/transition_route_groups_connection.h @@ -28,6 +28,7 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include #include #include @@ -212,6 +213,12 @@ class TransitionRouteGroupsConnection { virtual Status DeleteTransitionRouteGroup( google::cloud::dialogflow::cx::v3:: DeleteTransitionRouteGroupRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_cx/transition_route_groups_connection_idempotency_policy.cc b/google/cloud/dialogflow_cx/transition_route_groups_connection_idempotency_policy.cc index 936cbec62b7fe..8c2eba4390cb1 100644 --- a/google/cloud/dialogflow_cx/transition_route_groups_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/transition_route_groups_connection_idempotency_policy.cc @@ -69,6 +69,16 @@ TransitionRouteGroupsConnectionIdempotencyPolicy::DeleteTransitionRouteGroup( return Idempotency::kNonIdempotent; } +Idempotency TransitionRouteGroupsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency TransitionRouteGroupsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultTransitionRouteGroupsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_cx/transition_route_groups_connection_idempotency_policy.h b/google/cloud/dialogflow_cx/transition_route_groups_connection_idempotency_policy.h index 5ff209f9754c4..0ee2e2fb05d28 100644 --- a/google/cloud/dialogflow_cx/transition_route_groups_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/transition_route_groups_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -56,6 +57,12 @@ class TransitionRouteGroupsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteTransitionRouteGroup( google::cloud::dialogflow::cx::v3:: DeleteTransitionRouteGroupRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_cx/versions_client.cc b/google/cloud/dialogflow_cx/versions_client.cc index 6b33776d84f2d..59b2c838f2a1a 100644 --- a/google/cloud/dialogflow_cx/versions_client.cc +++ b/google/cloud/dialogflow_cx/versions_client.cc @@ -193,6 +193,18 @@ VersionsClient::CompareVersions( return connection_->CompareVersions(request); } +StreamRange VersionsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr VersionsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx } // namespace cloud diff --git a/google/cloud/dialogflow_cx/versions_client.h b/google/cloud/dialogflow_cx/versions_client.h index b4f01e424ad97..45b45bbcebbb0 100644 --- a/google/cloud/dialogflow_cx/versions_client.h +++ b/google/cloud/dialogflow_cx/versions_client.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -669,6 +670,76 @@ class VersionsClient { google::cloud::dialogflow::cx::v3::CompareVersionsRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_cx/versions_connection.cc b/google/cloud/dialogflow_cx/versions_connection.cc index 5aca50c984525..927ed5eac048b 100644 --- a/google/cloud/dialogflow_cx/versions_connection.cc +++ b/google/cloud/dialogflow_cx/versions_connection.cc @@ -109,6 +109,19 @@ VersionsConnection::CompareVersions( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +VersionsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr VersionsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeVersionsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include #include @@ -221,6 +222,12 @@ class VersionsConnection { virtual StatusOr CompareVersions( google::cloud::dialogflow::cx::v3::CompareVersionsRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_cx/versions_connection_idempotency_policy.cc b/google/cloud/dialogflow_cx/versions_connection_idempotency_policy.cc index fc95e93dcdeca..eeadcb7ba867a 100644 --- a/google/cloud/dialogflow_cx/versions_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/versions_connection_idempotency_policy.cc @@ -69,6 +69,16 @@ Idempotency VersionsConnectionIdempotencyPolicy::CompareVersions( return Idempotency::kNonIdempotent; } +Idempotency VersionsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency VersionsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultVersionsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_cx/versions_connection_idempotency_policy.h b/google/cloud/dialogflow_cx/versions_connection_idempotency_policy.h index 5bdcc8ff0509d..55fca4d364d17 100644 --- a/google/cloud/dialogflow_cx/versions_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/versions_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -56,6 +57,12 @@ class VersionsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency CompareVersions( google::cloud::dialogflow::cx::v3::CompareVersionsRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_cx/webhooks_client.cc b/google/cloud/dialogflow_cx/webhooks_client.cc index da3c5a11d7716..4fd23cfa70e69 100644 --- a/google/cloud/dialogflow_cx/webhooks_client.cc +++ b/google/cloud/dialogflow_cx/webhooks_client.cc @@ -115,6 +115,18 @@ Status WebhooksClient::DeleteWebhook( return connection_->DeleteWebhook(request); } +StreamRange WebhooksClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr WebhooksClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_cx } // namespace cloud diff --git a/google/cloud/dialogflow_cx/webhooks_client.h b/google/cloud/dialogflow_cx/webhooks_client.h index 56037421281d1..df6c95382311d 100644 --- a/google/cloud/dialogflow_cx/webhooks_client.h +++ b/google/cloud/dialogflow_cx/webhooks_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -387,6 +388,76 @@ class WebhooksClient { google::cloud::dialogflow::cx::v3::DeleteWebhookRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_cx/webhooks_connection.cc b/google/cloud/dialogflow_cx/webhooks_connection.cc index 0ae7e3ac02372..679f2b8595e8b 100644 --- a/google/cloud/dialogflow_cx/webhooks_connection.cc +++ b/google/cloud/dialogflow_cx/webhooks_connection.cc @@ -69,6 +69,19 @@ Status WebhooksConnection::DeleteWebhook( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +WebhooksConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr WebhooksConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeWebhooksConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include @@ -194,6 +195,12 @@ class WebhooksConnection { virtual Status DeleteWebhook( google::cloud::dialogflow::cx::v3::DeleteWebhookRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_cx/webhooks_connection_idempotency_policy.cc b/google/cloud/dialogflow_cx/webhooks_connection_idempotency_policy.cc index 2bb2b8ba5c084..716c230025e55 100644 --- a/google/cloud/dialogflow_cx/webhooks_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_cx/webhooks_connection_idempotency_policy.cc @@ -59,6 +59,16 @@ Idempotency WebhooksConnectionIdempotencyPolicy::DeleteWebhook( return Idempotency::kNonIdempotent; } +Idempotency WebhooksConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency WebhooksConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultWebhooksConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_cx/webhooks_connection_idempotency_policy.h b/google/cloud/dialogflow_cx/webhooks_connection_idempotency_policy.h index 673f0e13105e2..9570ab6437f7c 100644 --- a/google/cloud/dialogflow_cx/webhooks_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_cx/webhooks_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -50,6 +51,12 @@ class WebhooksConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteWebhook( google::cloud::dialogflow::cx::v3::DeleteWebhookRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_es/BUILD.bazel b/google/cloud/dialogflow_es/BUILD.bazel index 891db088da2ec..05b7e65e30c84 100644 --- a/google/cloud/dialogflow_es/BUILD.bazel +++ b/google/cloud/dialogflow_es/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = [""] googleapis_deps = [ "@com_google_googleapis//google/cloud/dialogflow/v2:dialogflow_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/dialogflow_es/agents_client.cc b/google/cloud/dialogflow_es/agents_client.cc index 89bda34d55de6..6e5296df0c853 100644 --- a/google/cloud/dialogflow_es/agents_client.cc +++ b/google/cloud/dialogflow_es/agents_client.cc @@ -215,6 +215,18 @@ AgentsClient::GetValidationResult( return connection_->GetValidationResult(request); } +StreamRange AgentsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr AgentsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es } // namespace cloud diff --git a/google/cloud/dialogflow_es/agents_client.h b/google/cloud/dialogflow_es/agents_client.h index 21cbcae0aa004..5ca6cd3225554 100644 --- a/google/cloud/dialogflow_es/agents_client.h +++ b/google/cloud/dialogflow_es/agents_client.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -834,6 +835,76 @@ class AgentsClient { google::cloud::dialogflow::v2::GetValidationResultRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_es/agents_connection.cc b/google/cloud/dialogflow_es/agents_connection.cc index 3508aed054dbc..720923828bd88 100644 --- a/google/cloud/dialogflow_es/agents_connection.cc +++ b/google/cloud/dialogflow_es/agents_connection.cc @@ -142,6 +142,18 @@ AgentsConnection::GetValidationResult( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange AgentsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr AgentsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAgentsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include #include @@ -239,6 +240,12 @@ class AgentsConnection { virtual StatusOr GetValidationResult( google::cloud::dialogflow::v2::GetValidationResultRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_es/agents_connection_idempotency_policy.cc b/google/cloud/dialogflow_es/agents_connection_idempotency_policy.cc index 0884d7fb76d26..2619fb5dfabce 100644 --- a/google/cloud/dialogflow_es/agents_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/agents_connection_idempotency_policy.cc @@ -79,6 +79,16 @@ Idempotency AgentsConnectionIdempotencyPolicy::GetValidationResult( return Idempotency::kIdempotent; } +Idempotency AgentsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AgentsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultAgentsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_es/agents_connection_idempotency_policy.h b/google/cloud/dialogflow_es/agents_connection_idempotency_policy.h index 71fa77decd0ae..c6233529f1971 100644 --- a/google/cloud/dialogflow_es/agents_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/agents_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -62,6 +63,12 @@ class AgentsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GetValidationResult( google::cloud::dialogflow::v2::GetValidationResultRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_es/answer_records_client.cc b/google/cloud/dialogflow_es/answer_records_client.cc index c0eda046475df..da9397c97a729 100644 --- a/google/cloud/dialogflow_es/answer_records_client.cc +++ b/google/cloud/dialogflow_es/answer_records_client.cc @@ -68,6 +68,19 @@ AnswerRecordsClient::UpdateAnswerRecord( return connection_->UpdateAnswerRecord(request); } +StreamRange +AnswerRecordsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr AnswerRecordsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es } // namespace cloud diff --git a/google/cloud/dialogflow_es/answer_records_client.h b/google/cloud/dialogflow_es/answer_records_client.h index e9074773a37d1..1084166ec5520 100644 --- a/google/cloud/dialogflow_es/answer_records_client.h +++ b/google/cloud/dialogflow_es/answer_records_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -224,6 +225,76 @@ class AnswerRecordsClient { google::cloud::dialogflow::v2::UpdateAnswerRecordRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_es/answer_records_connection.cc b/google/cloud/dialogflow_es/answer_records_connection.cc index 524c5fa8ffcac..55f7881bf40a2 100644 --- a/google/cloud/dialogflow_es/answer_records_connection.cc +++ b/google/cloud/dialogflow_es/answer_records_connection.cc @@ -52,6 +52,20 @@ AnswerRecordsConnection::UpdateAnswerRecord( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +AnswerRecordsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +AnswerRecordsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAnswerRecordsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include @@ -190,6 +191,12 @@ class AnswerRecordsConnection { virtual StatusOr UpdateAnswerRecord( google::cloud::dialogflow::v2::UpdateAnswerRecordRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_es/answer_records_connection_idempotency_policy.cc b/google/cloud/dialogflow_es/answer_records_connection_idempotency_policy.cc index dfbfa3acdb603..997775078f3eb 100644 --- a/google/cloud/dialogflow_es/answer_records_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/answer_records_connection_idempotency_policy.cc @@ -44,6 +44,16 @@ Idempotency AnswerRecordsConnectionIdempotencyPolicy::UpdateAnswerRecord( return Idempotency::kNonIdempotent; } +Idempotency AnswerRecordsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AnswerRecordsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultAnswerRecordsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_es/answer_records_connection_idempotency_policy.h b/google/cloud/dialogflow_es/answer_records_connection_idempotency_policy.h index 08d85e2980dce..35a53964f6f9f 100644 --- a/google/cloud/dialogflow_es/answer_records_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/answer_records_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -42,6 +43,12 @@ class AnswerRecordsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency UpdateAnswerRecord( google::cloud::dialogflow::v2::UpdateAnswerRecordRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_es/contexts_client.cc b/google/cloud/dialogflow_es/contexts_client.cc index 537b26a83b808..3087089edc5cc 100644 --- a/google/cloud/dialogflow_es/contexts_client.cc +++ b/google/cloud/dialogflow_es/contexts_client.cc @@ -125,6 +125,18 @@ Status ContextsClient::DeleteAllContexts( return connection_->DeleteAllContexts(request); } +StreamRange ContextsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr ContextsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es } // namespace cloud diff --git a/google/cloud/dialogflow_es/contexts_client.h b/google/cloud/dialogflow_es/contexts_client.h index 94cb5d6055cc3..10c2af74d6852 100644 --- a/google/cloud/dialogflow_es/contexts_client.h +++ b/google/cloud/dialogflow_es/contexts_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -453,6 +454,76 @@ class ContextsClient { google::cloud::dialogflow::v2::DeleteAllContextsRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_es/contexts_connection.cc b/google/cloud/dialogflow_es/contexts_connection.cc index 4eb5435e961c3..96709fdffe4e4 100644 --- a/google/cloud/dialogflow_es/contexts_connection.cc +++ b/google/cloud/dialogflow_es/contexts_connection.cc @@ -73,6 +73,19 @@ Status ContextsConnection::DeleteAllContexts( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +ContextsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ContextsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeContextsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include @@ -197,6 +198,12 @@ class ContextsConnection { virtual Status DeleteAllContexts( google::cloud::dialogflow::v2::DeleteAllContextsRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_es/contexts_connection_idempotency_policy.cc b/google/cloud/dialogflow_es/contexts_connection_idempotency_policy.cc index 4479821c95870..15408b797f287 100644 --- a/google/cloud/dialogflow_es/contexts_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/contexts_connection_idempotency_policy.cc @@ -64,6 +64,16 @@ Idempotency ContextsConnectionIdempotencyPolicy::DeleteAllContexts( return Idempotency::kNonIdempotent; } +Idempotency ContextsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ContextsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultContextsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_es/contexts_connection_idempotency_policy.h b/google/cloud/dialogflow_es/contexts_connection_idempotency_policy.h index 24deacbfaf519..bac73c3122415 100644 --- a/google/cloud/dialogflow_es/contexts_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/contexts_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -53,6 +54,12 @@ class ContextsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteAllContexts( google::cloud::dialogflow::v2::DeleteAllContextsRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_es/conversation_datasets_client.cc b/google/cloud/dialogflow_es/conversation_datasets_client.cc index 27ef7268dd853..02eb4e8eec28a 100644 --- a/google/cloud/dialogflow_es/conversation_datasets_client.cc +++ b/google/cloud/dialogflow_es/conversation_datasets_client.cc @@ -192,6 +192,20 @@ ConversationDatasetsClient::ImportConversationData( return connection_->ImportConversationData(operation); } +StreamRange +ConversationDatasetsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +ConversationDatasetsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es } // namespace cloud diff --git a/google/cloud/dialogflow_es/conversation_datasets_client.h b/google/cloud/dialogflow_es/conversation_datasets_client.h index 4e8a2844041c7..cfb5e38d3bd33 100644 --- a/google/cloud/dialogflow_es/conversation_datasets_client.h +++ b/google/cloud/dialogflow_es/conversation_datasets_client.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -596,6 +597,76 @@ class ConversationDatasetsClient { ImportConversationData(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_es/conversation_datasets_connection.cc b/google/cloud/dialogflow_es/conversation_datasets_connection.cc index 276d94dcae527..b9511d8eccc55 100644 --- a/google/cloud/dialogflow_es/conversation_datasets_connection.cc +++ b/google/cloud/dialogflow_es/conversation_datasets_connection.cc @@ -130,6 +130,20 @@ ConversationDatasetsConnection::ImportConversationData( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +ConversationDatasetsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +ConversationDatasetsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeConversationDatasetsConnection(std::string const& location, Options options) { diff --git a/google/cloud/dialogflow_es/conversation_datasets_connection.h b/google/cloud/dialogflow_es/conversation_datasets_connection.h index 474eb080c077c..29b2b727e25d7 100644 --- a/google/cloud/dialogflow_es/conversation_datasets_connection.h +++ b/google/cloud/dialogflow_es/conversation_datasets_connection.h @@ -31,6 +31,7 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -242,6 +243,12 @@ class ConversationDatasetsConnection { virtual future> ImportConversationData(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_es/conversation_datasets_connection_idempotency_policy.cc b/google/cloud/dialogflow_es/conversation_datasets_connection_idempotency_policy.cc index de15efcab62a7..b2c6f2698d8db 100644 --- a/google/cloud/dialogflow_es/conversation_datasets_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/conversation_datasets_connection_idempotency_policy.cc @@ -65,6 +65,16 @@ ConversationDatasetsConnectionIdempotencyPolicy::ImportConversationData( return Idempotency::kNonIdempotent; } +Idempotency ConversationDatasetsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ConversationDatasetsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultConversationDatasetsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_es/conversation_datasets_connection_idempotency_policy.h b/google/cloud/dialogflow_es/conversation_datasets_connection_idempotency_policy.h index 09b9172cffe9b..bec8854371edd 100644 --- a/google/cloud/dialogflow_es/conversation_datasets_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/conversation_datasets_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -55,6 +56,12 @@ class ConversationDatasetsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ImportConversationData( google::cloud::dialogflow::v2::ImportConversationDataRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_es/conversation_models_client.cc b/google/cloud/dialogflow_es/conversation_models_client.cc index f2c6fd592e493..669a6eb94555f 100644 --- a/google/cloud/dialogflow_es/conversation_models_client.cc +++ b/google/cloud/dialogflow_es/conversation_models_client.cc @@ -313,6 +313,20 @@ ConversationModelsClient::CreateConversationModelEvaluation( return connection_->CreateConversationModelEvaluation(operation); } +StreamRange +ConversationModelsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +ConversationModelsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es } // namespace cloud diff --git a/google/cloud/dialogflow_es/conversation_models_client.h b/google/cloud/dialogflow_es/conversation_models_client.h index 0dce2e4d73f7d..dacadee09b8ca 100644 --- a/google/cloud/dialogflow_es/conversation_models_client.h +++ b/google/cloud/dialogflow_es/conversation_models_client.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -936,6 +937,76 @@ class ConversationModelsClient { CreateConversationModelEvaluation( google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_es/conversation_models_connection.cc b/google/cloud/dialogflow_es/conversation_models_connection.cc index 648de162ccb9d..2206eae317a82 100644 --- a/google/cloud/dialogflow_es/conversation_models_connection.cc +++ b/google/cloud/dialogflow_es/conversation_models_connection.cc @@ -196,6 +196,20 @@ ConversationModelsConnection::CreateConversationModelEvaluation( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +ConversationModelsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +ConversationModelsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeConversationModelsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include #include @@ -283,6 +284,12 @@ class ConversationModelsConnection { StatusOr> CreateConversationModelEvaluation( google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_es/conversation_models_connection_idempotency_policy.cc b/google/cloud/dialogflow_es/conversation_models_connection_idempotency_policy.cc index 3154c739d37d8..952073ad63d3e 100644 --- a/google/cloud/dialogflow_es/conversation_models_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/conversation_models_connection_idempotency_policy.cc @@ -90,6 +90,16 @@ Idempotency ConversationModelsConnectionIdempotencyPolicy:: return Idempotency::kNonIdempotent; } +Idempotency ConversationModelsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ConversationModelsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultConversationModelsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_es/conversation_models_connection_idempotency_policy.h b/google/cloud/dialogflow_es/conversation_models_connection_idempotency_policy.h index b71bfabc6a0be..20d7aa10a1e08 100644 --- a/google/cloud/dialogflow_es/conversation_models_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/conversation_models_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -71,6 +72,12 @@ class ConversationModelsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency CreateConversationModelEvaluation( google::cloud::dialogflow::v2:: CreateConversationModelEvaluationRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_es/conversation_profiles_client.cc b/google/cloud/dialogflow_es/conversation_profiles_client.cc index 9648d2b39ee92..38b1bc740879c 100644 --- a/google/cloud/dialogflow_es/conversation_profiles_client.cc +++ b/google/cloud/dialogflow_es/conversation_profiles_client.cc @@ -273,6 +273,20 @@ ConversationProfilesClient::ClearSuggestionFeatureConfig( return connection_->ClearSuggestionFeatureConfig(operation); } +StreamRange +ConversationProfilesClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +ConversationProfilesClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es } // namespace cloud diff --git a/google/cloud/dialogflow_es/conversation_profiles_client.h b/google/cloud/dialogflow_es/conversation_profiles_client.h index 553479e9e07db..9d6bc4bc68b4b 100644 --- a/google/cloud/dialogflow_es/conversation_profiles_client.h +++ b/google/cloud/dialogflow_es/conversation_profiles_client.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -870,6 +871,76 @@ class ConversationProfilesClient { ClearSuggestionFeatureConfig(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_es/conversation_profiles_connection.cc b/google/cloud/dialogflow_es/conversation_profiles_connection.cc index f78d7c06879f5..6a494ae0616de 100644 --- a/google/cloud/dialogflow_es/conversation_profiles_connection.cc +++ b/google/cloud/dialogflow_es/conversation_profiles_connection.cc @@ -117,6 +117,20 @@ ConversationProfilesConnection::ClearSuggestionFeatureConfig( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +ConversationProfilesConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +ConversationProfilesConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeConversationProfilesConnection(std::string const& location, Options options) { diff --git a/google/cloud/dialogflow_es/conversation_profiles_connection.h b/google/cloud/dialogflow_es/conversation_profiles_connection.h index 4a72362b15482..8cb02c4bad6d3 100644 --- a/google/cloud/dialogflow_es/conversation_profiles_connection.h +++ b/google/cloud/dialogflow_es/conversation_profiles_connection.h @@ -31,6 +31,7 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -239,6 +240,12 @@ class ConversationProfilesConnection { virtual future> ClearSuggestionFeatureConfig(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_es/conversation_profiles_connection_idempotency_policy.cc b/google/cloud/dialogflow_es/conversation_profiles_connection_idempotency_policy.cc index 4b77e5f132334..4d203cadabb8d 100644 --- a/google/cloud/dialogflow_es/conversation_profiles_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/conversation_profiles_connection_idempotency_policy.cc @@ -77,6 +77,16 @@ ConversationProfilesConnectionIdempotencyPolicy::ClearSuggestionFeatureConfig( return Idempotency::kNonIdempotent; } +Idempotency ConversationProfilesConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ConversationProfilesConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultConversationProfilesConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_es/conversation_profiles_connection_idempotency_policy.h b/google/cloud/dialogflow_es/conversation_profiles_connection_idempotency_policy.h index 5464ab6095ced..1608f3e3807b9 100644 --- a/google/cloud/dialogflow_es/conversation_profiles_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/conversation_profiles_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -63,6 +64,12 @@ class ConversationProfilesConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ClearSuggestionFeatureConfig( google::cloud::dialogflow::v2::ClearSuggestionFeatureConfigRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_es/conversations_client.cc b/google/cloud/dialogflow_es/conversations_client.cc index 3abff0295217c..0be8f76c22e45 100644 --- a/google/cloud/dialogflow_es/conversations_client.cc +++ b/google/cloud/dialogflow_es/conversations_client.cc @@ -161,6 +161,19 @@ ConversationsClient::SearchKnowledge( return connection_->SearchKnowledge(request); } +StreamRange +ConversationsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr ConversationsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es } // namespace cloud diff --git a/google/cloud/dialogflow_es/conversations_client.h b/google/cloud/dialogflow_es/conversations_client.h index 184e3a677eb45..ba9eef6407404 100644 --- a/google/cloud/dialogflow_es/conversations_client.h +++ b/google/cloud/dialogflow_es/conversations_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -633,6 +634,76 @@ class ConversationsClient { google::cloud::dialogflow::v2::SearchKnowledgeRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_es/conversations_connection.cc b/google/cloud/dialogflow_es/conversations_connection.cc index 02e2b1c5efc94..76c33bfbca965 100644 --- a/google/cloud/dialogflow_es/conversations_connection.cc +++ b/google/cloud/dialogflow_es/conversations_connection.cc @@ -96,6 +96,20 @@ ConversationsConnection::SearchKnowledge( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +ConversationsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +ConversationsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeConversationsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include @@ -223,6 +224,12 @@ class ConversationsConnection { virtual StatusOr SearchKnowledge( google::cloud::dialogflow::v2::SearchKnowledgeRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_es/conversations_connection_idempotency_policy.cc b/google/cloud/dialogflow_es/conversations_connection_idempotency_policy.cc index 3285aa02c059a..f292537f7383c 100644 --- a/google/cloud/dialogflow_es/conversations_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/conversations_connection_idempotency_policy.cc @@ -81,6 +81,16 @@ Idempotency ConversationsConnectionIdempotencyPolicy::SearchKnowledge( return Idempotency::kNonIdempotent; } +Idempotency ConversationsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ConversationsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultConversationsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_es/conversations_connection_idempotency_policy.h b/google/cloud/dialogflow_es/conversations_connection_idempotency_policy.h index db91318812fed..1141d611a9328 100644 --- a/google/cloud/dialogflow_es/conversations_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/conversations_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -67,6 +68,12 @@ class ConversationsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency SearchKnowledge( google::cloud::dialogflow::v2::SearchKnowledgeRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_es/documents_client.cc b/google/cloud/dialogflow_es/documents_client.cc index bf1b041c38504..bfa4eb6104579 100644 --- a/google/cloud/dialogflow_es/documents_client.cc +++ b/google/cloud/dialogflow_es/documents_client.cc @@ -278,6 +278,18 @@ DocumentsClient::ExportDocument(google::longrunning::Operation const& operation, return connection_->ExportDocument(operation); } +StreamRange DocumentsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr DocumentsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es } // namespace cloud diff --git a/google/cloud/dialogflow_es/documents_client.h b/google/cloud/dialogflow_es/documents_client.h index 2e2d1178e4b9c..07937b26cf3c1 100644 --- a/google/cloud/dialogflow_es/documents_client.h +++ b/google/cloud/dialogflow_es/documents_client.h @@ -932,6 +932,76 @@ class DocumentsClient { future> ExportDocument( google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_es/documents_connection.cc b/google/cloud/dialogflow_es/documents_connection.cc index a17bb3295a4c8..f1894ce14b2d2 100644 --- a/google/cloud/dialogflow_es/documents_connection.cc +++ b/google/cloud/dialogflow_es/documents_connection.cc @@ -178,6 +178,19 @@ DocumentsConnection::ExportDocument(google::longrunning::Operation const&) { Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +DocumentsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr DocumentsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDocumentsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include #include @@ -261,6 +262,12 @@ class DocumentsConnection { virtual future> ExportDocument(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_es/documents_connection_idempotency_policy.cc b/google/cloud/dialogflow_es/documents_connection_idempotency_policy.cc index c7d2cbf442120..e850704d530a2 100644 --- a/google/cloud/dialogflow_es/documents_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/documents_connection_idempotency_policy.cc @@ -74,6 +74,16 @@ Idempotency DocumentsConnectionIdempotencyPolicy::ExportDocument( return Idempotency::kNonIdempotent; } +Idempotency DocumentsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DocumentsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultDocumentsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_es/documents_connection_idempotency_policy.h b/google/cloud/dialogflow_es/documents_connection_idempotency_policy.h index 49880c0cdc90b..288498aeb3d7e 100644 --- a/google/cloud/dialogflow_es/documents_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/documents_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -59,6 +60,12 @@ class DocumentsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ExportDocument( google::cloud::dialogflow::v2::ExportDocumentRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_es/entity_types_client.cc b/google/cloud/dialogflow_es/entity_types_client.cc index 7e86e0ad97520..bcc031f533e89 100644 --- a/google/cloud/dialogflow_es/entity_types_client.cc +++ b/google/cloud/dialogflow_es/entity_types_client.cc @@ -457,6 +457,18 @@ EntityTypesClient::BatchDeleteEntities( return connection_->BatchDeleteEntities(operation); } +StreamRange EntityTypesClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr EntityTypesClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es } // namespace cloud diff --git a/google/cloud/dialogflow_es/entity_types_client.h b/google/cloud/dialogflow_es/entity_types_client.h index 4f7522f72cfbc..56f09836525a9 100644 --- a/google/cloud/dialogflow_es/entity_types_client.h +++ b/google/cloud/dialogflow_es/entity_types_client.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -1449,6 +1450,76 @@ class EntityTypesClient { future> BatchDeleteEntities( google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_es/entity_types_connection.cc b/google/cloud/dialogflow_es/entity_types_connection.cc index 5a87f0cd03f37..f5f7e12f48bde 100644 --- a/google/cloud/dialogflow_es/entity_types_connection.cc +++ b/google/cloud/dialogflow_es/entity_types_connection.cc @@ -181,6 +181,19 @@ EntityTypesConnection::BatchDeleteEntities( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +EntityTypesConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr EntityTypesConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeEntityTypesConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include #include @@ -259,6 +260,12 @@ class EntityTypesConnection { virtual future> BatchDeleteEntities( google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_es/entity_types_connection_idempotency_policy.cc b/google/cloud/dialogflow_es/entity_types_connection_idempotency_policy.cc index 9a925889849c9..3b9b8b3d8df10 100644 --- a/google/cloud/dialogflow_es/entity_types_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/entity_types_connection_idempotency_policy.cc @@ -84,6 +84,16 @@ Idempotency EntityTypesConnectionIdempotencyPolicy::BatchDeleteEntities( return Idempotency::kNonIdempotent; } +Idempotency EntityTypesConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency EntityTypesConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultEntityTypesConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_es/entity_types_connection_idempotency_policy.h b/google/cloud/dialogflow_es/entity_types_connection_idempotency_policy.h index 5fbca6e938387..f1bbd99e06f84 100644 --- a/google/cloud/dialogflow_es/entity_types_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/entity_types_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -67,6 +68,12 @@ class EntityTypesConnectionIdempotencyPolicy { virtual google::cloud::Idempotency BatchDeleteEntities( google::cloud::dialogflow::v2::BatchDeleteEntitiesRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_es/environments_client.cc b/google/cloud/dialogflow_es/environments_client.cc index 8f0eac221c847..d3649f83087ef 100644 --- a/google/cloud/dialogflow_es/environments_client.cc +++ b/google/cloud/dialogflow_es/environments_client.cc @@ -87,6 +87,19 @@ EnvironmentsClient::GetEnvironmentHistory( return connection_->GetEnvironmentHistory(std::move(request)); } +StreamRange +EnvironmentsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr EnvironmentsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es } // namespace cloud diff --git a/google/cloud/dialogflow_es/environments_client.h b/google/cloud/dialogflow_es/environments_client.h index 8b4bc5bd6af26..9a086f8116be9 100644 --- a/google/cloud/dialogflow_es/environments_client.h +++ b/google/cloud/dialogflow_es/environments_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -339,6 +340,76 @@ class EnvironmentsClient { google::cloud::dialogflow::v2::GetEnvironmentHistoryRequest request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_es/environments_connection.cc b/google/cloud/dialogflow_es/environments_connection.cc index c755ba16551a3..806b529826f5c 100644 --- a/google/cloud/dialogflow_es/environments_connection.cc +++ b/google/cloud/dialogflow_es/environments_connection.cc @@ -77,6 +77,19 @@ EnvironmentsConnection::GetEnvironmentHistory( StreamRange>(); } +StreamRange +EnvironmentsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr EnvironmentsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeEnvironmentsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include @@ -204,6 +205,12 @@ class EnvironmentsConnection { virtual StreamRange GetEnvironmentHistory( google::cloud::dialogflow::v2::GetEnvironmentHistoryRequest request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_es/environments_connection_idempotency_policy.cc b/google/cloud/dialogflow_es/environments_connection_idempotency_policy.cc index 287b397008859..15c350a280289 100644 --- a/google/cloud/dialogflow_es/environments_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/environments_connection_idempotency_policy.cc @@ -64,6 +64,16 @@ Idempotency EnvironmentsConnectionIdempotencyPolicy::GetEnvironmentHistory( return Idempotency::kIdempotent; } +Idempotency EnvironmentsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency EnvironmentsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultEnvironmentsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_es/environments_connection_idempotency_policy.h b/google/cloud/dialogflow_es/environments_connection_idempotency_policy.h index 96362cdb36a68..43b3234decb77 100644 --- a/google/cloud/dialogflow_es/environments_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/environments_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -54,6 +55,12 @@ class EnvironmentsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GetEnvironmentHistory( google::cloud::dialogflow::v2::GetEnvironmentHistoryRequest request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_es/fulfillments_client.cc b/google/cloud/dialogflow_es/fulfillments_client.cc index 24f39831b9d18..d75539bacf16c 100644 --- a/google/cloud/dialogflow_es/fulfillments_client.cc +++ b/google/cloud/dialogflow_es/fulfillments_client.cc @@ -67,6 +67,19 @@ FulfillmentsClient::UpdateFulfillment( return connection_->UpdateFulfillment(request); } +StreamRange +FulfillmentsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr FulfillmentsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es } // namespace cloud diff --git a/google/cloud/dialogflow_es/fulfillments_client.h b/google/cloud/dialogflow_es/fulfillments_client.h index d96a1f64a3097..be1c46cdbcd48 100644 --- a/google/cloud/dialogflow_es/fulfillments_client.h +++ b/google/cloud/dialogflow_es/fulfillments_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -204,6 +205,76 @@ class FulfillmentsClient { google::cloud::dialogflow::v2::UpdateFulfillmentRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_es/fulfillments_connection.cc b/google/cloud/dialogflow_es/fulfillments_connection.cc index 4356232f76a8a..54b23254cf664 100644 --- a/google/cloud/dialogflow_es/fulfillments_connection.cc +++ b/google/cloud/dialogflow_es/fulfillments_connection.cc @@ -26,6 +26,7 @@ #include "google/cloud/common_options.h" #include "google/cloud/credentials.h" #include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/unified_grpc_credentials.h" #include #include @@ -49,6 +50,19 @@ FulfillmentsConnection::UpdateFulfillment( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +FulfillmentsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr FulfillmentsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeFulfillmentsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include @@ -188,6 +190,12 @@ class FulfillmentsConnection { virtual StatusOr UpdateFulfillment( google::cloud::dialogflow::v2::UpdateFulfillmentRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_es/fulfillments_connection_idempotency_policy.cc b/google/cloud/dialogflow_es/fulfillments_connection_idempotency_policy.cc index 4bac228cfcb24..c7812a7f112cc 100644 --- a/google/cloud/dialogflow_es/fulfillments_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/fulfillments_connection_idempotency_policy.cc @@ -44,6 +44,16 @@ Idempotency FulfillmentsConnectionIdempotencyPolicy::UpdateFulfillment( return Idempotency::kNonIdempotent; } +Idempotency FulfillmentsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency FulfillmentsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultFulfillmentsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_es/fulfillments_connection_idempotency_policy.h b/google/cloud/dialogflow_es/fulfillments_connection_idempotency_policy.h index 4064f95e00bf5..6c4ca8b728fe0 100644 --- a/google/cloud/dialogflow_es/fulfillments_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/fulfillments_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -42,6 +43,12 @@ class FulfillmentsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency UpdateFulfillment( google::cloud::dialogflow::v2::UpdateFulfillmentRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_es/intents_client.cc b/google/cloud/dialogflow_es/intents_client.cc index 246bfa60a5fd2..98d043665d079 100644 --- a/google/cloud/dialogflow_es/intents_client.cc +++ b/google/cloud/dialogflow_es/intents_client.cc @@ -261,6 +261,18 @@ future> IntentsClient::BatchDeleteIntents( return connection_->BatchDeleteIntents(operation); } +StreamRange IntentsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr IntentsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es } // namespace cloud diff --git a/google/cloud/dialogflow_es/intents_client.h b/google/cloud/dialogflow_es/intents_client.h index 574c1dbe5418d..514f9f44ef526 100644 --- a/google/cloud/dialogflow_es/intents_client.h +++ b/google/cloud/dialogflow_es/intents_client.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -933,6 +934,76 @@ class IntentsClient { future> BatchDeleteIntents( google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_es/intents_connection.cc b/google/cloud/dialogflow_es/intents_connection.cc index 8839b9ca41579..01272573c0244 100644 --- a/google/cloud/dialogflow_es/intents_connection.cc +++ b/google/cloud/dialogflow_es/intents_connection.cc @@ -108,6 +108,18 @@ IntentsConnection::BatchDeleteIntents(google::longrunning::Operation const&) { Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange IntentsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr IntentsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeIntentsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include #include @@ -222,6 +223,12 @@ class IntentsConnection { virtual future> BatchDeleteIntents( google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_es/intents_connection_idempotency_policy.cc b/google/cloud/dialogflow_es/intents_connection_idempotency_policy.cc index 9a1322637db80..fee2fae62e9f4 100644 --- a/google/cloud/dialogflow_es/intents_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/intents_connection_idempotency_policy.cc @@ -69,6 +69,16 @@ Idempotency IntentsConnectionIdempotencyPolicy::BatchDeleteIntents( return Idempotency::kNonIdempotent; } +Idempotency IntentsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency IntentsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultIntentsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_es/intents_connection_idempotency_policy.h b/google/cloud/dialogflow_es/intents_connection_idempotency_policy.h index d2524f9ea5961..8c8b58bb082a8 100644 --- a/google/cloud/dialogflow_es/intents_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/intents_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -56,6 +57,12 @@ class IntentsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency BatchDeleteIntents( google::cloud::dialogflow::v2::BatchDeleteIntentsRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_es/internal/agents_auth_decorator.cc b/google/cloud/dialogflow_es/internal/agents_auth_decorator.cc index 0e0f7e9b51e0c..abef3afe1912a 100644 --- a/google/cloud/dialogflow_es/internal/agents_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/agents_auth_decorator.cc @@ -181,6 +181,23 @@ AgentsAuth::GetValidationResult( return child_->GetValidationResult(context, options, request); } +StatusOr +AgentsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr AgentsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> AgentsAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/agents_auth_decorator.h b/google/cloud/dialogflow_es/internal/agents_auth_decorator.h index a08915e9975ff..f65139774b7a7 100644 --- a/google/cloud/dialogflow_es/internal/agents_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/agents_auth_decorator.h @@ -107,6 +107,14 @@ class AgentsAuth : public AgentsStub { google::cloud::dialogflow::v2::GetValidationResultRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/agents_connection_impl.cc b/google/cloud/dialogflow_es/internal/agents_connection_impl.cc index 9065e568f7934..29f43a33ab2f7 100644 --- a/google/cloud/dialogflow_es/internal/agents_connection_impl.cc +++ b/google/cloud/dialogflow_es/internal/agents_connection_impl.cc @@ -498,6 +498,53 @@ AgentsConnectionImpl::GetValidationResult( *current, request, __func__); } +StreamRange +AgentsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr AgentsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/agents_connection_impl.h b/google/cloud/dialogflow_es/internal/agents_connection_impl.h index 90fb384b23322..f28e1abc21e68 100644 --- a/google/cloud/dialogflow_es/internal/agents_connection_impl.h +++ b/google/cloud/dialogflow_es/internal/agents_connection_impl.h @@ -113,6 +113,12 @@ class AgentsConnectionImpl : public dialogflow_es::AgentsConnection { google::cloud::dialogflow::v2::GetValidationResultRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_es/internal/agents_logging_decorator.cc b/google/cloud/dialogflow_es/internal/agents_logging_decorator.cc index ebc3e36aa93d3..1c7ba494b95d7 100644 --- a/google/cloud/dialogflow_es/internal/agents_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/agents_logging_decorator.cc @@ -211,6 +211,29 @@ AgentsLogging::GetValidationResult( context, options, request, __func__, tracing_options_); } +StatusOr +AgentsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AgentsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> AgentsLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/agents_logging_decorator.h b/google/cloud/dialogflow_es/internal/agents_logging_decorator.h index 5093331a6eb1a..06a153df0886c 100644 --- a/google/cloud/dialogflow_es/internal/agents_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/agents_logging_decorator.h @@ -107,6 +107,14 @@ class AgentsLogging : public AgentsStub { google::cloud::dialogflow::v2::GetValidationResultRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/agents_metadata_decorator.cc b/google/cloud/dialogflow_es/internal/agents_metadata_decorator.cc index 5d0fed260f8eb..ee23eef8eb0a5 100644 --- a/google/cloud/dialogflow_es/internal/agents_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/agents_metadata_decorator.cc @@ -167,6 +167,23 @@ AgentsMetadata::GetValidationResult( return child_->GetValidationResult(context, options, request); } +StatusOr +AgentsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr AgentsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> AgentsMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/agents_metadata_decorator.h b/google/cloud/dialogflow_es/internal/agents_metadata_decorator.h index 5a8573ebf64d2..8a0e626061daa 100644 --- a/google/cloud/dialogflow_es/internal/agents_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/agents_metadata_decorator.h @@ -107,6 +107,14 @@ class AgentsMetadata : public AgentsStub { google::cloud::dialogflow::v2::GetValidationResultRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/agents_stub.cc b/google/cloud/dialogflow_es/internal/agents_stub.cc index 3c6f5e306f2f9..71e6564a9344f 100644 --- a/google/cloud/dialogflow_es/internal/agents_stub.cc +++ b/google/cloud/dialogflow_es/internal/agents_stub.cc @@ -204,6 +204,29 @@ DefaultAgentsStub::GetValidationResult( return response; } +StatusOr +DefaultAgentsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAgentsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultAgentsStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/agents_stub.h b/google/cloud/dialogflow_es/internal/agents_stub.h index 93f4d1a2fdd98..912cab25d55cc 100644 --- a/google/cloud/dialogflow_es/internal/agents_stub.h +++ b/google/cloud/dialogflow_es/internal/agents_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -102,6 +104,15 @@ class AgentsStub { google::cloud::dialogflow::v2::GetValidationResultRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -120,9 +131,13 @@ class DefaultAgentsStub : public AgentsStub { DefaultAgentsStub( std::unique_ptr grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr GetAgent( grpc::ClientContext& context, Options const& options, @@ -192,6 +207,14 @@ class DefaultAgentsStub : public AgentsStub { google::cloud::dialogflow::v2::GetValidationResultRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -207,6 +230,8 @@ class DefaultAgentsStub : public AgentsStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/dialogflow_es/internal/agents_stub_factory.cc b/google/cloud/dialogflow_es/internal/agents_stub_factory.cc index 88eb6f9e5d3e1..7bd30c9e3edf3 100644 --- a/google/cloud/dialogflow_es/internal/agents_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/agents_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,8 +45,10 @@ std::shared_ptr CreateDefaultAgentsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::Agents::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/dialogflow_es/internal/agents_tracing_connection.cc b/google/cloud/dialogflow_es/internal/agents_tracing_connection.cc index 1392f164609ab..a2b19772dee23 100644 --- a/google/cloud/dialogflow_es/internal/agents_tracing_connection.cc +++ b/google/cloud/dialogflow_es/internal/agents_tracing_connection.cc @@ -178,6 +178,26 @@ AgentsTracingConnection::GetValidationResult( return internal::EndSpan(*span, child_->GetValidationResult(request)); } +StreamRange +AgentsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_es::AgentsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AgentsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::AgentsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeAgentsTracingConnection( diff --git a/google/cloud/dialogflow_es/internal/agents_tracing_connection.h b/google/cloud/dialogflow_es/internal/agents_tracing_connection.h index e996baeda90dc..3cb27555d1afa 100644 --- a/google/cloud/dialogflow_es/internal/agents_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/agents_tracing_connection.h @@ -101,6 +101,12 @@ class AgentsTracingConnection : public dialogflow_es::AgentsConnection { google::cloud::dialogflow::v2::GetValidationResultRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_es/internal/agents_tracing_stub.cc b/google/cloud/dialogflow_es/internal/agents_tracing_stub.cc index ffa4ab132264a..9019d47150649 100644 --- a/google/cloud/dialogflow_es/internal/agents_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/agents_tracing_stub.cc @@ -188,6 +188,29 @@ AgentsTracingStub::GetValidationResult( context, *span, child_->GetValidationResult(context, options, request)); } +StatusOr +AgentsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Agents", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr AgentsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Agents", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> AgentsTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/agents_tracing_stub.h b/google/cloud/dialogflow_es/internal/agents_tracing_stub.h index bd8dd221e69c0..76c035f5f8ea8 100644 --- a/google/cloud/dialogflow_es/internal/agents_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/agents_tracing_stub.h @@ -106,6 +106,14 @@ class AgentsTracingStub : public AgentsStub { google::cloud::dialogflow::v2::GetValidationResultRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/answer_records_auth_decorator.cc b/google/cloud/dialogflow_es/internal/answer_records_auth_decorator.cc index bdf1b53590f2c..07981972234a9 100644 --- a/google/cloud/dialogflow_es/internal/answer_records_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/answer_records_auth_decorator.cc @@ -49,6 +49,23 @@ AnswerRecordsAuth::UpdateAnswerRecord( return child_->UpdateAnswerRecord(context, options, request); } +StatusOr +AnswerRecordsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr AnswerRecordsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/answer_records_auth_decorator.h b/google/cloud/dialogflow_es/internal/answer_records_auth_decorator.h index e07b514b7c324..ab7e9ee2c6c1e 100644 --- a/google/cloud/dialogflow_es/internal/answer_records_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/answer_records_auth_decorator.h @@ -49,6 +49,14 @@ class AnswerRecordsAuth : public AnswerRecordsStub { google::cloud::dialogflow::v2::UpdateAnswerRecordRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/dialogflow_es/internal/answer_records_connection_impl.cc b/google/cloud/dialogflow_es/internal/answer_records_connection_impl.cc index c7958be26e470..01c6ff686f8e9 100644 --- a/google/cloud/dialogflow_es/internal/answer_records_connection_impl.cc +++ b/google/cloud/dialogflow_es/internal/answer_records_connection_impl.cc @@ -110,6 +110,54 @@ AnswerRecordsConnectionImpl::UpdateAnswerRecord( *current, request, __func__); } +StreamRange +AnswerRecordsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AnswerRecordsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/answer_records_connection_impl.h b/google/cloud/dialogflow_es/internal/answer_records_connection_impl.h index f131ed67490d1..cc7047da38d28 100644 --- a/google/cloud/dialogflow_es/internal/answer_records_connection_impl.h +++ b/google/cloud/dialogflow_es/internal/answer_records_connection_impl.h @@ -56,6 +56,12 @@ class AnswerRecordsConnectionImpl google::cloud::dialogflow::v2::UpdateAnswerRecordRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_es/internal/answer_records_logging_decorator.cc b/google/cloud/dialogflow_es/internal/answer_records_logging_decorator.cc index 1cddc87b39b86..6513f59e69da5 100644 --- a/google/cloud/dialogflow_es/internal/answer_records_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/answer_records_logging_decorator.cc @@ -61,6 +61,29 @@ AnswerRecordsLogging::UpdateAnswerRecord( context, options, request, __func__, tracing_options_); } +StatusOr +AnswerRecordsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AnswerRecordsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/answer_records_logging_decorator.h b/google/cloud/dialogflow_es/internal/answer_records_logging_decorator.h index 7695ccbe44795..af7d964316b4b 100644 --- a/google/cloud/dialogflow_es/internal/answer_records_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/answer_records_logging_decorator.h @@ -49,6 +49,14 @@ class AnswerRecordsLogging : public AnswerRecordsStub { google::cloud::dialogflow::v2::UpdateAnswerRecordRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/dialogflow_es/internal/answer_records_metadata_decorator.cc b/google/cloud/dialogflow_es/internal/answer_records_metadata_decorator.cc index e6ac11ecbf49f..3c472ebc46945 100644 --- a/google/cloud/dialogflow_es/internal/answer_records_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/answer_records_metadata_decorator.cc @@ -64,6 +64,23 @@ AnswerRecordsMetadata::UpdateAnswerRecord( return child_->UpdateAnswerRecord(context, options, request); } +StatusOr +AnswerRecordsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr AnswerRecordsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void AnswerRecordsMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/dialogflow_es/internal/answer_records_metadata_decorator.h b/google/cloud/dialogflow_es/internal/answer_records_metadata_decorator.h index 0a92f4aa18b9f..93860a370eaf1 100644 --- a/google/cloud/dialogflow_es/internal/answer_records_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/answer_records_metadata_decorator.h @@ -49,6 +49,14 @@ class AnswerRecordsMetadata : public AnswerRecordsStub { google::cloud::dialogflow::v2::UpdateAnswerRecordRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/dialogflow_es/internal/answer_records_stub.cc b/google/cloud/dialogflow_es/internal/answer_records_stub.cc index a4d05485cbaf1..e6d79539db0e5 100644 --- a/google/cloud/dialogflow_es/internal/answer_records_stub.cc +++ b/google/cloud/dialogflow_es/internal/answer_records_stub.cc @@ -54,6 +54,30 @@ DefaultAnswerRecordsStub::UpdateAnswerRecord( return response; } +StatusOr +DefaultAnswerRecordsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAnswerRecordsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/answer_records_stub.h b/google/cloud/dialogflow_es/internal/answer_records_stub.h index 1069e6bf4ed25..23c04d513c4a9 100644 --- a/google/cloud/dialogflow_es/internal/answer_records_stub.h +++ b/google/cloud/dialogflow_es/internal/answer_records_stub.h @@ -23,6 +23,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -46,6 +48,15 @@ class AnswerRecordsStub { grpc::ClientContext& context, Options const& options, google::cloud::dialogflow::v2::UpdateAnswerRecordRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultAnswerRecordsStub : public AnswerRecordsStub { @@ -53,8 +64,11 @@ class DefaultAnswerRecordsStub : public AnswerRecordsStub { explicit DefaultAnswerRecordsStub( std::unique_ptr< google::cloud::dialogflow::v2::AnswerRecords::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListAnswerRecords( @@ -67,9 +81,19 @@ class DefaultAnswerRecordsStub : public AnswerRecordsStub { google::cloud::dialogflow::v2::UpdateAnswerRecordRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/internal/answer_records_stub_factory.cc b/google/cloud/dialogflow_es/internal/answer_records_stub_factory.cc index eccc28641dcfd..2ddbb46aa5321 100644 --- a/google/cloud/dialogflow_es/internal/answer_records_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/answer_records_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,8 +45,11 @@ std::shared_ptr CreateDefaultAnswerRecordsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::AnswerRecords::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + std::make_shared( + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = diff --git a/google/cloud/dialogflow_es/internal/answer_records_tracing_connection.cc b/google/cloud/dialogflow_es/internal/answer_records_tracing_connection.cc index e8a2b1103e74d..3678003914fd4 100644 --- a/google/cloud/dialogflow_es/internal/answer_records_tracing_connection.cc +++ b/google/cloud/dialogflow_es/internal/answer_records_tracing_connection.cc @@ -54,6 +54,26 @@ AnswerRecordsTracingConnection::UpdateAnswerRecord( return internal::EndSpan(*span, child_->UpdateAnswerRecord(request)); } +StreamRange +AnswerRecordsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_es::AnswerRecordsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AnswerRecordsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::AnswerRecordsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_es/internal/answer_records_tracing_connection.h b/google/cloud/dialogflow_es/internal/answer_records_tracing_connection.h index efc948e825820..9a11311a9ae21 100644 --- a/google/cloud/dialogflow_es/internal/answer_records_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/answer_records_tracing_connection.h @@ -47,6 +47,12 @@ class AnswerRecordsTracingConnection google::cloud::dialogflow::v2::UpdateAnswerRecordRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_es/internal/answer_records_tracing_stub.cc b/google/cloud/dialogflow_es/internal/answer_records_tracing_stub.cc index b181f2a7fd6cd..1ac5011e3e2cc 100644 --- a/google/cloud/dialogflow_es/internal/answer_records_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/answer_records_tracing_stub.cc @@ -56,6 +56,30 @@ AnswerRecordsTracingStub::UpdateAnswerRecord( context, *span, child_->UpdateAnswerRecord(context, options, request)); } +StatusOr +AnswerRecordsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.AnswerRecords", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +AnswerRecordsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.AnswerRecords", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeAnswerRecordsTracingStub( diff --git a/google/cloud/dialogflow_es/internal/answer_records_tracing_stub.h b/google/cloud/dialogflow_es/internal/answer_records_tracing_stub.h index e4a3550339e48..1500b62d1cea0 100644 --- a/google/cloud/dialogflow_es/internal/answer_records_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/answer_records_tracing_stub.h @@ -49,6 +49,14 @@ class AnswerRecordsTracingStub : public AnswerRecordsStub { google::cloud::dialogflow::v2::UpdateAnswerRecordRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/dialogflow_es/internal/contexts_auth_decorator.cc b/google/cloud/dialogflow_es/internal/contexts_auth_decorator.cc index 5d280f4c3f3e1..8ea24ae1a8953 100644 --- a/google/cloud/dialogflow_es/internal/contexts_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/contexts_auth_decorator.cc @@ -80,6 +80,23 @@ Status ContextsAuth::DeleteAllContexts( return child_->DeleteAllContexts(context, options, request); } +StatusOr +ContextsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr ContextsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/contexts_auth_decorator.h b/google/cloud/dialogflow_es/internal/contexts_auth_decorator.h index dca45efbce6b4..0131b4eaca65b 100644 --- a/google/cloud/dialogflow_es/internal/contexts_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/contexts_auth_decorator.h @@ -67,6 +67,14 @@ class ContextsAuth : public ContextsStub { google::cloud::dialogflow::v2::DeleteAllContextsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/dialogflow_es/internal/contexts_connection_impl.cc b/google/cloud/dialogflow_es/internal/contexts_connection_impl.cc index 8d75b88960229..7361b973d2b72 100644 --- a/google/cloud/dialogflow_es/internal/contexts_connection_impl.cc +++ b/google/cloud/dialogflow_es/internal/contexts_connection_impl.cc @@ -164,6 +164,53 @@ Status ContextsConnectionImpl::DeleteAllContexts( *current, request, __func__); } +StreamRange +ContextsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr ContextsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/contexts_connection_impl.h b/google/cloud/dialogflow_es/internal/contexts_connection_impl.h index 4b8b20218b944..a6b3aa6c9fc61 100644 --- a/google/cloud/dialogflow_es/internal/contexts_connection_impl.h +++ b/google/cloud/dialogflow_es/internal/contexts_connection_impl.h @@ -70,6 +70,12 @@ class ContextsConnectionImpl : public dialogflow_es::ContextsConnection { google::cloud::dialogflow::v2::DeleteAllContextsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_es/internal/contexts_logging_decorator.cc b/google/cloud/dialogflow_es/internal/contexts_logging_decorator.cc index ea692e8ce68e3..147de9c9a9069 100644 --- a/google/cloud/dialogflow_es/internal/contexts_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/contexts_logging_decorator.cc @@ -107,6 +107,29 @@ Status ContextsLogging::DeleteAllContexts( context, options, request, __func__, tracing_options_); } +StatusOr +ContextsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ContextsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/contexts_logging_decorator.h b/google/cloud/dialogflow_es/internal/contexts_logging_decorator.h index b908a4598d5a5..62c8f49a18320 100644 --- a/google/cloud/dialogflow_es/internal/contexts_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/contexts_logging_decorator.h @@ -67,6 +67,14 @@ class ContextsLogging : public ContextsStub { google::cloud::dialogflow::v2::DeleteAllContextsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/dialogflow_es/internal/contexts_metadata_decorator.cc b/google/cloud/dialogflow_es/internal/contexts_metadata_decorator.cc index 961d9dde1e533..c743a6173a8c2 100644 --- a/google/cloud/dialogflow_es/internal/contexts_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/contexts_metadata_decorator.cc @@ -96,6 +96,23 @@ Status ContextsMetadata::DeleteAllContexts( return child_->DeleteAllContexts(context, options, request); } +StatusOr +ContextsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr ContextsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void ContextsMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/dialogflow_es/internal/contexts_metadata_decorator.h b/google/cloud/dialogflow_es/internal/contexts_metadata_decorator.h index 721c16a9c17f2..0bba613d4c356 100644 --- a/google/cloud/dialogflow_es/internal/contexts_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/contexts_metadata_decorator.h @@ -67,6 +67,14 @@ class ContextsMetadata : public ContextsStub { google::cloud::dialogflow::v2::DeleteAllContextsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/dialogflow_es/internal/contexts_stub.cc b/google/cloud/dialogflow_es/internal/contexts_stub.cc index ba24765d6bf9d..7d46d00abece8 100644 --- a/google/cloud/dialogflow_es/internal/contexts_stub.cc +++ b/google/cloud/dialogflow_es/internal/contexts_stub.cc @@ -100,6 +100,29 @@ Status DefaultContextsStub::DeleteAllContexts( return google::cloud::Status(); } +StatusOr +DefaultContextsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultContextsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/contexts_stub.h b/google/cloud/dialogflow_es/internal/contexts_stub.h index 7a0cb7143fc91..a7fe9ae52f206 100644 --- a/google/cloud/dialogflow_es/internal/contexts_stub.h +++ b/google/cloud/dialogflow_es/internal/contexts_stub.h @@ -23,6 +23,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -60,14 +62,26 @@ class ContextsStub { grpc::ClientContext& context, Options const& options, google::cloud::dialogflow::v2::DeleteAllContextsRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultContextsStub : public ContextsStub { public: explicit DefaultContextsStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListContexts( grpc::ClientContext& context, Options const& options, @@ -98,9 +112,19 @@ class DefaultContextsStub : public ContextsStub { google::cloud::dialogflow::v2::DeleteAllContextsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/internal/contexts_stub_factory.cc b/google/cloud/dialogflow_es/internal/contexts_stub_factory.cc index 795495b72ff2c..b6215e2ea742c 100644 --- a/google/cloud/dialogflow_es/internal/contexts_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/contexts_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,8 +45,10 @@ std::shared_ptr CreateDefaultContextsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::Contexts::NewStub(channel); - std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); + std::shared_ptr stub = std::make_shared( + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), std::move(stub)); diff --git a/google/cloud/dialogflow_es/internal/contexts_tracing_connection.cc b/google/cloud/dialogflow_es/internal/contexts_tracing_connection.cc index e10e4a45a9dcc..3e098f3067a2a 100644 --- a/google/cloud/dialogflow_es/internal/contexts_tracing_connection.cc +++ b/google/cloud/dialogflow_es/internal/contexts_tracing_connection.cc @@ -87,6 +87,26 @@ Status ContextsTracingConnection::DeleteAllContexts( return internal::EndSpan(*span, child_->DeleteAllContexts(request)); } +StreamRange +ContextsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_es::ContextsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ContextsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::ContextsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_es/internal/contexts_tracing_connection.h b/google/cloud/dialogflow_es/internal/contexts_tracing_connection.h index c88f48e6ce495..6c4829de487bb 100644 --- a/google/cloud/dialogflow_es/internal/contexts_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/contexts_tracing_connection.h @@ -61,6 +61,12 @@ class ContextsTracingConnection : public dialogflow_es::ContextsConnection { google::cloud::dialogflow::v2::DeleteAllContextsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_es/internal/contexts_tracing_stub.cc b/google/cloud/dialogflow_es/internal/contexts_tracing_stub.cc index 229d8f3d96d3a..d5f75bfa66b2d 100644 --- a/google/cloud/dialogflow_es/internal/contexts_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/contexts_tracing_stub.cc @@ -101,6 +101,29 @@ Status ContextsTracingStub::DeleteAllContexts( context, *span, child_->DeleteAllContexts(context, options, request)); } +StatusOr +ContextsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Contexts", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr ContextsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Contexts", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeContextsTracingStub( diff --git a/google/cloud/dialogflow_es/internal/contexts_tracing_stub.h b/google/cloud/dialogflow_es/internal/contexts_tracing_stub.h index 8b695aeca2d84..28b5953627cfd 100644 --- a/google/cloud/dialogflow_es/internal/contexts_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/contexts_tracing_stub.h @@ -67,6 +67,14 @@ class ContextsTracingStub : public ContextsStub { google::cloud::dialogflow::v2::DeleteAllContextsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/dialogflow_es/internal/conversation_datasets_auth_decorator.cc b/google/cloud/dialogflow_es/internal/conversation_datasets_auth_decorator.cc index 5d5b1162a4cd6..c8ea195663cc8 100644 --- a/google/cloud/dialogflow_es/internal/conversation_datasets_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/conversation_datasets_auth_decorator.cc @@ -144,6 +144,24 @@ ConversationDatasetsAuth::ImportConversationData( return child_->ImportConversationData(context, options, request); } +StatusOr +ConversationDatasetsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +ConversationDatasetsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> ConversationDatasetsAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/conversation_datasets_auth_decorator.h b/google/cloud/dialogflow_es/internal/conversation_datasets_auth_decorator.h index a76ac5f36481e..e7dc73253aff5 100644 --- a/google/cloud/dialogflow_es/internal/conversation_datasets_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/conversation_datasets_auth_decorator.h @@ -89,6 +89,14 @@ class ConversationDatasetsAuth : public ConversationDatasetsStub { google::cloud::dialogflow::v2::ImportConversationDataRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/conversation_datasets_connection_impl.cc b/google/cloud/dialogflow_es/internal/conversation_datasets_connection_impl.cc index 265b1941e3e67..bfb0cd00fe908 100644 --- a/google/cloud/dialogflow_es/internal/conversation_datasets_connection_impl.cc +++ b/google/cloud/dialogflow_es/internal/conversation_datasets_connection_impl.cc @@ -422,6 +422,54 @@ ConversationDatasetsConnectionImpl::ImportConversationData( polling_policy(*current), __func__); } +StreamRange +ConversationDatasetsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ConversationDatasetsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/conversation_datasets_connection_impl.h b/google/cloud/dialogflow_es/internal/conversation_datasets_connection_impl.h index b1c9fa48900b6..5d498bab64490 100644 --- a/google/cloud/dialogflow_es/internal/conversation_datasets_connection_impl.h +++ b/google/cloud/dialogflow_es/internal/conversation_datasets_connection_impl.h @@ -108,6 +108,12 @@ class ConversationDatasetsConnectionImpl ImportConversationData( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_es/internal/conversation_datasets_logging_decorator.cc b/google/cloud/dialogflow_es/internal/conversation_datasets_logging_decorator.cc index 4e907e820f64d..811deca185648 100644 --- a/google/cloud/dialogflow_es/internal/conversation_datasets_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/conversation_datasets_logging_decorator.cc @@ -170,6 +170,30 @@ ConversationDatasetsLogging::ImportConversationData( context, options, request, __func__, tracing_options_); } +StatusOr +ConversationDatasetsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ConversationDatasetsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ConversationDatasetsLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/conversation_datasets_logging_decorator.h b/google/cloud/dialogflow_es/internal/conversation_datasets_logging_decorator.h index 6b88e4a90acae..3bb8e50ca7f31 100644 --- a/google/cloud/dialogflow_es/internal/conversation_datasets_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/conversation_datasets_logging_decorator.h @@ -89,6 +89,14 @@ class ConversationDatasetsLogging : public ConversationDatasetsStub { google::cloud::dialogflow::v2::ImportConversationDataRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/conversation_datasets_metadata_decorator.cc b/google/cloud/dialogflow_es/internal/conversation_datasets_metadata_decorator.cc index 02d589483b743..a43ab5c356847 100644 --- a/google/cloud/dialogflow_es/internal/conversation_datasets_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/conversation_datasets_metadata_decorator.cc @@ -133,6 +133,24 @@ ConversationDatasetsMetadata::ImportConversationData( return child_->ImportConversationData(context, options, request); } +StatusOr +ConversationDatasetsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +ConversationDatasetsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> ConversationDatasetsMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/conversation_datasets_metadata_decorator.h b/google/cloud/dialogflow_es/internal/conversation_datasets_metadata_decorator.h index 6fd8e208e4b39..f8f09d8d08777 100644 --- a/google/cloud/dialogflow_es/internal/conversation_datasets_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/conversation_datasets_metadata_decorator.h @@ -90,6 +90,14 @@ class ConversationDatasetsMetadata : public ConversationDatasetsStub { google::cloud::dialogflow::v2::ImportConversationDataRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/conversation_datasets_stub.cc b/google/cloud/dialogflow_es/internal/conversation_datasets_stub.cc index 43cf42bc8ff7c..85e5728b8ca03 100644 --- a/google/cloud/dialogflow_es/internal/conversation_datasets_stub.cc +++ b/google/cloud/dialogflow_es/internal/conversation_datasets_stub.cc @@ -163,6 +163,30 @@ DefaultConversationDatasetsStub::ImportConversationData( return response; } +StatusOr +DefaultConversationDatasetsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultConversationDatasetsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultConversationDatasetsStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/conversation_datasets_stub.h b/google/cloud/dialogflow_es/internal/conversation_datasets_stub.h index 1c7f3665d6f0b..791a38030b802 100644 --- a/google/cloud/dialogflow_es/internal/conversation_datasets_stub.h +++ b/google/cloud/dialogflow_es/internal/conversation_datasets_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -90,6 +92,15 @@ class ConversationDatasetsStub { google::cloud::dialogflow::v2::ImportConversationDataRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -109,9 +120,13 @@ class DefaultConversationDatasetsStub : public ConversationDatasetsStub { std::unique_ptr< google::cloud::dialogflow::v2::ConversationDatasets::StubInterface> grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateConversationDataset( @@ -163,6 +178,14 @@ class DefaultConversationDatasetsStub : public ConversationDatasetsStub { google::cloud::dialogflow::v2::ImportConversationDataRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -179,6 +202,8 @@ class DefaultConversationDatasetsStub : public ConversationDatasetsStub { std::unique_ptr< google::cloud::dialogflow::v2::ConversationDatasets::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/dialogflow_es/internal/conversation_datasets_stub_factory.cc b/google/cloud/dialogflow_es/internal/conversation_datasets_stub_factory.cc index 26a4c76fc226c..90e1680f5cb5c 100644 --- a/google/cloud/dialogflow_es/internal/conversation_datasets_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/conversation_datasets_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultConversationDatasetsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::ConversationDatasets::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/dialogflow_es/internal/conversation_datasets_tracing_connection.cc b/google/cloud/dialogflow_es/internal/conversation_datasets_tracing_connection.cc index c9bc5e98f4195..a451962249cd3 100644 --- a/google/cloud/dialogflow_es/internal/conversation_datasets_tracing_connection.cc +++ b/google/cloud/dialogflow_es/internal/conversation_datasets_tracing_connection.cc @@ -165,6 +165,26 @@ ConversationDatasetsTracingConnection::ImportConversationData( child_->ImportConversationData(operation)); } +StreamRange +ConversationDatasetsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_es::ConversationDatasetsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ConversationDatasetsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_es::ConversationDatasetsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_es/internal/conversation_datasets_tracing_connection.h b/google/cloud/dialogflow_es/internal/conversation_datasets_tracing_connection.h index 3307b858b9fb4..a9dac373cbe93 100644 --- a/google/cloud/dialogflow_es/internal/conversation_datasets_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/conversation_datasets_tracing_connection.h @@ -96,6 +96,12 @@ class ConversationDatasetsTracingConnection ImportConversationData( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_es/internal/conversation_datasets_tracing_stub.cc b/google/cloud/dialogflow_es/internal/conversation_datasets_tracing_stub.cc index 8deeb04934165..52763d950a089 100644 --- a/google/cloud/dialogflow_es/internal/conversation_datasets_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/conversation_datasets_tracing_stub.cc @@ -158,6 +158,30 @@ ConversationDatasetsTracingStub::ImportConversationData( child_->ImportConversationData(context, options, request)); } +StatusOr +ConversationDatasetsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.v2.ConversationDatasets", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +ConversationDatasetsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.v2.ConversationDatasets", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> ConversationDatasetsTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/conversation_datasets_tracing_stub.h b/google/cloud/dialogflow_es/internal/conversation_datasets_tracing_stub.h index 78affb28126cc..def243a474831 100644 --- a/google/cloud/dialogflow_es/internal/conversation_datasets_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/conversation_datasets_tracing_stub.h @@ -89,6 +89,14 @@ class ConversationDatasetsTracingStub : public ConversationDatasetsStub { google::cloud::dialogflow::v2::ImportConversationDataRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/conversation_models_auth_decorator.cc b/google/cloud/dialogflow_es/internal/conversation_models_auth_decorator.cc index f4646bfd96348..2a326f17f6163 100644 --- a/google/cloud/dialogflow_es/internal/conversation_models_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/conversation_models_auth_decorator.cc @@ -226,6 +226,23 @@ ConversationModelsAuth::CreateConversationModelEvaluation( return child_->CreateConversationModelEvaluation(context, options, request); } +StatusOr +ConversationModelsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr ConversationModelsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> ConversationModelsAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/conversation_models_auth_decorator.h b/google/cloud/dialogflow_es/internal/conversation_models_auth_decorator.h index 18d30f9afae63..028e9441b2e17 100644 --- a/google/cloud/dialogflow_es/internal/conversation_models_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/conversation_models_auth_decorator.h @@ -126,6 +126,14 @@ class ConversationModelsAuth : public ConversationModelsStub { google::cloud::dialogflow::v2:: CreateConversationModelEvaluationRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/conversation_models_connection_impl.cc b/google/cloud/dialogflow_es/internal/conversation_models_connection_impl.cc index 55a4e763d566d..3ca483ac502b6 100644 --- a/google/cloud/dialogflow_es/internal/conversation_models_connection_impl.cc +++ b/google/cloud/dialogflow_es/internal/conversation_models_connection_impl.cc @@ -676,6 +676,54 @@ ConversationModelsConnectionImpl::CreateConversationModelEvaluation( polling_policy(*current), __func__); } +StreamRange +ConversationModelsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ConversationModelsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/conversation_models_connection_impl.h b/google/cloud/dialogflow_es/internal/conversation_models_connection_impl.h index 7a910505965f5..79d9f29a581ab 100644 --- a/google/cloud/dialogflow_es/internal/conversation_models_connection_impl.h +++ b/google/cloud/dialogflow_es/internal/conversation_models_connection_impl.h @@ -148,6 +148,12 @@ class ConversationModelsConnectionImpl CreateConversationModelEvaluation( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_es/internal/conversation_models_logging_decorator.cc b/google/cloud/dialogflow_es/internal/conversation_models_logging_decorator.cc index 34ffabead76d4..4ab568db97566 100644 --- a/google/cloud/dialogflow_es/internal/conversation_models_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/conversation_models_logging_decorator.cc @@ -272,6 +272,30 @@ ConversationModelsLogging::CreateConversationModelEvaluation( context, options, request, __func__, tracing_options_); } +StatusOr +ConversationModelsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ConversationModelsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ConversationModelsLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/conversation_models_logging_decorator.h b/google/cloud/dialogflow_es/internal/conversation_models_logging_decorator.h index 76512071bfffc..1389c0b9a8d73 100644 --- a/google/cloud/dialogflow_es/internal/conversation_models_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/conversation_models_logging_decorator.h @@ -126,6 +126,14 @@ class ConversationModelsLogging : public ConversationModelsStub { google::cloud::dialogflow::v2:: CreateConversationModelEvaluationRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/conversation_models_metadata_decorator.cc b/google/cloud/dialogflow_es/internal/conversation_models_metadata_decorator.cc index 033002084ad46..f4fa102c1617b 100644 --- a/google/cloud/dialogflow_es/internal/conversation_models_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/conversation_models_metadata_decorator.cc @@ -199,6 +199,24 @@ ConversationModelsMetadata::CreateConversationModelEvaluation( return child_->CreateConversationModelEvaluation(context, options, request); } +StatusOr +ConversationModelsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +ConversationModelsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> ConversationModelsMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/conversation_models_metadata_decorator.h b/google/cloud/dialogflow_es/internal/conversation_models_metadata_decorator.h index e86de719d9fbf..37efd2077dac7 100644 --- a/google/cloud/dialogflow_es/internal/conversation_models_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/conversation_models_metadata_decorator.h @@ -127,6 +127,14 @@ class ConversationModelsMetadata : public ConversationModelsStub { google::cloud::dialogflow::v2:: CreateConversationModelEvaluationRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/conversation_models_stub.cc b/google/cloud/dialogflow_es/internal/conversation_models_stub.cc index 8f2929693e4a2..f8e3473f7a51d 100644 --- a/google/cloud/dialogflow_es/internal/conversation_models_stub.cc +++ b/google/cloud/dialogflow_es/internal/conversation_models_stub.cc @@ -262,6 +262,30 @@ DefaultConversationModelsStub::CreateConversationModelEvaluation( return response; } +StatusOr +DefaultConversationModelsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultConversationModelsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultConversationModelsStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/conversation_models_stub.h b/google/cloud/dialogflow_es/internal/conversation_models_stub.h index 307598db5f601..53921f84e47a0 100644 --- a/google/cloud/dialogflow_es/internal/conversation_models_stub.h +++ b/google/cloud/dialogflow_es/internal/conversation_models_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -130,6 +132,15 @@ class ConversationModelsStub { google::cloud::dialogflow::v2:: CreateConversationModelEvaluationRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -149,9 +160,13 @@ class DefaultConversationModelsStub : public ConversationModelsStub { std::unique_ptr< google::cloud::dialogflow::v2::ConversationModels::StubInterface> grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateConversationModel( google::cloud::CompletionQueue& cq, @@ -240,6 +255,14 @@ class DefaultConversationModelsStub : public ConversationModelsStub { google::cloud::dialogflow::v2:: CreateConversationModelEvaluationRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -256,6 +279,8 @@ class DefaultConversationModelsStub : public ConversationModelsStub { std::unique_ptr< google::cloud::dialogflow::v2::ConversationModels::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/dialogflow_es/internal/conversation_models_stub_factory.cc b/google/cloud/dialogflow_es/internal/conversation_models_stub_factory.cc index 254e5e5f562c9..63243ad53a6a1 100644 --- a/google/cloud/dialogflow_es/internal/conversation_models_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/conversation_models_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultConversationModelsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::ConversationModels::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/dialogflow_es/internal/conversation_models_tracing_connection.cc b/google/cloud/dialogflow_es/internal/conversation_models_tracing_connection.cc index ef22d13d34143..15177c0430226 100644 --- a/google/cloud/dialogflow_es/internal/conversation_models_tracing_connection.cc +++ b/google/cloud/dialogflow_es/internal/conversation_models_tracing_connection.cc @@ -253,6 +253,26 @@ ConversationModelsTracingConnection::CreateConversationModelEvaluation( std::move(span), child_->CreateConversationModelEvaluation(operation)); } +StreamRange +ConversationModelsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_es::ConversationModelsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ConversationModelsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_es::ConversationModelsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_es/internal/conversation_models_tracing_connection.h b/google/cloud/dialogflow_es/internal/conversation_models_tracing_connection.h index cf898e2cc67e2..c26cf8b8511d7 100644 --- a/google/cloud/dialogflow_es/internal/conversation_models_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/conversation_models_tracing_connection.h @@ -136,6 +136,12 @@ class ConversationModelsTracingConnection CreateConversationModelEvaluation( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_es/internal/conversation_models_tracing_stub.cc b/google/cloud/dialogflow_es/internal/conversation_models_tracing_stub.cc index 394517d28990c..915a071c3103b 100644 --- a/google/cloud/dialogflow_es/internal/conversation_models_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/conversation_models_tracing_stub.cc @@ -250,6 +250,30 @@ ConversationModelsTracingStub::CreateConversationModelEvaluation( child_->CreateConversationModelEvaluation(context, options, request)); } +StatusOr +ConversationModelsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.v2.ConversationModels", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +ConversationModelsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.v2.ConversationModels", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> ConversationModelsTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/conversation_models_tracing_stub.h b/google/cloud/dialogflow_es/internal/conversation_models_tracing_stub.h index c7e66f0ae4ac5..5091d7a8e6443 100644 --- a/google/cloud/dialogflow_es/internal/conversation_models_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/conversation_models_tracing_stub.h @@ -126,6 +126,14 @@ class ConversationModelsTracingStub : public ConversationModelsStub { google::cloud::dialogflow::v2:: CreateConversationModelEvaluationRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/conversation_profiles_auth_decorator.cc b/google/cloud/dialogflow_es/internal/conversation_profiles_auth_decorator.cc index 11dde1d882384..9da33c7598d9c 100644 --- a/google/cloud/dialogflow_es/internal/conversation_profiles_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/conversation_profiles_auth_decorator.cc @@ -142,6 +142,24 @@ ConversationProfilesAuth::ClearSuggestionFeatureConfig( return child_->ClearSuggestionFeatureConfig(context, options, request); } +StatusOr +ConversationProfilesAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +ConversationProfilesAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> ConversationProfilesAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/conversation_profiles_auth_decorator.h b/google/cloud/dialogflow_es/internal/conversation_profiles_auth_decorator.h index feeb1998248b3..ee77ddb129b2a 100644 --- a/google/cloud/dialogflow_es/internal/conversation_profiles_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/conversation_profiles_auth_decorator.h @@ -94,6 +94,14 @@ class ConversationProfilesAuth : public ConversationProfilesStub { google::cloud::dialogflow::v2::ClearSuggestionFeatureConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/conversation_profiles_connection_impl.cc b/google/cloud/dialogflow_es/internal/conversation_profiles_connection_impl.cc index 159456179fc20..ecfa636db02b4 100644 --- a/google/cloud/dialogflow_es/internal/conversation_profiles_connection_impl.cc +++ b/google/cloud/dialogflow_es/internal/conversation_profiles_connection_impl.cc @@ -360,6 +360,54 @@ ConversationProfilesConnectionImpl::ClearSuggestionFeatureConfig( polling_policy(*current), __func__); } +StreamRange +ConversationProfilesConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ConversationProfilesConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/conversation_profiles_connection_impl.h b/google/cloud/dialogflow_es/internal/conversation_profiles_connection_impl.h index 514d2d2651788..56e3e674f8472 100644 --- a/google/cloud/dialogflow_es/internal/conversation_profiles_connection_impl.h +++ b/google/cloud/dialogflow_es/internal/conversation_profiles_connection_impl.h @@ -104,6 +104,12 @@ class ConversationProfilesConnectionImpl ClearSuggestionFeatureConfig( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_es/internal/conversation_profiles_logging_decorator.cc b/google/cloud/dialogflow_es/internal/conversation_profiles_logging_decorator.cc index e57834f0a12d8..9bbd584e7d773 100644 --- a/google/cloud/dialogflow_es/internal/conversation_profiles_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/conversation_profiles_logging_decorator.cc @@ -176,6 +176,30 @@ ConversationProfilesLogging::ClearSuggestionFeatureConfig( context, options, request, __func__, tracing_options_); } +StatusOr +ConversationProfilesLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ConversationProfilesLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ConversationProfilesLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/conversation_profiles_logging_decorator.h b/google/cloud/dialogflow_es/internal/conversation_profiles_logging_decorator.h index c75258d4c746f..19c6a9da09cb9 100644 --- a/google/cloud/dialogflow_es/internal/conversation_profiles_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/conversation_profiles_logging_decorator.h @@ -94,6 +94,14 @@ class ConversationProfilesLogging : public ConversationProfilesStub { google::cloud::dialogflow::v2::ClearSuggestionFeatureConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/conversation_profiles_metadata_decorator.cc b/google/cloud/dialogflow_es/internal/conversation_profiles_metadata_decorator.cc index b7e553cf553a0..b64f9790e3ba8 100644 --- a/google/cloud/dialogflow_es/internal/conversation_profiles_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/conversation_profiles_metadata_decorator.cc @@ -149,6 +149,24 @@ ConversationProfilesMetadata::ClearSuggestionFeatureConfig( return child_->ClearSuggestionFeatureConfig(context, options, request); } +StatusOr +ConversationProfilesMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +ConversationProfilesMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> ConversationProfilesMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/conversation_profiles_metadata_decorator.h b/google/cloud/dialogflow_es/internal/conversation_profiles_metadata_decorator.h index 2e93f9ac6e8c4..2df1e180ef022 100644 --- a/google/cloud/dialogflow_es/internal/conversation_profiles_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/conversation_profiles_metadata_decorator.h @@ -95,6 +95,14 @@ class ConversationProfilesMetadata : public ConversationProfilesStub { google::cloud::dialogflow::v2::ClearSuggestionFeatureConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/conversation_profiles_stub.cc b/google/cloud/dialogflow_es/internal/conversation_profiles_stub.cc index 13eeb1227c48c..7ef69a21b15a1 100644 --- a/google/cloud/dialogflow_es/internal/conversation_profiles_stub.cc +++ b/google/cloud/dialogflow_es/internal/conversation_profiles_stub.cc @@ -170,6 +170,30 @@ DefaultConversationProfilesStub::ClearSuggestionFeatureConfig( return response; } +StatusOr +DefaultConversationProfilesStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultConversationProfilesStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultConversationProfilesStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/conversation_profiles_stub.h b/google/cloud/dialogflow_es/internal/conversation_profiles_stub.h index ad1b54053ca45..ca22ca1be901b 100644 --- a/google/cloud/dialogflow_es/internal/conversation_profiles_stub.h +++ b/google/cloud/dialogflow_es/internal/conversation_profiles_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -94,6 +96,15 @@ class ConversationProfilesStub { google::cloud::dialogflow::v2::ClearSuggestionFeatureConfigRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -113,9 +124,13 @@ class DefaultConversationProfilesStub : public ConversationProfilesStub { std::unique_ptr< google::cloud::dialogflow::v2::ConversationProfiles::StubInterface> grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListConversationProfiles( @@ -172,6 +187,14 @@ class DefaultConversationProfilesStub : public ConversationProfilesStub { google::cloud::dialogflow::v2::ClearSuggestionFeatureConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -188,6 +211,8 @@ class DefaultConversationProfilesStub : public ConversationProfilesStub { std::unique_ptr< google::cloud::dialogflow::v2::ConversationProfiles::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/dialogflow_es/internal/conversation_profiles_stub_factory.cc b/google/cloud/dialogflow_es/internal/conversation_profiles_stub_factory.cc index 606d561e2ef9c..32d5f39db8b10 100644 --- a/google/cloud/dialogflow_es/internal/conversation_profiles_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/conversation_profiles_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultConversationProfilesStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::ConversationProfiles::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/dialogflow_es/internal/conversation_profiles_tracing_connection.cc b/google/cloud/dialogflow_es/internal/conversation_profiles_tracing_connection.cc index 32850e3bf2134..ec5f1fb173e06 100644 --- a/google/cloud/dialogflow_es/internal/conversation_profiles_tracing_connection.cc +++ b/google/cloud/dialogflow_es/internal/conversation_profiles_tracing_connection.cc @@ -160,6 +160,26 @@ ConversationProfilesTracingConnection::ClearSuggestionFeatureConfig( child_->ClearSuggestionFeatureConfig(operation)); } +StreamRange +ConversationProfilesTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_es::ConversationProfilesConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ConversationProfilesTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_es::ConversationProfilesConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_es/internal/conversation_profiles_tracing_connection.h b/google/cloud/dialogflow_es/internal/conversation_profiles_tracing_connection.h index 7637177ae60fe..3d504f28a7de4 100644 --- a/google/cloud/dialogflow_es/internal/conversation_profiles_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/conversation_profiles_tracing_connection.h @@ -92,6 +92,12 @@ class ConversationProfilesTracingConnection ClearSuggestionFeatureConfig( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_es/internal/conversation_profiles_tracing_stub.cc b/google/cloud/dialogflow_es/internal/conversation_profiles_tracing_stub.cc index c16636e4b3f3b..ec777af1100f3 100644 --- a/google/cloud/dialogflow_es/internal/conversation_profiles_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/conversation_profiles_tracing_stub.cc @@ -170,6 +170,30 @@ ConversationProfilesTracingStub::ClearSuggestionFeatureConfig( child_->ClearSuggestionFeatureConfig(context, options, request)); } +StatusOr +ConversationProfilesTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.v2.ConversationProfiles", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +ConversationProfilesTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.v2.ConversationProfiles", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> ConversationProfilesTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/conversation_profiles_tracing_stub.h b/google/cloud/dialogflow_es/internal/conversation_profiles_tracing_stub.h index a32599cc8abf6..947a0e43cc07b 100644 --- a/google/cloud/dialogflow_es/internal/conversation_profiles_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/conversation_profiles_tracing_stub.h @@ -94,6 +94,14 @@ class ConversationProfilesTracingStub : public ConversationProfilesStub { google::cloud::dialogflow::v2::ClearSuggestionFeatureConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/conversations_auth_decorator.cc b/google/cloud/dialogflow_es/internal/conversations_auth_decorator.cc index 35df51cdc5d56..9bbafeb88c928 100644 --- a/google/cloud/dialogflow_es/internal/conversations_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/conversations_auth_decorator.cc @@ -115,6 +115,23 @@ ConversationsAuth::SearchKnowledge( return child_->SearchKnowledge(context, options, request); } +StatusOr +ConversationsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr ConversationsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/conversations_auth_decorator.h b/google/cloud/dialogflow_es/internal/conversations_auth_decorator.h index 93ec6049226ce..7fba0d8abf1ec 100644 --- a/google/cloud/dialogflow_es/internal/conversations_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/conversations_auth_decorator.h @@ -87,6 +87,14 @@ class ConversationsAuth : public ConversationsStub { google::cloud::dialogflow::v2::SearchKnowledgeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/dialogflow_es/internal/conversations_connection_impl.cc b/google/cloud/dialogflow_es/internal/conversations_connection_impl.cc index ba38986965e50..632bf0ed233d1 100644 --- a/google/cloud/dialogflow_es/internal/conversations_connection_impl.cc +++ b/google/cloud/dialogflow_es/internal/conversations_connection_impl.cc @@ -238,6 +238,54 @@ ConversationsConnectionImpl::SearchKnowledge( *current, request, __func__); } +StreamRange +ConversationsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ConversationsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/conversations_connection_impl.h b/google/cloud/dialogflow_es/internal/conversations_connection_impl.h index e3894b0a0eaa0..f6dfaf4c36e02 100644 --- a/google/cloud/dialogflow_es/internal/conversations_connection_impl.h +++ b/google/cloud/dialogflow_es/internal/conversations_connection_impl.h @@ -86,6 +86,12 @@ class ConversationsConnectionImpl SearchKnowledge(google::cloud::dialogflow::v2::SearchKnowledgeRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_es/internal/conversations_logging_decorator.cc b/google/cloud/dialogflow_es/internal/conversations_logging_decorator.cc index 97d8f657ff5d3..aadf53c97b53b 100644 --- a/google/cloud/dialogflow_es/internal/conversations_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/conversations_logging_decorator.cc @@ -156,6 +156,29 @@ ConversationsLogging::SearchKnowledge( context, options, request, __func__, tracing_options_); } +StatusOr +ConversationsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ConversationsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/conversations_logging_decorator.h b/google/cloud/dialogflow_es/internal/conversations_logging_decorator.h index 2e6ef1d3e8832..9d85f5a6c42e4 100644 --- a/google/cloud/dialogflow_es/internal/conversations_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/conversations_logging_decorator.h @@ -87,6 +87,14 @@ class ConversationsLogging : public ConversationsStub { google::cloud::dialogflow::v2::SearchKnowledgeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/dialogflow_es/internal/conversations_metadata_decorator.cc b/google/cloud/dialogflow_es/internal/conversations_metadata_decorator.cc index 175b3c85a0b9b..579e302c53007 100644 --- a/google/cloud/dialogflow_es/internal/conversations_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/conversations_metadata_decorator.cc @@ -131,6 +131,23 @@ ConversationsMetadata::SearchKnowledge( return child_->SearchKnowledge(context, options, request); } +StatusOr +ConversationsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr ConversationsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void ConversationsMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/dialogflow_es/internal/conversations_metadata_decorator.h b/google/cloud/dialogflow_es/internal/conversations_metadata_decorator.h index 3ac9ef7171aba..8b5d8ce879342 100644 --- a/google/cloud/dialogflow_es/internal/conversations_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/conversations_metadata_decorator.h @@ -87,6 +87,14 @@ class ConversationsMetadata : public ConversationsStub { google::cloud::dialogflow::v2::SearchKnowledgeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/dialogflow_es/internal/conversations_stub.cc b/google/cloud/dialogflow_es/internal/conversations_stub.cc index 567f7c1bb1b53..5699cde8c1a78 100644 --- a/google/cloud/dialogflow_es/internal/conversations_stub.cc +++ b/google/cloud/dialogflow_es/internal/conversations_stub.cc @@ -144,6 +144,30 @@ DefaultConversationsStub::SearchKnowledge( return response; } +StatusOr +DefaultConversationsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultConversationsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/conversations_stub.h b/google/cloud/dialogflow_es/internal/conversations_stub.h index 9692628caf2b1..1c242ae4bb329 100644 --- a/google/cloud/dialogflow_es/internal/conversations_stub.h +++ b/google/cloud/dialogflow_es/internal/conversations_stub.h @@ -23,6 +23,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -87,6 +89,15 @@ class ConversationsStub { SearchKnowledge( grpc::ClientContext& context, Options const& options, google::cloud::dialogflow::v2::SearchKnowledgeRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultConversationsStub : public ConversationsStub { @@ -94,8 +105,11 @@ class DefaultConversationsStub : public ConversationsStub { explicit DefaultConversationsStub( std::unique_ptr< google::cloud::dialogflow::v2::Conversations::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr CreateConversation( grpc::ClientContext& context, Options const& options, @@ -146,9 +160,19 @@ class DefaultConversationsStub : public ConversationsStub { google::cloud::dialogflow::v2::SearchKnowledgeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/internal/conversations_stub_factory.cc b/google/cloud/dialogflow_es/internal/conversations_stub_factory.cc index c29370bf2f2ef..0f4f00f9fbae5 100644 --- a/google/cloud/dialogflow_es/internal/conversations_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/conversations_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,8 +45,11 @@ std::shared_ptr CreateDefaultConversationsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::Conversations::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + std::make_shared( + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = diff --git a/google/cloud/dialogflow_es/internal/conversations_tracing_connection.cc b/google/cloud/dialogflow_es/internal/conversations_tracing_connection.cc index a67fb3d74b765..334f3b000aa1d 100644 --- a/google/cloud/dialogflow_es/internal/conversations_tracing_connection.cc +++ b/google/cloud/dialogflow_es/internal/conversations_tracing_connection.cc @@ -122,6 +122,26 @@ ConversationsTracingConnection::SearchKnowledge( return internal::EndSpan(*span, child_->SearchKnowledge(request)); } +StreamRange +ConversationsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_es::ConversationsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ConversationsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::ConversationsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_es/internal/conversations_tracing_connection.h b/google/cloud/dialogflow_es/internal/conversations_tracing_connection.h index eeaf4509bc506..ee26391b0a244 100644 --- a/google/cloud/dialogflow_es/internal/conversations_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/conversations_tracing_connection.h @@ -77,6 +77,12 @@ class ConversationsTracingConnection SearchKnowledge(google::cloud::dialogflow::v2::SearchKnowledgeRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_es/internal/conversations_tracing_stub.cc b/google/cloud/dialogflow_es/internal/conversations_tracing_stub.cc index 17b697d5c892f..2736301124dd9 100644 --- a/google/cloud/dialogflow_es/internal/conversations_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/conversations_tracing_stub.cc @@ -146,6 +146,30 @@ ConversationsTracingStub::SearchKnowledge( child_->SearchKnowledge(context, options, request)); } +StatusOr +ConversationsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Conversations", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +ConversationsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Conversations", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeConversationsTracingStub( diff --git a/google/cloud/dialogflow_es/internal/conversations_tracing_stub.h b/google/cloud/dialogflow_es/internal/conversations_tracing_stub.h index 9d8bdbf4a49e7..5733692c1e76e 100644 --- a/google/cloud/dialogflow_es/internal/conversations_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/conversations_tracing_stub.h @@ -87,6 +87,14 @@ class ConversationsTracingStub : public ConversationsStub { google::cloud::dialogflow::v2::SearchKnowledgeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/dialogflow_es/internal/documents_auth_decorator.cc b/google/cloud/dialogflow_es/internal/documents_auth_decorator.cc index b03e661b844db..9e1bf65db7551 100644 --- a/google/cloud/dialogflow_es/internal/documents_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/documents_auth_decorator.cc @@ -216,6 +216,23 @@ StatusOr DocumentsAuth::ExportDocument( return child_->ExportDocument(context, options, request); } +StatusOr +DocumentsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr DocumentsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> DocumentsAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/documents_auth_decorator.h b/google/cloud/dialogflow_es/internal/documents_auth_decorator.h index 55e015bdf9944..76ef75bb08648 100644 --- a/google/cloud/dialogflow_es/internal/documents_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/documents_auth_decorator.h @@ -121,6 +121,14 @@ class DocumentsAuth : public DocumentsStub { google::cloud::dialogflow::v2::ExportDocumentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/documents_connection_impl.cc b/google/cloud/dialogflow_es/internal/documents_connection_impl.cc index fb09988fdbf4f..c0be14de73f30 100644 --- a/google/cloud/dialogflow_es/internal/documents_connection_impl.cc +++ b/google/cloud/dialogflow_es/internal/documents_connection_impl.cc @@ -667,6 +667,54 @@ DocumentsConnectionImpl::ExportDocument( polling_policy(*current), __func__); } +StreamRange +DocumentsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DocumentsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/documents_connection_impl.h b/google/cloud/dialogflow_es/internal/documents_connection_impl.h index 01b05a64a9c8a..66d29e9a09fd2 100644 --- a/google/cloud/dialogflow_es/internal/documents_connection_impl.h +++ b/google/cloud/dialogflow_es/internal/documents_connection_impl.h @@ -130,6 +130,12 @@ class DocumentsConnectionImpl : public dialogflow_es::DocumentsConnection { future> ExportDocument( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_es/internal/documents_logging_decorator.cc b/google/cloud/dialogflow_es/internal/documents_logging_decorator.cc index 2da727315e7c1..83f1c8b163d32 100644 --- a/google/cloud/dialogflow_es/internal/documents_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/documents_logging_decorator.cc @@ -245,6 +245,29 @@ StatusOr DocumentsLogging::ExportDocument( context, options, request, __func__, tracing_options_); } +StatusOr +DocumentsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DocumentsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> DocumentsLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/documents_logging_decorator.h b/google/cloud/dialogflow_es/internal/documents_logging_decorator.h index 5587dec5f0d3a..db662b89624fb 100644 --- a/google/cloud/dialogflow_es/internal/documents_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/documents_logging_decorator.h @@ -121,6 +121,14 @@ class DocumentsLogging : public DocumentsStub { google::cloud::dialogflow::v2::ExportDocumentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/documents_metadata_decorator.cc b/google/cloud/dialogflow_es/internal/documents_metadata_decorator.cc index f6898159998b8..e297ab19c8171 100644 --- a/google/cloud/dialogflow_es/internal/documents_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/documents_metadata_decorator.cc @@ -184,6 +184,23 @@ StatusOr DocumentsMetadata::ExportDocument( return child_->ExportDocument(context, options, request); } +StatusOr +DocumentsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr DocumentsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> DocumentsMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/documents_metadata_decorator.h b/google/cloud/dialogflow_es/internal/documents_metadata_decorator.h index ec3fd03a97360..267690c3fe100 100644 --- a/google/cloud/dialogflow_es/internal/documents_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/documents_metadata_decorator.h @@ -121,6 +121,14 @@ class DocumentsMetadata : public DocumentsStub { google::cloud::dialogflow::v2::ExportDocumentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/documents_stub.cc b/google/cloud/dialogflow_es/internal/documents_stub.cc index 6d8f4a1f4a925..316732db65fbf 100644 --- a/google/cloud/dialogflow_es/internal/documents_stub.cc +++ b/google/cloud/dialogflow_es/internal/documents_stub.cc @@ -235,6 +235,29 @@ StatusOr DefaultDocumentsStub::ExportDocument( return response; } +StatusOr +DefaultDocumentsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultDocumentsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultDocumentsStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/documents_stub.h b/google/cloud/dialogflow_es/internal/documents_stub.h index 424e6cfa5bfff..e07922a58dd9c 100644 --- a/google/cloud/dialogflow_es/internal/documents_stub.h +++ b/google/cloud/dialogflow_es/internal/documents_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -107,6 +109,15 @@ class DocumentsStub { grpc::ClientContext& context, Options options, google::cloud::dialogflow::v2::ExportDocumentRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -125,9 +136,13 @@ class DefaultDocumentsStub : public DocumentsStub { DefaultDocumentsStub( std::unique_ptr grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListDocuments( grpc::ClientContext& context, Options const& options, @@ -211,6 +226,14 @@ class DefaultDocumentsStub : public DocumentsStub { google::cloud::dialogflow::v2::ExportDocumentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -226,6 +249,8 @@ class DefaultDocumentsStub : public DocumentsStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/dialogflow_es/internal/documents_stub_factory.cc b/google/cloud/dialogflow_es/internal/documents_stub_factory.cc index 1d09d13af23f6..60d7ebfd1aabe 100644 --- a/google/cloud/dialogflow_es/internal/documents_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/documents_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,8 +45,10 @@ std::shared_ptr CreateDefaultDocumentsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::Documents::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/dialogflow_es/internal/documents_tracing_connection.cc b/google/cloud/dialogflow_es/internal/documents_tracing_connection.cc index 1e07ceb3024f5..f9b3372b2ac36 100644 --- a/google/cloud/dialogflow_es/internal/documents_tracing_connection.cc +++ b/google/cloud/dialogflow_es/internal/documents_tracing_connection.cc @@ -227,6 +227,26 @@ DocumentsTracingConnection::ExportDocument( return internal::EndSpan(std::move(span), child_->ExportDocument(operation)); } +StreamRange +DocumentsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_es::DocumentsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DocumentsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::DocumentsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_es/internal/documents_tracing_connection.h b/google/cloud/dialogflow_es/internal/documents_tracing_connection.h index 4295d789f8822..db85f752fa824 100644 --- a/google/cloud/dialogflow_es/internal/documents_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/documents_tracing_connection.h @@ -118,6 +118,12 @@ class DocumentsTracingConnection : public dialogflow_es::DocumentsConnection { future> ExportDocument( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_es/internal/documents_tracing_stub.cc b/google/cloud/dialogflow_es/internal/documents_tracing_stub.cc index 00543ac62828d..a0fdaf2aac3e8 100644 --- a/google/cloud/dialogflow_es/internal/documents_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/documents_tracing_stub.cc @@ -211,6 +211,29 @@ StatusOr DocumentsTracingStub::ExportDocument( child_->ExportDocument(context, options, request)); } +StatusOr +DocumentsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Documents", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr DocumentsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Documents", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> DocumentsTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/documents_tracing_stub.h b/google/cloud/dialogflow_es/internal/documents_tracing_stub.h index 3974e495a87ac..ff28add4464a6 100644 --- a/google/cloud/dialogflow_es/internal/documents_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/documents_tracing_stub.h @@ -120,6 +120,14 @@ class DocumentsTracingStub : public DocumentsStub { google::cloud::dialogflow::v2::ExportDocumentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/entity_types_auth_decorator.cc b/google/cloud/dialogflow_es/internal/entity_types_auth_decorator.cc index 879241e07ff27..449caec661465 100644 --- a/google/cloud/dialogflow_es/internal/entity_types_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/entity_types_auth_decorator.cc @@ -221,6 +221,23 @@ StatusOr EntityTypesAuth::BatchDeleteEntities( return child_->BatchDeleteEntities(context, options, request); } +StatusOr +EntityTypesAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr EntityTypesAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> EntityTypesAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/entity_types_auth_decorator.h b/google/cloud/dialogflow_es/internal/entity_types_auth_decorator.h index 5dbba49b50cd0..0a45f82f6591a 100644 --- a/google/cloud/dialogflow_es/internal/entity_types_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/entity_types_auth_decorator.h @@ -124,6 +124,14 @@ class EntityTypesAuth : public EntityTypesStub { google::cloud::dialogflow::v2::BatchDeleteEntitiesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/entity_types_connection_impl.cc b/google/cloud/dialogflow_es/internal/entity_types_connection_impl.cc index a728926158755..084f02687717b 100644 --- a/google/cloud/dialogflow_es/internal/entity_types_connection_impl.cc +++ b/google/cloud/dialogflow_es/internal/entity_types_connection_impl.cc @@ -617,6 +617,54 @@ EntityTypesConnectionImpl::BatchDeleteEntities( polling_policy(*current), __func__); } +StreamRange +EntityTypesConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +EntityTypesConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/entity_types_connection_impl.h b/google/cloud/dialogflow_es/internal/entity_types_connection_impl.h index 1bf72d597b474..b0537bc5b2bf8 100644 --- a/google/cloud/dialogflow_es/internal/entity_types_connection_impl.h +++ b/google/cloud/dialogflow_es/internal/entity_types_connection_impl.h @@ -134,6 +134,12 @@ class EntityTypesConnectionImpl : public dialogflow_es::EntityTypesConnection { future> BatchDeleteEntities( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_es/internal/entity_types_logging_decorator.cc b/google/cloud/dialogflow_es/internal/entity_types_logging_decorator.cc index d0e153e0366d0..1686b4f283972 100644 --- a/google/cloud/dialogflow_es/internal/entity_types_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/entity_types_logging_decorator.cc @@ -263,6 +263,29 @@ EntityTypesLogging::BatchDeleteEntities( context, options, request, __func__, tracing_options_); } +StatusOr +EntityTypesLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EntityTypesLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> EntityTypesLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/entity_types_logging_decorator.h b/google/cloud/dialogflow_es/internal/entity_types_logging_decorator.h index adbcf8a57c19f..a194794b50457 100644 --- a/google/cloud/dialogflow_es/internal/entity_types_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/entity_types_logging_decorator.h @@ -124,6 +124,14 @@ class EntityTypesLogging : public EntityTypesStub { google::cloud::dialogflow::v2::BatchDeleteEntitiesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/entity_types_metadata_decorator.cc b/google/cloud/dialogflow_es/internal/entity_types_metadata_decorator.cc index f80e41b4e84dd..7bb82bac4b012 100644 --- a/google/cloud/dialogflow_es/internal/entity_types_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/entity_types_metadata_decorator.cc @@ -198,6 +198,23 @@ EntityTypesMetadata::BatchDeleteEntities( return child_->BatchDeleteEntities(context, options, request); } +StatusOr +EntityTypesMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr EntityTypesMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> EntityTypesMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/entity_types_metadata_decorator.h b/google/cloud/dialogflow_es/internal/entity_types_metadata_decorator.h index 39241d28a801c..bca7303b9d09f 100644 --- a/google/cloud/dialogflow_es/internal/entity_types_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/entity_types_metadata_decorator.h @@ -124,6 +124,14 @@ class EntityTypesMetadata : public EntityTypesStub { google::cloud::dialogflow::v2::BatchDeleteEntitiesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/entity_types_stub.cc b/google/cloud/dialogflow_es/internal/entity_types_stub.cc index 0b74a6493584b..8cd561ac772ab 100644 --- a/google/cloud/dialogflow_es/internal/entity_types_stub.cc +++ b/google/cloud/dialogflow_es/internal/entity_types_stub.cc @@ -251,6 +251,29 @@ DefaultEntityTypesStub::BatchDeleteEntities( return response; } +StatusOr +DefaultEntityTypesStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultEntityTypesStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultEntityTypesStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/entity_types_stub.h b/google/cloud/dialogflow_es/internal/entity_types_stub.h index ec9100f5c6191..693fdcba87a24 100644 --- a/google/cloud/dialogflow_es/internal/entity_types_stub.h +++ b/google/cloud/dialogflow_es/internal/entity_types_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -128,6 +130,15 @@ class EntityTypesStub { google::cloud::dialogflow::v2::BatchDeleteEntitiesRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -146,9 +157,13 @@ class DefaultEntityTypesStub : public EntityTypesStub { DefaultEntityTypesStub( std::unique_ptr grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListEntityTypes(grpc::ClientContext& context, Options const& options, @@ -235,6 +250,14 @@ class DefaultEntityTypesStub : public EntityTypesStub { google::cloud::dialogflow::v2::BatchDeleteEntitiesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -250,6 +273,8 @@ class DefaultEntityTypesStub : public EntityTypesStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/dialogflow_es/internal/entity_types_stub_factory.cc b/google/cloud/dialogflow_es/internal/entity_types_stub_factory.cc index ca915e58819ce..e4fbf8b9e33c8 100644 --- a/google/cloud/dialogflow_es/internal/entity_types_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/entity_types_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultEntityTypesStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::EntityTypes::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/dialogflow_es/internal/entity_types_tracing_connection.cc b/google/cloud/dialogflow_es/internal/entity_types_tracing_connection.cc index 73bf7841e8cce..4476484224df9 100644 --- a/google/cloud/dialogflow_es/internal/entity_types_tracing_connection.cc +++ b/google/cloud/dialogflow_es/internal/entity_types_tracing_connection.cc @@ -239,6 +239,26 @@ EntityTypesTracingConnection::BatchDeleteEntities( child_->BatchDeleteEntities(operation)); } +StreamRange +EntityTypesTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_es::EntityTypesConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +EntityTypesTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::EntityTypesConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_es/internal/entity_types_tracing_connection.h b/google/cloud/dialogflow_es/internal/entity_types_tracing_connection.h index 819391f621141..07965a0c14400 100644 --- a/google/cloud/dialogflow_es/internal/entity_types_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/entity_types_tracing_connection.h @@ -123,6 +123,12 @@ class EntityTypesTracingConnection future> BatchDeleteEntities( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_es/internal/entity_types_tracing_stub.cc b/google/cloud/dialogflow_es/internal/entity_types_tracing_stub.cc index af2d102ff5865..565e573e6f76c 100644 --- a/google/cloud/dialogflow_es/internal/entity_types_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/entity_types_tracing_stub.cc @@ -232,6 +232,29 @@ EntityTypesTracingStub::BatchDeleteEntities( context, *span, child_->BatchDeleteEntities(context, options, request)); } +StatusOr +EntityTypesTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.EntityTypes", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr EntityTypesTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.EntityTypes", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> EntityTypesTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/entity_types_tracing_stub.h b/google/cloud/dialogflow_es/internal/entity_types_tracing_stub.h index 34125a4d22372..7cf661ec2e718 100644 --- a/google/cloud/dialogflow_es/internal/entity_types_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/entity_types_tracing_stub.h @@ -123,6 +123,14 @@ class EntityTypesTracingStub : public EntityTypesStub { google::cloud::dialogflow::v2::BatchDeleteEntitiesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/environments_auth_decorator.cc b/google/cloud/dialogflow_es/internal/environments_auth_decorator.cc index 048c0e88f27d7..abdccdba18593 100644 --- a/google/cloud/dialogflow_es/internal/environments_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/environments_auth_decorator.cc @@ -85,6 +85,23 @@ EnvironmentsAuth::GetEnvironmentHistory( return child_->GetEnvironmentHistory(context, options, request); } +StatusOr +EnvironmentsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr EnvironmentsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/environments_auth_decorator.h b/google/cloud/dialogflow_es/internal/environments_auth_decorator.h index ec308157d67b7..66e5e18530648 100644 --- a/google/cloud/dialogflow_es/internal/environments_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/environments_auth_decorator.h @@ -69,6 +69,14 @@ class EnvironmentsAuth : public EnvironmentsStub { google::cloud::dialogflow::v2::GetEnvironmentHistoryRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/dialogflow_es/internal/environments_connection_impl.cc b/google/cloud/dialogflow_es/internal/environments_connection_impl.cc index c466af9bc4ef3..b7a7f1f9c550f 100644 --- a/google/cloud/dialogflow_es/internal/environments_connection_impl.cc +++ b/google/cloud/dialogflow_es/internal/environments_connection_impl.cc @@ -188,6 +188,54 @@ EnvironmentsConnectionImpl::GetEnvironmentHistory( }); } +StreamRange +EnvironmentsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +EnvironmentsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/environments_connection_impl.h b/google/cloud/dialogflow_es/internal/environments_connection_impl.h index eb4f87a4fa954..1948eefeb24d0 100644 --- a/google/cloud/dialogflow_es/internal/environments_connection_impl.h +++ b/google/cloud/dialogflow_es/internal/environments_connection_impl.h @@ -73,6 +73,12 @@ class EnvironmentsConnectionImpl google::cloud::dialogflow::v2::GetEnvironmentHistoryRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_es/internal/environments_logging_decorator.cc b/google/cloud/dialogflow_es/internal/environments_logging_decorator.cc index cfcea659ae3ff..073829ae8f69a 100644 --- a/google/cloud/dialogflow_es/internal/environments_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/environments_logging_decorator.cc @@ -113,6 +113,29 @@ EnvironmentsLogging::GetEnvironmentHistory( context, options, request, __func__, tracing_options_); } +StatusOr +EnvironmentsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EnvironmentsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/environments_logging_decorator.h b/google/cloud/dialogflow_es/internal/environments_logging_decorator.h index 0b15a6a853af6..612bbc9f369c8 100644 --- a/google/cloud/dialogflow_es/internal/environments_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/environments_logging_decorator.h @@ -69,6 +69,14 @@ class EnvironmentsLogging : public EnvironmentsStub { google::cloud::dialogflow::v2::GetEnvironmentHistoryRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/dialogflow_es/internal/environments_metadata_decorator.cc b/google/cloud/dialogflow_es/internal/environments_metadata_decorator.cc index a8b64b2e78802..6cb47d7dd7924 100644 --- a/google/cloud/dialogflow_es/internal/environments_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/environments_metadata_decorator.cc @@ -99,6 +99,23 @@ EnvironmentsMetadata::GetEnvironmentHistory( return child_->GetEnvironmentHistory(context, options, request); } +StatusOr +EnvironmentsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr EnvironmentsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void EnvironmentsMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/dialogflow_es/internal/environments_metadata_decorator.h b/google/cloud/dialogflow_es/internal/environments_metadata_decorator.h index 522cd11e37eb0..5cce5f8fd160e 100644 --- a/google/cloud/dialogflow_es/internal/environments_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/environments_metadata_decorator.h @@ -69,6 +69,14 @@ class EnvironmentsMetadata : public EnvironmentsStub { google::cloud::dialogflow::v2::GetEnvironmentHistoryRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/dialogflow_es/internal/environments_stub.cc b/google/cloud/dialogflow_es/internal/environments_stub.cc index 729be1d01f61d..74facf63a42b4 100644 --- a/google/cloud/dialogflow_es/internal/environments_stub.cc +++ b/google/cloud/dialogflow_es/internal/environments_stub.cc @@ -102,6 +102,30 @@ DefaultEnvironmentsStub::GetEnvironmentHistory( return response; } +StatusOr +DefaultEnvironmentsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultEnvironmentsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/environments_stub.h b/google/cloud/dialogflow_es/internal/environments_stub.h index c2f37bd552506..32340c3f0724d 100644 --- a/google/cloud/dialogflow_es/internal/environments_stub.h +++ b/google/cloud/dialogflow_es/internal/environments_stub.h @@ -23,6 +23,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -66,6 +68,15 @@ class EnvironmentsStub { grpc::ClientContext& context, Options const& options, google::cloud::dialogflow::v2::GetEnvironmentHistoryRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultEnvironmentsStub : public EnvironmentsStub { @@ -73,8 +84,11 @@ class DefaultEnvironmentsStub : public EnvironmentsStub { explicit DefaultEnvironmentsStub( std::unique_ptr< google::cloud::dialogflow::v2::Environments::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListEnvironments(grpc::ClientContext& context, Options const& options, @@ -107,9 +121,19 @@ class DefaultEnvironmentsStub : public EnvironmentsStub { google::cloud::dialogflow::v2::GetEnvironmentHistoryRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/internal/environments_stub_factory.cc b/google/cloud/dialogflow_es/internal/environments_stub_factory.cc index e2668b4b3c4d7..faef1b27f4836 100644 --- a/google/cloud/dialogflow_es/internal/environments_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/environments_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,8 +45,11 @@ std::shared_ptr CreateDefaultEnvironmentsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::Environments::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + std::make_shared( + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), std::move(stub)); diff --git a/google/cloud/dialogflow_es/internal/environments_tracing_connection.cc b/google/cloud/dialogflow_es/internal/environments_tracing_connection.cc index f16b5c688a835..081c5fd0d73b5 100644 --- a/google/cloud/dialogflow_es/internal/environments_tracing_connection.cc +++ b/google/cloud/dialogflow_es/internal/environments_tracing_connection.cc @@ -92,6 +92,26 @@ EnvironmentsTracingConnection::GetEnvironmentHistory( std::move(sr)); } +StreamRange +EnvironmentsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_es::EnvironmentsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +EnvironmentsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::EnvironmentsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_es/internal/environments_tracing_connection.h b/google/cloud/dialogflow_es/internal/environments_tracing_connection.h index e7bc3f03d885c..0a880f6e5b0a5 100644 --- a/google/cloud/dialogflow_es/internal/environments_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/environments_tracing_connection.h @@ -64,6 +64,12 @@ class EnvironmentsTracingConnection google::cloud::dialogflow::v2::GetEnvironmentHistoryRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_es/internal/environments_tracing_stub.cc b/google/cloud/dialogflow_es/internal/environments_tracing_stub.cc index 672aa2ea0bfdd..ab03bd735489f 100644 --- a/google/cloud/dialogflow_es/internal/environments_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/environments_tracing_stub.cc @@ -104,6 +104,30 @@ EnvironmentsTracingStub::GetEnvironmentHistory( context, *span, child_->GetEnvironmentHistory(context, options, request)); } +StatusOr +EnvironmentsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Environments", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +EnvironmentsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Environments", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeEnvironmentsTracingStub( diff --git a/google/cloud/dialogflow_es/internal/environments_tracing_stub.h b/google/cloud/dialogflow_es/internal/environments_tracing_stub.h index ebd4f95144214..44ff124a227ad 100644 --- a/google/cloud/dialogflow_es/internal/environments_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/environments_tracing_stub.h @@ -69,6 +69,14 @@ class EnvironmentsTracingStub : public EnvironmentsStub { google::cloud::dialogflow::v2::GetEnvironmentHistoryRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/dialogflow_es/internal/fulfillments_auth_decorator.cc b/google/cloud/dialogflow_es/internal/fulfillments_auth_decorator.cc index 0ffa38d99b27a..8fa616be42e56 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/fulfillments_auth_decorator.cc @@ -49,6 +49,23 @@ FulfillmentsAuth::UpdateFulfillment( return child_->UpdateFulfillment(context, options, request); } +StatusOr +FulfillmentsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr FulfillmentsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/fulfillments_auth_decorator.h b/google/cloud/dialogflow_es/internal/fulfillments_auth_decorator.h index d9298f9857659..0b098a53f6c2a 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/fulfillments_auth_decorator.h @@ -48,6 +48,14 @@ class FulfillmentsAuth : public FulfillmentsStub { google::cloud::dialogflow::v2::UpdateFulfillmentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/dialogflow_es/internal/fulfillments_connection_impl.cc b/google/cloud/dialogflow_es/internal/fulfillments_connection_impl.cc index 0ccc34fdaaad9..207f051cc50fe 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_connection_impl.cc +++ b/google/cloud/dialogflow_es/internal/fulfillments_connection_impl.cc @@ -21,6 +21,7 @@ #include "google/cloud/background_threads.h" #include "google/cloud/common_options.h" #include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/retry_loop.h" #include #include @@ -88,6 +89,54 @@ FulfillmentsConnectionImpl::UpdateFulfillment( *current, request, __func__); } +StreamRange +FulfillmentsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +FulfillmentsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/fulfillments_connection_impl.h b/google/cloud/dialogflow_es/internal/fulfillments_connection_impl.h index 59e92d926e869..6677608318f88 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_connection_impl.h +++ b/google/cloud/dialogflow_es/internal/fulfillments_connection_impl.h @@ -28,6 +28,7 @@ #include "google/cloud/backoff_policy.h" #include "google/cloud/options.h" #include "google/cloud/status_or.h" +#include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include @@ -56,6 +57,12 @@ class FulfillmentsConnectionImpl google::cloud::dialogflow::v2::UpdateFulfillmentRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_es/internal/fulfillments_logging_decorator.cc b/google/cloud/dialogflow_es/internal/fulfillments_logging_decorator.cc index b4adf8faad2ca..68ea9cb997bb3 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/fulfillments_logging_decorator.cc @@ -61,6 +61,29 @@ FulfillmentsLogging::UpdateFulfillment( context, options, request, __func__, tracing_options_); } +StatusOr +FulfillmentsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr FulfillmentsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/fulfillments_logging_decorator.h b/google/cloud/dialogflow_es/internal/fulfillments_logging_decorator.h index 9088338ec262e..93e3a4ba91bfe 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/fulfillments_logging_decorator.h @@ -48,6 +48,14 @@ class FulfillmentsLogging : public FulfillmentsStub { google::cloud::dialogflow::v2::UpdateFulfillmentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/dialogflow_es/internal/fulfillments_metadata_decorator.cc b/google/cloud/dialogflow_es/internal/fulfillments_metadata_decorator.cc index 1032fd938eef2..14d10def39f85 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/fulfillments_metadata_decorator.cc @@ -63,6 +63,23 @@ FulfillmentsMetadata::UpdateFulfillment( return child_->UpdateFulfillment(context, options, request); } +StatusOr +FulfillmentsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr FulfillmentsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void FulfillmentsMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/dialogflow_es/internal/fulfillments_metadata_decorator.h b/google/cloud/dialogflow_es/internal/fulfillments_metadata_decorator.h index b0295df8c62b6..86032f613c76b 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/fulfillments_metadata_decorator.h @@ -48,6 +48,14 @@ class FulfillmentsMetadata : public FulfillmentsStub { google::cloud::dialogflow::v2::UpdateFulfillmentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/dialogflow_es/internal/fulfillments_stub.cc b/google/cloud/dialogflow_es/internal/fulfillments_stub.cc index 4d14a645e568f..ea762e08b5141 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_stub.cc +++ b/google/cloud/dialogflow_es/internal/fulfillments_stub.cc @@ -54,6 +54,30 @@ DefaultFulfillmentsStub::UpdateFulfillment( return response; } +StatusOr +DefaultFulfillmentsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFulfillmentsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/fulfillments_stub.h b/google/cloud/dialogflow_es/internal/fulfillments_stub.h index 3df0396c6dd3d..1e7347f27c358 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_stub.h +++ b/google/cloud/dialogflow_es/internal/fulfillments_stub.h @@ -23,6 +23,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -44,6 +46,15 @@ class FulfillmentsStub { grpc::ClientContext& context, Options const& options, google::cloud::dialogflow::v2::UpdateFulfillmentRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultFulfillmentsStub : public FulfillmentsStub { @@ -51,8 +62,11 @@ class DefaultFulfillmentsStub : public FulfillmentsStub { explicit DefaultFulfillmentsStub( std::unique_ptr< google::cloud::dialogflow::v2::Fulfillments::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr GetFulfillment( grpc::ClientContext& context, Options const& options, @@ -64,9 +78,19 @@ class DefaultFulfillmentsStub : public FulfillmentsStub { google::cloud::dialogflow::v2::UpdateFulfillmentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/internal/fulfillments_stub_factory.cc b/google/cloud/dialogflow_es/internal/fulfillments_stub_factory.cc index 9796bc8ee0f1c..20225f8fbaa29 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/fulfillments_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,8 +45,11 @@ std::shared_ptr CreateDefaultFulfillmentsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::Fulfillments::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + std::make_shared( + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), std::move(stub)); diff --git a/google/cloud/dialogflow_es/internal/fulfillments_tracing_connection.cc b/google/cloud/dialogflow_es/internal/fulfillments_tracing_connection.cc index e850b3095822a..ee3673669a727 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_tracing_connection.cc +++ b/google/cloud/dialogflow_es/internal/fulfillments_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/dialogflow_es/internal/fulfillments_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -50,6 +51,26 @@ FulfillmentsTracingConnection::UpdateFulfillment( return internal::EndSpan(*span, child_->UpdateFulfillment(request)); } +StreamRange +FulfillmentsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_es::FulfillmentsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +FulfillmentsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::FulfillmentsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_es/internal/fulfillments_tracing_connection.h b/google/cloud/dialogflow_es/internal/fulfillments_tracing_connection.h index a6e3063276aa4..3b816a1871292 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/fulfillments_tracing_connection.h @@ -48,6 +48,12 @@ class FulfillmentsTracingConnection google::cloud::dialogflow::v2::UpdateFulfillmentRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_es/internal/fulfillments_tracing_stub.cc b/google/cloud/dialogflow_es/internal/fulfillments_tracing_stub.cc index 902248239da81..a58ac5c6c76cf 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/fulfillments_tracing_stub.cc @@ -56,6 +56,30 @@ FulfillmentsTracingStub::UpdateFulfillment( context, *span, child_->UpdateFulfillment(context, options, request)); } +StatusOr +FulfillmentsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Fulfillments", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +FulfillmentsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Fulfillments", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeFulfillmentsTracingStub( diff --git a/google/cloud/dialogflow_es/internal/fulfillments_tracing_stub.h b/google/cloud/dialogflow_es/internal/fulfillments_tracing_stub.h index ad28d51375e6e..d71bd3969ee63 100644 --- a/google/cloud/dialogflow_es/internal/fulfillments_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/fulfillments_tracing_stub.h @@ -48,6 +48,14 @@ class FulfillmentsTracingStub : public FulfillmentsStub { google::cloud::dialogflow::v2::UpdateFulfillmentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/dialogflow_es/internal/intents_auth_decorator.cc b/google/cloud/dialogflow_es/internal/intents_auth_decorator.cc index 1ecb4709a64ab..d0ebe2cd7fdc9 100644 --- a/google/cloud/dialogflow_es/internal/intents_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/intents_auth_decorator.cc @@ -128,6 +128,23 @@ StatusOr IntentsAuth::BatchDeleteIntents( return child_->BatchDeleteIntents(context, options, request); } +StatusOr +IntentsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr IntentsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> IntentsAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/intents_auth_decorator.h b/google/cloud/dialogflow_es/internal/intents_auth_decorator.h index 18d2ea7dbbef4..5d5d331741a2c 100644 --- a/google/cloud/dialogflow_es/internal/intents_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/intents_auth_decorator.h @@ -86,6 +86,14 @@ class IntentsAuth : public IntentsStub { google::cloud::dialogflow::v2::BatchDeleteIntentsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/intents_connection_impl.cc b/google/cloud/dialogflow_es/internal/intents_connection_impl.cc index 469dee351b72b..8af638a22952a 100644 --- a/google/cloud/dialogflow_es/internal/intents_connection_impl.cc +++ b/google/cloud/dialogflow_es/internal/intents_connection_impl.cc @@ -337,6 +337,53 @@ IntentsConnectionImpl::BatchDeleteIntents( polling_policy(*current), __func__); } +StreamRange +IntentsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr IntentsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/intents_connection_impl.h b/google/cloud/dialogflow_es/internal/intents_connection_impl.h index dd17352353d11..01fcdec636320 100644 --- a/google/cloud/dialogflow_es/internal/intents_connection_impl.h +++ b/google/cloud/dialogflow_es/internal/intents_connection_impl.h @@ -93,6 +93,12 @@ class IntentsConnectionImpl : public dialogflow_es::IntentsConnection { future> BatchDeleteIntents( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_es/internal/intents_logging_decorator.cc b/google/cloud/dialogflow_es/internal/intents_logging_decorator.cc index 764234e2bf5b4..908adeb9a9ac5 100644 --- a/google/cloud/dialogflow_es/internal/intents_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/intents_logging_decorator.cc @@ -156,6 +156,29 @@ StatusOr IntentsLogging::BatchDeleteIntents( context, options, request, __func__, tracing_options_); } +StatusOr +IntentsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr IntentsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> IntentsLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/intents_logging_decorator.h b/google/cloud/dialogflow_es/internal/intents_logging_decorator.h index 1365368cfc8b3..bce2bbbb5b5bd 100644 --- a/google/cloud/dialogflow_es/internal/intents_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/intents_logging_decorator.h @@ -86,6 +86,14 @@ class IntentsLogging : public IntentsStub { google::cloud::dialogflow::v2::BatchDeleteIntentsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/intents_metadata_decorator.cc b/google/cloud/dialogflow_es/internal/intents_metadata_decorator.cc index 46af43d927e72..f8757fa5a5a2d 100644 --- a/google/cloud/dialogflow_es/internal/intents_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/intents_metadata_decorator.cc @@ -126,6 +126,23 @@ StatusOr IntentsMetadata::BatchDeleteIntents( return child_->BatchDeleteIntents(context, options, request); } +StatusOr +IntentsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr IntentsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> IntentsMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/intents_metadata_decorator.h b/google/cloud/dialogflow_es/internal/intents_metadata_decorator.h index 336c228f1e40a..d2cefec5231fa 100644 --- a/google/cloud/dialogflow_es/internal/intents_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/intents_metadata_decorator.h @@ -86,6 +86,14 @@ class IntentsMetadata : public IntentsStub { google::cloud::dialogflow::v2::BatchDeleteIntentsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/intents_stub.cc b/google/cloud/dialogflow_es/internal/intents_stub.cc index 7567845b65c73..b797de2fdd251 100644 --- a/google/cloud/dialogflow_es/internal/intents_stub.cc +++ b/google/cloud/dialogflow_es/internal/intents_stub.cc @@ -149,6 +149,29 @@ StatusOr DefaultIntentsStub::BatchDeleteIntents( return response; } +StatusOr +DefaultIntentsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultIntentsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultIntentsStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/intents_stub.h b/google/cloud/dialogflow_es/internal/intents_stub.h index 23739823ecc8f..9e280c68eff02 100644 --- a/google/cloud/dialogflow_es/internal/intents_stub.h +++ b/google/cloud/dialogflow_es/internal/intents_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -86,6 +88,15 @@ class IntentsStub { google::cloud::dialogflow::v2::BatchDeleteIntentsRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -104,9 +115,13 @@ class DefaultIntentsStub : public IntentsStub { DefaultIntentsStub( std::unique_ptr grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListIntents( grpc::ClientContext& context, Options const& options, @@ -155,6 +170,14 @@ class DefaultIntentsStub : public IntentsStub { google::cloud::dialogflow::v2::BatchDeleteIntentsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -170,6 +193,8 @@ class DefaultIntentsStub : public IntentsStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/dialogflow_es/internal/intents_stub_factory.cc b/google/cloud/dialogflow_es/internal/intents_stub_factory.cc index 818b38891453b..d52771cd00bc9 100644 --- a/google/cloud/dialogflow_es/internal/intents_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/intents_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,8 +45,10 @@ std::shared_ptr CreateDefaultIntentsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::Intents::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/dialogflow_es/internal/intents_tracing_connection.cc b/google/cloud/dialogflow_es/internal/intents_tracing_connection.cc index adea0bcca4a26..7b19850125576 100644 --- a/google/cloud/dialogflow_es/internal/intents_tracing_connection.cc +++ b/google/cloud/dialogflow_es/internal/intents_tracing_connection.cc @@ -140,6 +140,26 @@ IntentsTracingConnection::BatchDeleteIntents( child_->BatchDeleteIntents(operation)); } +StreamRange +IntentsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_es::IntentsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +IntentsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::IntentsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeIntentsTracingConnection( diff --git a/google/cloud/dialogflow_es/internal/intents_tracing_connection.h b/google/cloud/dialogflow_es/internal/intents_tracing_connection.h index 37a6cb9202501..fe22eca84fbf6 100644 --- a/google/cloud/dialogflow_es/internal/intents_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/intents_tracing_connection.h @@ -81,6 +81,12 @@ class IntentsTracingConnection : public dialogflow_es::IntentsConnection { future> BatchDeleteIntents( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_es/internal/intents_tracing_stub.cc b/google/cloud/dialogflow_es/internal/intents_tracing_stub.cc index f841a8b401d0c..00c09ba11d4e9 100644 --- a/google/cloud/dialogflow_es/internal/intents_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/intents_tracing_stub.cc @@ -141,6 +141,29 @@ StatusOr IntentsTracingStub::BatchDeleteIntents( context, *span, child_->BatchDeleteIntents(context, options, request)); } +StatusOr +IntentsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Intents", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr IntentsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Intents", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> IntentsTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/dialogflow_es/internal/intents_tracing_stub.h b/google/cloud/dialogflow_es/internal/intents_tracing_stub.h index 5d01d8ec7f3d6..d993e796b4455 100644 --- a/google/cloud/dialogflow_es/internal/intents_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/intents_tracing_stub.h @@ -85,6 +85,14 @@ class IntentsTracingStub : public IntentsStub { google::cloud::dialogflow::v2::BatchDeleteIntentsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/dialogflow_es/internal/knowledge_bases_auth_decorator.cc b/google/cloud/dialogflow_es/internal/knowledge_bases_auth_decorator.cc index 08ef195dab641..6f4855a3274b2 100644 --- a/google/cloud/dialogflow_es/internal/knowledge_bases_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/knowledge_bases_auth_decorator.cc @@ -75,6 +75,23 @@ KnowledgeBasesAuth::UpdateKnowledgeBase( return child_->UpdateKnowledgeBase(context, options, request); } +StatusOr +KnowledgeBasesAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr KnowledgeBasesAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/knowledge_bases_auth_decorator.h b/google/cloud/dialogflow_es/internal/knowledge_bases_auth_decorator.h index ac1ca053403d8..4110c00cd7fce 100644 --- a/google/cloud/dialogflow_es/internal/knowledge_bases_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/knowledge_bases_auth_decorator.h @@ -64,6 +64,14 @@ class KnowledgeBasesAuth : public KnowledgeBasesStub { google::cloud::dialogflow::v2::UpdateKnowledgeBaseRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/dialogflow_es/internal/knowledge_bases_connection_impl.cc b/google/cloud/dialogflow_es/internal/knowledge_bases_connection_impl.cc index d912c6f3af908..5eb726fb48a4f 100644 --- a/google/cloud/dialogflow_es/internal/knowledge_bases_connection_impl.cc +++ b/google/cloud/dialogflow_es/internal/knowledge_bases_connection_impl.cc @@ -154,6 +154,54 @@ KnowledgeBasesConnectionImpl::UpdateKnowledgeBase( *current, request, __func__); } +StreamRange +KnowledgeBasesConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +KnowledgeBasesConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/knowledge_bases_connection_impl.h b/google/cloud/dialogflow_es/internal/knowledge_bases_connection_impl.h index 46acc6c5cad54..abdfecdedabf2 100644 --- a/google/cloud/dialogflow_es/internal/knowledge_bases_connection_impl.h +++ b/google/cloud/dialogflow_es/internal/knowledge_bases_connection_impl.h @@ -69,6 +69,12 @@ class KnowledgeBasesConnectionImpl google::cloud::dialogflow::v2::UpdateKnowledgeBaseRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_es/internal/knowledge_bases_logging_decorator.cc b/google/cloud/dialogflow_es/internal/knowledge_bases_logging_decorator.cc index bb6db0ab93d71..81a4ba4ad8b64 100644 --- a/google/cloud/dialogflow_es/internal/knowledge_bases_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/knowledge_bases_logging_decorator.cc @@ -99,6 +99,29 @@ KnowledgeBasesLogging::UpdateKnowledgeBase( context, options, request, __func__, tracing_options_); } +StatusOr +KnowledgeBasesLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr KnowledgeBasesLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/knowledge_bases_logging_decorator.h b/google/cloud/dialogflow_es/internal/knowledge_bases_logging_decorator.h index 204df7ebe78d5..77d5db7dc894a 100644 --- a/google/cloud/dialogflow_es/internal/knowledge_bases_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/knowledge_bases_logging_decorator.h @@ -64,6 +64,14 @@ class KnowledgeBasesLogging : public KnowledgeBasesStub { google::cloud::dialogflow::v2::UpdateKnowledgeBaseRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/dialogflow_es/internal/knowledge_bases_metadata_decorator.cc b/google/cloud/dialogflow_es/internal/knowledge_bases_metadata_decorator.cc index 3405268c1682f..d9350a217d7ab 100644 --- a/google/cloud/dialogflow_es/internal/knowledge_bases_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/knowledge_bases_metadata_decorator.cc @@ -90,6 +90,23 @@ KnowledgeBasesMetadata::UpdateKnowledgeBase( return child_->UpdateKnowledgeBase(context, options, request); } +StatusOr +KnowledgeBasesMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr KnowledgeBasesMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void KnowledgeBasesMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/dialogflow_es/internal/knowledge_bases_metadata_decorator.h b/google/cloud/dialogflow_es/internal/knowledge_bases_metadata_decorator.h index 4e0ee0d787c7c..f4b6ba5dd25ae 100644 --- a/google/cloud/dialogflow_es/internal/knowledge_bases_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/knowledge_bases_metadata_decorator.h @@ -64,6 +64,14 @@ class KnowledgeBasesMetadata : public KnowledgeBasesStub { google::cloud::dialogflow::v2::UpdateKnowledgeBaseRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/dialogflow_es/internal/knowledge_bases_stub.cc b/google/cloud/dialogflow_es/internal/knowledge_bases_stub.cc index 2aaae20c3aaca..4078e11171a1c 100644 --- a/google/cloud/dialogflow_es/internal/knowledge_bases_stub.cc +++ b/google/cloud/dialogflow_es/internal/knowledge_bases_stub.cc @@ -89,6 +89,30 @@ DefaultKnowledgeBasesStub::UpdateKnowledgeBase( return response; } +StatusOr +DefaultKnowledgeBasesStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultKnowledgeBasesStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/knowledge_bases_stub.h b/google/cloud/dialogflow_es/internal/knowledge_bases_stub.h index aa5f18b735080..c2c4e40aa5db7 100644 --- a/google/cloud/dialogflow_es/internal/knowledge_bases_stub.h +++ b/google/cloud/dialogflow_es/internal/knowledge_bases_stub.h @@ -23,6 +23,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -62,6 +64,15 @@ class KnowledgeBasesStub { grpc::ClientContext& context, Options const& options, google::cloud::dialogflow::v2::UpdateKnowledgeBaseRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultKnowledgeBasesStub : public KnowledgeBasesStub { @@ -69,8 +80,11 @@ class DefaultKnowledgeBasesStub : public KnowledgeBasesStub { explicit DefaultKnowledgeBasesStub( std::unique_ptr< google::cloud::dialogflow::v2::KnowledgeBases::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListKnowledgeBases( @@ -98,9 +112,19 @@ class DefaultKnowledgeBasesStub : public KnowledgeBasesStub { google::cloud::dialogflow::v2::UpdateKnowledgeBaseRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/internal/knowledge_bases_stub_factory.cc b/google/cloud/dialogflow_es/internal/knowledge_bases_stub_factory.cc index 5ef8b3df44829..5cca9252dacde 100644 --- a/google/cloud/dialogflow_es/internal/knowledge_bases_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/knowledge_bases_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,8 +45,11 @@ std::shared_ptr CreateDefaultKnowledgeBasesStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::KnowledgeBases::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + std::make_shared( + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = diff --git a/google/cloud/dialogflow_es/internal/knowledge_bases_tracing_connection.cc b/google/cloud/dialogflow_es/internal/knowledge_bases_tracing_connection.cc index 4abbff4e4d61c..ee881cd14c81e 100644 --- a/google/cloud/dialogflow_es/internal/knowledge_bases_tracing_connection.cc +++ b/google/cloud/dialogflow_es/internal/knowledge_bases_tracing_connection.cc @@ -80,6 +80,26 @@ KnowledgeBasesTracingConnection::UpdateKnowledgeBase( return internal::EndSpan(*span, child_->UpdateKnowledgeBase(request)); } +StreamRange +KnowledgeBasesTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_es::KnowledgeBasesConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +KnowledgeBasesTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_es::KnowledgeBasesConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_es/internal/knowledge_bases_tracing_connection.h b/google/cloud/dialogflow_es/internal/knowledge_bases_tracing_connection.h index 565d24b1160e3..17e5d29610aec 100644 --- a/google/cloud/dialogflow_es/internal/knowledge_bases_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/knowledge_bases_tracing_connection.h @@ -60,6 +60,12 @@ class KnowledgeBasesTracingConnection google::cloud::dialogflow::v2::UpdateKnowledgeBaseRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_es/internal/knowledge_bases_tracing_stub.cc b/google/cloud/dialogflow_es/internal/knowledge_bases_tracing_stub.cc index 6abbb31515643..4fb0259bc35fb 100644 --- a/google/cloud/dialogflow_es/internal/knowledge_bases_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/knowledge_bases_tracing_stub.cc @@ -91,6 +91,30 @@ KnowledgeBasesTracingStub::UpdateKnowledgeBase( context, *span, child_->UpdateKnowledgeBase(context, options, request)); } +StatusOr +KnowledgeBasesTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.v2.KnowledgeBases", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +KnowledgeBasesTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.v2.KnowledgeBases", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeKnowledgeBasesTracingStub( diff --git a/google/cloud/dialogflow_es/internal/knowledge_bases_tracing_stub.h b/google/cloud/dialogflow_es/internal/knowledge_bases_tracing_stub.h index 46b52d7914326..6b639a0cd4e0e 100644 --- a/google/cloud/dialogflow_es/internal/knowledge_bases_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/knowledge_bases_tracing_stub.h @@ -64,6 +64,14 @@ class KnowledgeBasesTracingStub : public KnowledgeBasesStub { google::cloud::dialogflow::v2::UpdateKnowledgeBaseRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/dialogflow_es/internal/participants_auth_decorator.cc b/google/cloud/dialogflow_es/internal/participants_auth_decorator.cc index af34ac11ef702..ee176c3e14be3 100644 --- a/google/cloud/dialogflow_es/internal/participants_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/participants_auth_decorator.cc @@ -133,6 +133,23 @@ ParticipantsAuth::SuggestKnowledgeAssist( return child_->SuggestKnowledgeAssist(context, options, request); } +StatusOr +ParticipantsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr ParticipantsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/participants_auth_decorator.h b/google/cloud/dialogflow_es/internal/participants_auth_decorator.h index c60fd2d7134ca..b9a598577e30c 100644 --- a/google/cloud/dialogflow_es/internal/participants_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/participants_auth_decorator.h @@ -94,6 +94,14 @@ class ParticipantsAuth : public ParticipantsStub { google::cloud::dialogflow::v2::SuggestKnowledgeAssistRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/dialogflow_es/internal/participants_connection_impl.cc b/google/cloud/dialogflow_es/internal/participants_connection_impl.cc index 19cd4b3666642..070433d470406 100644 --- a/google/cloud/dialogflow_es/internal/participants_connection_impl.cc +++ b/google/cloud/dialogflow_es/internal/participants_connection_impl.cc @@ -223,6 +223,54 @@ ParticipantsConnectionImpl::SuggestKnowledgeAssist( *current, request, __func__); } +StreamRange +ParticipantsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ParticipantsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/participants_connection_impl.h b/google/cloud/dialogflow_es/internal/participants_connection_impl.h index 775d85f543c7c..5b27cb33a4875 100644 --- a/google/cloud/dialogflow_es/internal/participants_connection_impl.h +++ b/google/cloud/dialogflow_es/internal/participants_connection_impl.h @@ -93,6 +93,12 @@ class ParticipantsConnectionImpl google::cloud::dialogflow::v2::SuggestKnowledgeAssistRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_es/internal/participants_logging_decorator.cc b/google/cloud/dialogflow_es/internal/participants_logging_decorator.cc index d7497d72d3dca..c15e2351b29a3 100644 --- a/google/cloud/dialogflow_es/internal/participants_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/participants_logging_decorator.cc @@ -179,6 +179,29 @@ ParticipantsLogging::SuggestKnowledgeAssist( context, options, request, __func__, tracing_options_); } +StatusOr +ParticipantsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ParticipantsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/participants_logging_decorator.h b/google/cloud/dialogflow_es/internal/participants_logging_decorator.h index b72cc15a44dbb..c782fdea4aac2 100644 --- a/google/cloud/dialogflow_es/internal/participants_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/participants_logging_decorator.h @@ -94,6 +94,14 @@ class ParticipantsLogging : public ParticipantsStub { google::cloud::dialogflow::v2::SuggestKnowledgeAssistRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/dialogflow_es/internal/participants_metadata_decorator.cc b/google/cloud/dialogflow_es/internal/participants_metadata_decorator.cc index 5402a02feb6f0..ad8ac7e7dc370 100644 --- a/google/cloud/dialogflow_es/internal/participants_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/participants_metadata_decorator.cc @@ -140,6 +140,23 @@ ParticipantsMetadata::SuggestKnowledgeAssist( return child_->SuggestKnowledgeAssist(context, options, request); } +StatusOr +ParticipantsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr ParticipantsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void ParticipantsMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/dialogflow_es/internal/participants_metadata_decorator.h b/google/cloud/dialogflow_es/internal/participants_metadata_decorator.h index 2a67ff54432dd..1506e3632a284 100644 --- a/google/cloud/dialogflow_es/internal/participants_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/participants_metadata_decorator.h @@ -94,6 +94,14 @@ class ParticipantsMetadata : public ParticipantsStub { google::cloud::dialogflow::v2::SuggestKnowledgeAssistRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/dialogflow_es/internal/participants_stub.cc b/google/cloud/dialogflow_es/internal/participants_stub.cc index d16c7982b79c2..e716381f79b67 100644 --- a/google/cloud/dialogflow_es/internal/participants_stub.cc +++ b/google/cloud/dialogflow_es/internal/participants_stub.cc @@ -157,6 +157,30 @@ DefaultParticipantsStub::SuggestKnowledgeAssist( return response; } +StatusOr +DefaultParticipantsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultParticipantsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/participants_stub.h b/google/cloud/dialogflow_es/internal/participants_stub.h index a75cec5886581..e9ab4443c4689 100644 --- a/google/cloud/dialogflow_es/internal/participants_stub.h +++ b/google/cloud/dialogflow_es/internal/participants_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -94,6 +96,15 @@ class ParticipantsStub { grpc::ClientContext& context, Options const& options, google::cloud::dialogflow::v2::SuggestKnowledgeAssistRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultParticipantsStub : public ParticipantsStub { @@ -101,8 +112,11 @@ class DefaultParticipantsStub : public ParticipantsStub { explicit DefaultParticipantsStub( std::unique_ptr< google::cloud::dialogflow::v2::Participants::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr CreateParticipant( grpc::ClientContext& context, Options const& options, @@ -160,9 +174,19 @@ class DefaultParticipantsStub : public ParticipantsStub { google::cloud::dialogflow::v2::SuggestKnowledgeAssistRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/internal/participants_stub_factory.cc b/google/cloud/dialogflow_es/internal/participants_stub_factory.cc index f8687eb2b880b..11c6c83bc391b 100644 --- a/google/cloud/dialogflow_es/internal/participants_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/participants_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,8 +45,11 @@ std::shared_ptr CreateDefaultParticipantsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::Participants::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + std::make_shared( + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), std::move(stub)); diff --git a/google/cloud/dialogflow_es/internal/participants_tracing_connection.cc b/google/cloud/dialogflow_es/internal/participants_tracing_connection.cc index 0366a4ac74c72..687b6180dee63 100644 --- a/google/cloud/dialogflow_es/internal/participants_tracing_connection.cc +++ b/google/cloud/dialogflow_es/internal/participants_tracing_connection.cc @@ -125,6 +125,26 @@ ParticipantsTracingConnection::SuggestKnowledgeAssist( return internal::EndSpan(*span, child_->SuggestKnowledgeAssist(request)); } +StreamRange +ParticipantsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_es::ParticipantsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ParticipantsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::ParticipantsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_es/internal/participants_tracing_connection.h b/google/cloud/dialogflow_es/internal/participants_tracing_connection.h index d9f0af53f6a33..a233451af244a 100644 --- a/google/cloud/dialogflow_es/internal/participants_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/participants_tracing_connection.h @@ -83,6 +83,12 @@ class ParticipantsTracingConnection google::cloud::dialogflow::v2::SuggestKnowledgeAssistRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_es/internal/participants_tracing_stub.cc b/google/cloud/dialogflow_es/internal/participants_tracing_stub.cc index f0974580d5e77..b43e8e673d844 100644 --- a/google/cloud/dialogflow_es/internal/participants_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/participants_tracing_stub.cc @@ -161,6 +161,30 @@ ParticipantsTracingStub::SuggestKnowledgeAssist( child_->SuggestKnowledgeAssist(context, options, request)); } +StatusOr +ParticipantsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Participants", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +ParticipantsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Participants", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeParticipantsTracingStub( diff --git a/google/cloud/dialogflow_es/internal/participants_tracing_stub.h b/google/cloud/dialogflow_es/internal/participants_tracing_stub.h index 5c21343e653da..32a4ec67189f6 100644 --- a/google/cloud/dialogflow_es/internal/participants_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/participants_tracing_stub.h @@ -94,6 +94,14 @@ class ParticipantsTracingStub : public ParticipantsStub { google::cloud::dialogflow::v2::SuggestKnowledgeAssistRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/dialogflow_es/internal/session_entity_types_auth_decorator.cc b/google/cloud/dialogflow_es/internal/session_entity_types_auth_decorator.cc index 0519969a9851a..c9d7ee6b0e0ce 100644 --- a/google/cloud/dialogflow_es/internal/session_entity_types_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/session_entity_types_auth_decorator.cc @@ -79,6 +79,23 @@ Status SessionEntityTypesAuth::DeleteSessionEntityType( return child_->DeleteSessionEntityType(context, options, request); } +StatusOr +SessionEntityTypesAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr SessionEntityTypesAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/session_entity_types_auth_decorator.h b/google/cloud/dialogflow_es/internal/session_entity_types_auth_decorator.h index a6cf0fc6406b2..ed69736357d84 100644 --- a/google/cloud/dialogflow_es/internal/session_entity_types_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/session_entity_types_auth_decorator.h @@ -67,6 +67,14 @@ class SessionEntityTypesAuth : public SessionEntityTypesStub { google::cloud::dialogflow::v2::DeleteSessionEntityTypeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/dialogflow_es/internal/session_entity_types_connection_impl.cc b/google/cloud/dialogflow_es/internal/session_entity_types_connection_impl.cc index 6b9e120795ea9..ea007e4fd696c 100644 --- a/google/cloud/dialogflow_es/internal/session_entity_types_connection_impl.cc +++ b/google/cloud/dialogflow_es/internal/session_entity_types_connection_impl.cc @@ -162,6 +162,54 @@ Status SessionEntityTypesConnectionImpl::DeleteSessionEntityType( *current, request, __func__); } +StreamRange +SessionEntityTypesConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +SessionEntityTypesConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/session_entity_types_connection_impl.h b/google/cloud/dialogflow_es/internal/session_entity_types_connection_impl.h index 36b08f3a4bc7a..8817e2d4591bc 100644 --- a/google/cloud/dialogflow_es/internal/session_entity_types_connection_impl.h +++ b/google/cloud/dialogflow_es/internal/session_entity_types_connection_impl.h @@ -73,6 +73,12 @@ class SessionEntityTypesConnectionImpl google::cloud::dialogflow::v2::DeleteSessionEntityTypeRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_es/internal/session_entity_types_logging_decorator.cc b/google/cloud/dialogflow_es/internal/session_entity_types_logging_decorator.cc index 6495d89a8385f..d6c1aa6ced1fd 100644 --- a/google/cloud/dialogflow_es/internal/session_entity_types_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/session_entity_types_logging_decorator.cc @@ -106,6 +106,30 @@ Status SessionEntityTypesLogging::DeleteSessionEntityType( context, options, request, __func__, tracing_options_); } +StatusOr +SessionEntityTypesLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +SessionEntityTypesLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/session_entity_types_logging_decorator.h b/google/cloud/dialogflow_es/internal/session_entity_types_logging_decorator.h index 977201bd5994b..1eda6a7351363 100644 --- a/google/cloud/dialogflow_es/internal/session_entity_types_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/session_entity_types_logging_decorator.h @@ -67,6 +67,14 @@ class SessionEntityTypesLogging : public SessionEntityTypesStub { google::cloud::dialogflow::v2::DeleteSessionEntityTypeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/dialogflow_es/internal/session_entity_types_metadata_decorator.cc b/google/cloud/dialogflow_es/internal/session_entity_types_metadata_decorator.cc index b1925969fd9ee..214d15efab093 100644 --- a/google/cloud/dialogflow_es/internal/session_entity_types_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/session_entity_types_metadata_decorator.cc @@ -94,6 +94,24 @@ Status SessionEntityTypesMetadata::DeleteSessionEntityType( return child_->DeleteSessionEntityType(context, options, request); } +StatusOr +SessionEntityTypesMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +SessionEntityTypesMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void SessionEntityTypesMetadata::SetMetadata( grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/dialogflow_es/internal/session_entity_types_metadata_decorator.h b/google/cloud/dialogflow_es/internal/session_entity_types_metadata_decorator.h index 5bbc94cd6c4b8..602666bef1252 100644 --- a/google/cloud/dialogflow_es/internal/session_entity_types_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/session_entity_types_metadata_decorator.h @@ -68,6 +68,14 @@ class SessionEntityTypesMetadata : public SessionEntityTypesStub { google::cloud::dialogflow::v2::DeleteSessionEntityTypeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/dialogflow_es/internal/session_entity_types_stub.cc b/google/cloud/dialogflow_es/internal/session_entity_types_stub.cc index e4e1d7c0fc845..a4f1084f202ac 100644 --- a/google/cloud/dialogflow_es/internal/session_entity_types_stub.cc +++ b/google/cloud/dialogflow_es/internal/session_entity_types_stub.cc @@ -97,6 +97,30 @@ Status DefaultSessionEntityTypesStub::DeleteSessionEntityType( return google::cloud::Status(); } +StatusOr +DefaultSessionEntityTypesStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultSessionEntityTypesStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/session_entity_types_stub.h b/google/cloud/dialogflow_es/internal/session_entity_types_stub.h index 0f1293dc2011f..f6f5e072a564f 100644 --- a/google/cloud/dialogflow_es/internal/session_entity_types_stub.h +++ b/google/cloud/dialogflow_es/internal/session_entity_types_stub.h @@ -23,6 +23,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -64,6 +66,15 @@ class SessionEntityTypesStub { grpc::ClientContext& context, Options const& options, google::cloud::dialogflow::v2::DeleteSessionEntityTypeRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultSessionEntityTypesStub : public SessionEntityTypesStub { @@ -71,8 +82,11 @@ class DefaultSessionEntityTypesStub : public SessionEntityTypesStub { explicit DefaultSessionEntityTypesStub( std::unique_ptr< google::cloud::dialogflow::v2::SessionEntityTypes::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListSessionEntityTypes( @@ -103,10 +117,20 @@ class DefaultSessionEntityTypesStub : public SessionEntityTypesStub { google::cloud::dialogflow::v2::DeleteSessionEntityTypeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr< google::cloud::dialogflow::v2::SessionEntityTypes::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/internal/session_entity_types_stub_factory.cc b/google/cloud/dialogflow_es/internal/session_entity_types_stub_factory.cc index 860a62dc4bca4..ad538c2c371fe 100644 --- a/google/cloud/dialogflow_es/internal/session_entity_types_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/session_entity_types_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultSessionEntityTypesStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::SessionEntityTypes::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/dialogflow_es/internal/session_entity_types_tracing_connection.cc b/google/cloud/dialogflow_es/internal/session_entity_types_tracing_connection.cc index 946524750dda0..b27813b6b8388 100644 --- a/google/cloud/dialogflow_es/internal/session_entity_types_tracing_connection.cc +++ b/google/cloud/dialogflow_es/internal/session_entity_types_tracing_connection.cc @@ -83,6 +83,26 @@ Status SessionEntityTypesTracingConnection::DeleteSessionEntityType( return internal::EndSpan(*span, child_->DeleteSessionEntityType(request)); } +StreamRange +SessionEntityTypesTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "dialogflow_es::SessionEntityTypesConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SessionEntityTypesTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "dialogflow_es::SessionEntityTypesConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_es/internal/session_entity_types_tracing_connection.h b/google/cloud/dialogflow_es/internal/session_entity_types_tracing_connection.h index 3e5c88959a65c..9348f8b11bd3d 100644 --- a/google/cloud/dialogflow_es/internal/session_entity_types_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/session_entity_types_tracing_connection.h @@ -64,6 +64,12 @@ class SessionEntityTypesTracingConnection google::cloud::dialogflow::v2::DeleteSessionEntityTypeRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_es/internal/session_entity_types_tracing_stub.cc b/google/cloud/dialogflow_es/internal/session_entity_types_tracing_stub.cc index 60bf0dc4a6891..52de3c1a7b275 100644 --- a/google/cloud/dialogflow_es/internal/session_entity_types_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/session_entity_types_tracing_stub.cc @@ -103,6 +103,30 @@ Status SessionEntityTypesTracingStub::DeleteSessionEntityType( child_->DeleteSessionEntityType(context, options, request)); } +StatusOr +SessionEntityTypesTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.v2.SessionEntityTypes", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +SessionEntityTypesTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.dialogflow.v2.SessionEntityTypes", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeSessionEntityTypesTracingStub( diff --git a/google/cloud/dialogflow_es/internal/session_entity_types_tracing_stub.h b/google/cloud/dialogflow_es/internal/session_entity_types_tracing_stub.h index 9ca42f724cf77..f8868cf19ab60 100644 --- a/google/cloud/dialogflow_es/internal/session_entity_types_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/session_entity_types_tracing_stub.h @@ -68,6 +68,14 @@ class SessionEntityTypesTracingStub : public SessionEntityTypesStub { google::cloud::dialogflow::v2::DeleteSessionEntityTypeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/dialogflow_es/internal/sessions_auth_decorator.cc b/google/cloud/dialogflow_es/internal/sessions_auth_decorator.cc index 52a296bfc5fb2..9dc8d4cee7c61 100644 --- a/google/cloud/dialogflow_es/internal/sessions_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/sessions_auth_decorator.cc @@ -60,6 +60,23 @@ SessionsAuth::AsyncStreamingDetectIntent( std::move(context), auth_, StreamAuth::StreamFactory(std::move(call))); } +StatusOr +SessionsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr SessionsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/sessions_auth_decorator.h b/google/cloud/dialogflow_es/internal/sessions_auth_decorator.h index eff92d478cb7e..5635855ae331f 100644 --- a/google/cloud/dialogflow_es/internal/sessions_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/sessions_auth_decorator.h @@ -51,6 +51,14 @@ class SessionsAuth : public SessionsStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/dialogflow_es/internal/sessions_connection_impl.cc b/google/cloud/dialogflow_es/internal/sessions_connection_impl.cc index 78a40203881f4..b0d41e75f6d7d 100644 --- a/google/cloud/dialogflow_es/internal/sessions_connection_impl.cc +++ b/google/cloud/dialogflow_es/internal/sessions_connection_impl.cc @@ -21,6 +21,7 @@ #include "google/cloud/background_threads.h" #include "google/cloud/common_options.h" #include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/retry_loop.h" #include #include @@ -81,6 +82,53 @@ SessionsConnectionImpl::AsyncStreamingDetectIntent() { internal::SaveCurrentOptions()); } +StreamRange +SessionsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr SessionsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/sessions_connection_impl.h b/google/cloud/dialogflow_es/internal/sessions_connection_impl.h index f9775f1b45644..2e64de5f7f2c5 100644 --- a/google/cloud/dialogflow_es/internal/sessions_connection_impl.h +++ b/google/cloud/dialogflow_es/internal/sessions_connection_impl.h @@ -29,6 +29,7 @@ #include "google/cloud/backoff_policy.h" #include "google/cloud/options.h" #include "google/cloud/status_or.h" +#include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include @@ -57,6 +58,12 @@ class SessionsConnectionImpl : public dialogflow_es::SessionsConnection { google::cloud::dialogflow::v2::StreamingDetectIntentResponse>> AsyncStreamingDetectIntent() override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_es/internal/sessions_logging_decorator.cc b/google/cloud/dialogflow_es/internal/sessions_logging_decorator.cc index bb28fc096eea6..c468627defefc 100644 --- a/google/cloud/dialogflow_es/internal/sessions_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/sessions_logging_decorator.cc @@ -74,6 +74,29 @@ SessionsLogging::AsyncStreamingDetectIntent( return stream; } +StatusOr +SessionsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr SessionsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/sessions_logging_decorator.h b/google/cloud/dialogflow_es/internal/sessions_logging_decorator.h index 490b24bc83aea..466e424608975 100644 --- a/google/cloud/dialogflow_es/internal/sessions_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/sessions_logging_decorator.h @@ -51,6 +51,14 @@ class SessionsLogging : public SessionsStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/dialogflow_es/internal/sessions_metadata_decorator.cc b/google/cloud/dialogflow_es/internal/sessions_metadata_decorator.cc index 6ade403142136..2e1d9fc7574cd 100644 --- a/google/cloud/dialogflow_es/internal/sessions_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/sessions_metadata_decorator.cc @@ -65,6 +65,23 @@ SessionsMetadata::AsyncStreamingDetectIntent( std::move(options)); } +StatusOr +SessionsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr SessionsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void SessionsMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/dialogflow_es/internal/sessions_metadata_decorator.h b/google/cloud/dialogflow_es/internal/sessions_metadata_decorator.h index bc13eaa426d33..2b1593d3df16c 100644 --- a/google/cloud/dialogflow_es/internal/sessions_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/sessions_metadata_decorator.h @@ -51,6 +51,14 @@ class SessionsMetadata : public SessionsStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/dialogflow_es/internal/sessions_stub.cc b/google/cloud/dialogflow_es/internal/sessions_stub.cc index 9df85c2260ffc..4592ce93cfe34 100644 --- a/google/cloud/dialogflow_es/internal/sessions_stub.cc +++ b/google/cloud/dialogflow_es/internal/sessions_stub.cc @@ -59,6 +59,29 @@ DefaultSessionsStub::AsyncStreamingDetectIntent( }); } +StatusOr +DefaultSessionsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultSessionsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/sessions_stub.h b/google/cloud/dialogflow_es/internal/sessions_stub.h index 13c35c29a8147..f7ce6ec0c0c67 100644 --- a/google/cloud/dialogflow_es/internal/sessions_stub.h +++ b/google/cloud/dialogflow_es/internal/sessions_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -49,14 +51,26 @@ class SessionsStub { google::cloud::CompletionQueue const& cq, std::shared_ptr context, google::cloud::internal::ImmutableOptions options) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultSessionsStub : public SessionsStub { public: explicit DefaultSessionsStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr DetectIntent( grpc::ClientContext& context, Options const& options, @@ -71,9 +85,19 @@ class DefaultSessionsStub : public SessionsStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/internal/sessions_stub_factory.cc b/google/cloud/dialogflow_es/internal/sessions_stub_factory.cc index 73f430404803f..89b64371574bb 100644 --- a/google/cloud/dialogflow_es/internal/sessions_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/sessions_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,8 +45,10 @@ std::shared_ptr CreateDefaultSessionsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::Sessions::NewStub(channel); - std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); + std::shared_ptr stub = std::make_shared( + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), std::move(stub)); diff --git a/google/cloud/dialogflow_es/internal/sessions_tracing_connection.cc b/google/cloud/dialogflow_es/internal/sessions_tracing_connection.cc index 78e697784a5ee..8c6745efe0055 100644 --- a/google/cloud/dialogflow_es/internal/sessions_tracing_connection.cc +++ b/google/cloud/dialogflow_es/internal/sessions_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/dialogflow_es/internal/sessions_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -48,6 +49,26 @@ SessionsTracingConnection::AsyncStreamingDetectIntent() { return child_->AsyncStreamingDetectIntent(); } +StreamRange +SessionsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_es::SessionsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SessionsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::SessionsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_es/internal/sessions_tracing_connection.h b/google/cloud/dialogflow_es/internal/sessions_tracing_connection.h index a8a863c0ce385..600d201e43338 100644 --- a/google/cloud/dialogflow_es/internal/sessions_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/sessions_tracing_connection.h @@ -48,6 +48,12 @@ class SessionsTracingConnection : public dialogflow_es::SessionsConnection { google::cloud::dialogflow::v2::StreamingDetectIntentResponse>> AsyncStreamingDetectIntent() override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_es/internal/sessions_tracing_stub.cc b/google/cloud/dialogflow_es/internal/sessions_tracing_stub.cc index 7b49a117c1bb0..637fa39e577f7 100644 --- a/google/cloud/dialogflow_es/internal/sessions_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/sessions_tracing_stub.cc @@ -62,6 +62,29 @@ SessionsTracingStub::AsyncStreamingDetectIntent( std::move(context), std::move(stream), std::move(span)); } +StatusOr +SessionsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Sessions", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr SessionsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Sessions", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeSessionsTracingStub( diff --git a/google/cloud/dialogflow_es/internal/sessions_tracing_stub.h b/google/cloud/dialogflow_es/internal/sessions_tracing_stub.h index 6e611aa806d21..d8c5a05b3fb42 100644 --- a/google/cloud/dialogflow_es/internal/sessions_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/sessions_tracing_stub.h @@ -51,6 +51,14 @@ class SessionsTracingStub : public SessionsStub { std::shared_ptr context, google::cloud::internal::ImmutableOptions options) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/dialogflow_es/internal/versions_auth_decorator.cc b/google/cloud/dialogflow_es/internal/versions_auth_decorator.cc index fc4feb55061e1..bb42f0a22c9c7 100644 --- a/google/cloud/dialogflow_es/internal/versions_auth_decorator.cc +++ b/google/cloud/dialogflow_es/internal/versions_auth_decorator.cc @@ -72,6 +72,23 @@ Status VersionsAuth::DeleteVersion( return child_->DeleteVersion(context, options, request); } +StatusOr +VersionsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr VersionsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/versions_auth_decorator.h b/google/cloud/dialogflow_es/internal/versions_auth_decorator.h index 9a0ea42be4f9a..b203dffb4a572 100644 --- a/google/cloud/dialogflow_es/internal/versions_auth_decorator.h +++ b/google/cloud/dialogflow_es/internal/versions_auth_decorator.h @@ -62,6 +62,14 @@ class VersionsAuth : public VersionsStub { google::cloud::dialogflow::v2::DeleteVersionRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/dialogflow_es/internal/versions_connection_impl.cc b/google/cloud/dialogflow_es/internal/versions_connection_impl.cc index 88ee0a3391e9c..b3c9ce7612256 100644 --- a/google/cloud/dialogflow_es/internal/versions_connection_impl.cc +++ b/google/cloud/dialogflow_es/internal/versions_connection_impl.cc @@ -150,6 +150,53 @@ Status VersionsConnectionImpl::DeleteVersion( *current, request, __func__); } +StreamRange +VersionsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr VersionsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/versions_connection_impl.h b/google/cloud/dialogflow_es/internal/versions_connection_impl.h index 755f787ee2beb..cc21a56966ae8 100644 --- a/google/cloud/dialogflow_es/internal/versions_connection_impl.h +++ b/google/cloud/dialogflow_es/internal/versions_connection_impl.h @@ -66,6 +66,12 @@ class VersionsConnectionImpl : public dialogflow_es::VersionsConnection { google::cloud::dialogflow::v2::DeleteVersionRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/dialogflow_es/internal/versions_logging_decorator.cc b/google/cloud/dialogflow_es/internal/versions_logging_decorator.cc index 2da0b2a488779..001b942ff4da0 100644 --- a/google/cloud/dialogflow_es/internal/versions_logging_decorator.cc +++ b/google/cloud/dialogflow_es/internal/versions_logging_decorator.cc @@ -95,6 +95,29 @@ Status VersionsLogging::DeleteVersion( context, options, request, __func__, tracing_options_); } +StatusOr +VersionsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr VersionsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/versions_logging_decorator.h b/google/cloud/dialogflow_es/internal/versions_logging_decorator.h index d6d394cde02b2..02a2a51181c81 100644 --- a/google/cloud/dialogflow_es/internal/versions_logging_decorator.h +++ b/google/cloud/dialogflow_es/internal/versions_logging_decorator.h @@ -62,6 +62,14 @@ class VersionsLogging : public VersionsStub { google::cloud::dialogflow::v2::DeleteVersionRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/dialogflow_es/internal/versions_metadata_decorator.cc b/google/cloud/dialogflow_es/internal/versions_metadata_decorator.cc index b90e50ebe77cb..589448605154f 100644 --- a/google/cloud/dialogflow_es/internal/versions_metadata_decorator.cc +++ b/google/cloud/dialogflow_es/internal/versions_metadata_decorator.cc @@ -88,6 +88,23 @@ Status VersionsMetadata::DeleteVersion( return child_->DeleteVersion(context, options, request); } +StatusOr +VersionsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr VersionsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void VersionsMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/dialogflow_es/internal/versions_metadata_decorator.h b/google/cloud/dialogflow_es/internal/versions_metadata_decorator.h index 128e466f7e346..3449f056f3b3c 100644 --- a/google/cloud/dialogflow_es/internal/versions_metadata_decorator.h +++ b/google/cloud/dialogflow_es/internal/versions_metadata_decorator.h @@ -62,6 +62,14 @@ class VersionsMetadata : public VersionsStub { google::cloud::dialogflow::v2::DeleteVersionRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/dialogflow_es/internal/versions_stub.cc b/google/cloud/dialogflow_es/internal/versions_stub.cc index dce18fecd0be5..417fb2c6300bb 100644 --- a/google/cloud/dialogflow_es/internal/versions_stub.cc +++ b/google/cloud/dialogflow_es/internal/versions_stub.cc @@ -89,6 +89,29 @@ Status DefaultVersionsStub::DeleteVersion( return google::cloud::Status(); } +StatusOr +DefaultVersionsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultVersionsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es_internal } // namespace cloud diff --git a/google/cloud/dialogflow_es/internal/versions_stub.h b/google/cloud/dialogflow_es/internal/versions_stub.h index e6c8aad79b749..9697175d49ed7 100644 --- a/google/cloud/dialogflow_es/internal/versions_stub.h +++ b/google/cloud/dialogflow_es/internal/versions_stub.h @@ -23,6 +23,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include @@ -55,14 +57,26 @@ class VersionsStub { virtual Status DeleteVersion( grpc::ClientContext& context, Options const& options, google::cloud::dialogflow::v2::DeleteVersionRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultVersionsStub : public VersionsStub { public: explicit DefaultVersionsStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListVersions( grpc::ClientContext& context, Options const& options, @@ -88,9 +102,19 @@ class DefaultVersionsStub : public VersionsStub { google::cloud::dialogflow::v2::DeleteVersionRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/internal/versions_stub_factory.cc b/google/cloud/dialogflow_es/internal/versions_stub_factory.cc index 205439d71a861..60d01ac3cb533 100644 --- a/google/cloud/dialogflow_es/internal/versions_stub_factory.cc +++ b/google/cloud/dialogflow_es/internal/versions_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,8 +45,10 @@ std::shared_ptr CreateDefaultVersionsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::dialogflow::v2::Versions::NewStub(channel); - std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); + std::shared_ptr stub = std::make_shared( + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), std::move(stub)); diff --git a/google/cloud/dialogflow_es/internal/versions_tracing_connection.cc b/google/cloud/dialogflow_es/internal/versions_tracing_connection.cc index 345ba16278da1..dab6a08006e7b 100644 --- a/google/cloud/dialogflow_es/internal/versions_tracing_connection.cc +++ b/google/cloud/dialogflow_es/internal/versions_tracing_connection.cc @@ -79,6 +79,26 @@ Status VersionsTracingConnection::DeleteVersion( return internal::EndSpan(*span, child_->DeleteVersion(request)); } +StreamRange +VersionsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("dialogflow_es::VersionsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +VersionsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("dialogflow_es::VersionsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/dialogflow_es/internal/versions_tracing_connection.h b/google/cloud/dialogflow_es/internal/versions_tracing_connection.h index 29592e1a4cdf0..038f02fa6109d 100644 --- a/google/cloud/dialogflow_es/internal/versions_tracing_connection.h +++ b/google/cloud/dialogflow_es/internal/versions_tracing_connection.h @@ -57,6 +57,12 @@ class VersionsTracingConnection : public dialogflow_es::VersionsConnection { google::cloud::dialogflow::v2::DeleteVersionRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/dialogflow_es/internal/versions_tracing_stub.cc b/google/cloud/dialogflow_es/internal/versions_tracing_stub.cc index 895a5dfc95b68..bcf1da645bc23 100644 --- a/google/cloud/dialogflow_es/internal/versions_tracing_stub.cc +++ b/google/cloud/dialogflow_es/internal/versions_tracing_stub.cc @@ -90,6 +90,29 @@ Status VersionsTracingStub::DeleteVersion( child_->DeleteVersion(context, options, request)); } +StatusOr +VersionsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Versions", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr VersionsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.dialogflow.v2.Versions", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeVersionsTracingStub( diff --git a/google/cloud/dialogflow_es/internal/versions_tracing_stub.h b/google/cloud/dialogflow_es/internal/versions_tracing_stub.h index ebdf752805273..7cf0f37cac17d 100644 --- a/google/cloud/dialogflow_es/internal/versions_tracing_stub.h +++ b/google/cloud/dialogflow_es/internal/versions_tracing_stub.h @@ -62,6 +62,14 @@ class VersionsTracingStub : public VersionsStub { google::cloud::dialogflow::v2::DeleteVersionRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/dialogflow_es/knowledge_bases_client.cc b/google/cloud/dialogflow_es/knowledge_bases_client.cc index 66fd645e97127..d9db49a2259c8 100644 --- a/google/cloud/dialogflow_es/knowledge_bases_client.cc +++ b/google/cloud/dialogflow_es/knowledge_bases_client.cc @@ -119,6 +119,19 @@ KnowledgeBasesClient::UpdateKnowledgeBase( return connection_->UpdateKnowledgeBase(request); } +StreamRange +KnowledgeBasesClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr KnowledgeBasesClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es } // namespace cloud diff --git a/google/cloud/dialogflow_es/knowledge_bases_client.h b/google/cloud/dialogflow_es/knowledge_bases_client.h index 56cad49318a79..9690fa407ea55 100644 --- a/google/cloud/dialogflow_es/knowledge_bases_client.h +++ b/google/cloud/dialogflow_es/knowledge_bases_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -391,6 +392,76 @@ class KnowledgeBasesClient { google::cloud::dialogflow::v2::UpdateKnowledgeBaseRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_es/knowledge_bases_connection.cc b/google/cloud/dialogflow_es/knowledge_bases_connection.cc index 5d9f11566ddf4..f06f3a9f82d65 100644 --- a/google/cloud/dialogflow_es/knowledge_bases_connection.cc +++ b/google/cloud/dialogflow_es/knowledge_bases_connection.cc @@ -69,6 +69,20 @@ KnowledgeBasesConnection::UpdateKnowledgeBase( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +KnowledgeBasesConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +KnowledgeBasesConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeKnowledgeBasesConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include @@ -201,6 +202,12 @@ class KnowledgeBasesConnection { virtual StatusOr UpdateKnowledgeBase( google::cloud::dialogflow::v2::UpdateKnowledgeBaseRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_es/knowledge_bases_connection_idempotency_policy.cc b/google/cloud/dialogflow_es/knowledge_bases_connection_idempotency_policy.cc index 83d5d2ff5f7fb..2797b9644d97e 100644 --- a/google/cloud/dialogflow_es/knowledge_bases_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/knowledge_bases_connection_idempotency_policy.cc @@ -59,6 +59,16 @@ Idempotency KnowledgeBasesConnectionIdempotencyPolicy::UpdateKnowledgeBase( return Idempotency::kNonIdempotent; } +Idempotency KnowledgeBasesConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency KnowledgeBasesConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultKnowledgeBasesConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_es/knowledge_bases_connection_idempotency_policy.h b/google/cloud/dialogflow_es/knowledge_bases_connection_idempotency_policy.h index 82209f844e437..43203a439e161 100644 --- a/google/cloud/dialogflow_es/knowledge_bases_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/knowledge_bases_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -51,6 +52,12 @@ class KnowledgeBasesConnectionIdempotencyPolicy { virtual google::cloud::Idempotency UpdateKnowledgeBase( google::cloud::dialogflow::v2::UpdateKnowledgeBaseRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_es/mocks/mock_agents_connection.h b/google/cloud/dialogflow_es/mocks/mock_agents_connection.h index 4f81635f95316..fd28b95494fbd 100644 --- a/google/cloud/dialogflow_es/mocks/mock_agents_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_agents_connection.h @@ -217,6 +217,14 @@ class MockAgentsConnection : public dialogflow_es::AgentsConnection { (google::cloud::dialogflow::v2::GetValidationResultRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/mocks/mock_answer_records_connection.h b/google/cloud/dialogflow_es/mocks/mock_answer_records_connection.h index d74855e90f759..c08d3615d03b0 100644 --- a/google/cloud/dialogflow_es/mocks/mock_answer_records_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_answer_records_connection.h @@ -56,6 +56,14 @@ class MockAnswerRecordsConnection StatusOr, UpdateAnswerRecord, (google::cloud::dialogflow::v2::UpdateAnswerRecordRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/mocks/mock_contexts_connection.h b/google/cloud/dialogflow_es/mocks/mock_contexts_connection.h index 873995d110d61..b86f1541d8fa8 100644 --- a/google/cloud/dialogflow_es/mocks/mock_contexts_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_contexts_connection.h @@ -74,6 +74,14 @@ class MockContextsConnection : public dialogflow_es::ContextsConnection { Status, DeleteAllContexts, (google::cloud::dialogflow::v2::DeleteAllContextsRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/mocks/mock_conversation_datasets_connection.h b/google/cloud/dialogflow_es/mocks/mock_conversation_datasets_connection.h index 1b400f8919cb9..b6556c432f424 100644 --- a/google/cloud/dialogflow_es/mocks/mock_conversation_datasets_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_conversation_datasets_connection.h @@ -189,6 +189,14 @@ class MockConversationDatasetsConnection ImportConversationDataOperationResponse>>, ImportConversationData, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/mocks/mock_conversation_models_connection.h b/google/cloud/dialogflow_es/mocks/mock_conversation_models_connection.h index fc2f214a4cd6a..356c270eb8c37 100644 --- a/google/cloud/dialogflow_es/mocks/mock_conversation_models_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_conversation_models_connection.h @@ -292,6 +292,14 @@ class MockConversationModelsConnection StatusOr>, CreateConversationModelEvaluation, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/mocks/mock_conversation_profiles_connection.h b/google/cloud/dialogflow_es/mocks/mock_conversation_profiles_connection.h index 0abe9e1a2f94c..02f315f96af58 100644 --- a/google/cloud/dialogflow_es/mocks/mock_conversation_profiles_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_conversation_profiles_connection.h @@ -165,6 +165,14 @@ class MockConversationProfilesConnection future>, ClearSuggestionFeatureConfig, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/mocks/mock_conversations_connection.h b/google/cloud/dialogflow_es/mocks/mock_conversations_connection.h index 03e1d49449aaf..aa2d6720c1e44 100644 --- a/google/cloud/dialogflow_es/mocks/mock_conversations_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_conversations_connection.h @@ -101,6 +101,14 @@ class MockConversationsConnection SearchKnowledge, (google::cloud::dialogflow::v2::SearchKnowledgeRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/mocks/mock_documents_connection.h b/google/cloud/dialogflow_es/mocks/mock_documents_connection.h index 0f81470304b6d..e8eda7f18a34a 100644 --- a/google/cloud/dialogflow_es/mocks/mock_documents_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_documents_connection.h @@ -289,6 +289,14 @@ class MockDocumentsConnection : public dialogflow_es::DocumentsConnection { MOCK_METHOD(future>, ExportDocument, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/mocks/mock_entity_types_connection.h b/google/cloud/dialogflow_es/mocks/mock_entity_types_connection.h index cd0b9c21b8f1c..2cf669c20023b 100644 --- a/google/cloud/dialogflow_es/mocks/mock_entity_types_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_entity_types_connection.h @@ -265,6 +265,14 @@ class MockEntityTypesConnection : public dialogflow_es::EntityTypesConnection { /// @endcode MOCK_METHOD(future>, BatchDeleteEntities, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/mocks/mock_environments_connection.h b/google/cloud/dialogflow_es/mocks/mock_environments_connection.h index 12571aef7086d..1c4e11a16fd27 100644 --- a/google/cloud/dialogflow_es/mocks/mock_environments_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_environments_connection.h @@ -77,6 +77,14 @@ class MockEnvironmentsConnection GetEnvironmentHistory, (google::cloud::dialogflow::v2::GetEnvironmentHistoryRequest request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/mocks/mock_fulfillments_connection.h b/google/cloud/dialogflow_es/mocks/mock_fulfillments_connection.h index 1a323bed6eea0..2123e11739c33 100644 --- a/google/cloud/dialogflow_es/mocks/mock_fulfillments_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_fulfillments_connection.h @@ -56,6 +56,14 @@ class MockFulfillmentsConnection StatusOr, UpdateFulfillment, (google::cloud::dialogflow::v2::UpdateFulfillmentRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/mocks/mock_intents_connection.h b/google/cloud/dialogflow_es/mocks/mock_intents_connection.h index fcbbfdb3e088d..9c4c0979398cf 100644 --- a/google/cloud/dialogflow_es/mocks/mock_intents_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_intents_connection.h @@ -147,6 +147,14 @@ class MockIntentsConnection : public dialogflow_es::IntentsConnection { /// @endcode MOCK_METHOD(future>, BatchDeleteIntents, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/mocks/mock_knowledge_bases_connection.h b/google/cloud/dialogflow_es/mocks/mock_knowledge_bases_connection.h index 54e7370bd30bd..7c4ec012bd1d9 100644 --- a/google/cloud/dialogflow_es/mocks/mock_knowledge_bases_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_knowledge_bases_connection.h @@ -74,6 +74,14 @@ class MockKnowledgeBasesConnection (google::cloud::dialogflow::v2::UpdateKnowledgeBaseRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/mocks/mock_participants_connection.h b/google/cloud/dialogflow_es/mocks/mock_participants_connection.h index fd1df498baa48..bbbebc5edb403 100644 --- a/google/cloud/dialogflow_es/mocks/mock_participants_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_participants_connection.h @@ -104,6 +104,14 @@ class MockParticipantsConnection (google::cloud::dialogflow::v2::SuggestKnowledgeAssistRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/mocks/mock_session_entity_types_connection.h b/google/cloud/dialogflow_es/mocks/mock_session_entity_types_connection.h index c02c7761e6c54..ea0a6362949f4 100644 --- a/google/cloud/dialogflow_es/mocks/mock_session_entity_types_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_session_entity_types_connection.h @@ -78,6 +78,14 @@ class MockSessionEntityTypesConnection (google::cloud::dialogflow::v2::DeleteSessionEntityTypeRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/mocks/mock_sessions_connection.h b/google/cloud/dialogflow_es/mocks/mock_sessions_connection.h index 59e230dc99abf..c40340cc2372d 100644 --- a/google/cloud/dialogflow_es/mocks/mock_sessions_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_sessions_connection.h @@ -57,6 +57,14 @@ class MockSessionsConnection : public dialogflow_es::SessionsConnection { google::cloud::dialogflow::v2::StreamingDetectIntentRequest, google::cloud::dialogflow::v2::StreamingDetectIntentResponse>>), AsyncStreamingDetectIntent, (), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/mocks/mock_versions_connection.h b/google/cloud/dialogflow_es/mocks/mock_versions_connection.h index add772fcaaab3..741dcd61e19f8 100644 --- a/google/cloud/dialogflow_es/mocks/mock_versions_connection.h +++ b/google/cloud/dialogflow_es/mocks/mock_versions_connection.h @@ -69,6 +69,14 @@ class MockVersionsConnection : public dialogflow_es::VersionsConnection { Status, DeleteVersion, (google::cloud::dialogflow::v2::DeleteVersionRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/dialogflow_es/participants_client.cc b/google/cloud/dialogflow_es/participants_client.cc index 41fc0055613e6..ca35956a8d85f 100644 --- a/google/cloud/dialogflow_es/participants_client.cc +++ b/google/cloud/dialogflow_es/participants_client.cc @@ -199,6 +199,19 @@ ParticipantsClient::SuggestKnowledgeAssist( return connection_->SuggestKnowledgeAssist(request); } +StreamRange +ParticipantsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr ParticipantsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es } // namespace cloud diff --git a/google/cloud/dialogflow_es/participants_client.h b/google/cloud/dialogflow_es/participants_client.h index 8ab0d33636108..763ebc67ebf8f 100644 --- a/google/cloud/dialogflow_es/participants_client.h +++ b/google/cloud/dialogflow_es/participants_client.h @@ -701,6 +701,76 @@ class ParticipantsClient { request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_es/participants_connection.cc b/google/cloud/dialogflow_es/participants_connection.cc index 2821e356e0c44..39e117c975a78 100644 --- a/google/cloud/dialogflow_es/participants_connection.cc +++ b/google/cloud/dialogflow_es/participants_connection.cc @@ -105,6 +105,19 @@ ParticipantsConnection::SuggestKnowledgeAssist( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +ParticipantsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ParticipantsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeParticipantsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include @@ -225,6 +226,12 @@ class ParticipantsConnection { SuggestKnowledgeAssist( google::cloud::dialogflow::v2::SuggestKnowledgeAssistRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_es/participants_connection_idempotency_policy.cc b/google/cloud/dialogflow_es/participants_connection_idempotency_policy.cc index 0753392ff7b5a..095549da3a920 100644 --- a/google/cloud/dialogflow_es/participants_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/participants_connection_idempotency_policy.cc @@ -79,6 +79,16 @@ Idempotency ParticipantsConnectionIdempotencyPolicy::SuggestKnowledgeAssist( return Idempotency::kNonIdempotent; } +Idempotency ParticipantsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ParticipantsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultParticipantsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_es/participants_connection_idempotency_policy.h b/google/cloud/dialogflow_es/participants_connection_idempotency_policy.h index ec27e314d72fa..e2942bb856e45 100644 --- a/google/cloud/dialogflow_es/participants_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/participants_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -64,6 +65,12 @@ class ParticipantsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency SuggestKnowledgeAssist( google::cloud::dialogflow::v2::SuggestKnowledgeAssistRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_es/session_entity_types_client.cc b/google/cloud/dialogflow_es/session_entity_types_client.cc index c97be746a3a93..140d9149bfd1a 100644 --- a/google/cloud/dialogflow_es/session_entity_types_client.cc +++ b/google/cloud/dialogflow_es/session_entity_types_client.cc @@ -133,6 +133,20 @@ Status SessionEntityTypesClient::DeleteSessionEntityType( return connection_->DeleteSessionEntityType(request); } +StreamRange +SessionEntityTypesClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +SessionEntityTypesClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es } // namespace cloud diff --git a/google/cloud/dialogflow_es/session_entity_types_client.h b/google/cloud/dialogflow_es/session_entity_types_client.h index 555d18b1cff73..ac35284b09bf4 100644 --- a/google/cloud/dialogflow_es/session_entity_types_client.h +++ b/google/cloud/dialogflow_es/session_entity_types_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -490,6 +491,76 @@ class SessionEntityTypesClient { request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_es/session_entity_types_connection.cc b/google/cloud/dialogflow_es/session_entity_types_connection.cc index 2ba18b21110d3..f9ad3f0f582ec 100644 --- a/google/cloud/dialogflow_es/session_entity_types_connection.cc +++ b/google/cloud/dialogflow_es/session_entity_types_connection.cc @@ -69,6 +69,20 @@ Status SessionEntityTypesConnection::DeleteSessionEntityType( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +SessionEntityTypesConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +SessionEntityTypesConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSessionEntityTypesConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include @@ -208,6 +209,12 @@ class SessionEntityTypesConnection { virtual Status DeleteSessionEntityType( google::cloud::dialogflow::v2::DeleteSessionEntityTypeRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_es/session_entity_types_connection_idempotency_policy.cc b/google/cloud/dialogflow_es/session_entity_types_connection_idempotency_policy.cc index 98daa92cae2f7..09b60d8fc021f 100644 --- a/google/cloud/dialogflow_es/session_entity_types_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/session_entity_types_connection_idempotency_policy.cc @@ -63,6 +63,16 @@ SessionEntityTypesConnectionIdempotencyPolicy::DeleteSessionEntityType( return Idempotency::kNonIdempotent; } +Idempotency SessionEntityTypesConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SessionEntityTypesConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultSessionEntityTypesConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_es/session_entity_types_connection_idempotency_policy.h b/google/cloud/dialogflow_es/session_entity_types_connection_idempotency_policy.h index dac4b4e476db5..4c4e7ea8085e6 100644 --- a/google/cloud/dialogflow_es/session_entity_types_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/session_entity_types_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -55,6 +56,12 @@ class SessionEntityTypesConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteSessionEntityType( google::cloud::dialogflow::v2::DeleteSessionEntityTypeRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_es/sessions_client.cc b/google/cloud/dialogflow_es/sessions_client.cc index 7971061e9ac87..39ebc2f97dc55 100644 --- a/google/cloud/dialogflow_es/sessions_client.cc +++ b/google/cloud/dialogflow_es/sessions_client.cc @@ -60,6 +60,18 @@ SessionsClient::AsyncStreamingDetectIntent(Options opts) { return connection_->AsyncStreamingDetectIntent(); } +StreamRange SessionsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr SessionsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es } // namespace cloud diff --git a/google/cloud/dialogflow_es/sessions_client.h b/google/cloud/dialogflow_es/sessions_client.h index de04b888bf906..aae78ebdfc7a3 100644 --- a/google/cloud/dialogflow_es/sessions_client.h +++ b/google/cloud/dialogflow_es/sessions_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -238,6 +239,76 @@ class SessionsClient { google::cloud::dialogflow::v2::StreamingDetectIntentResponse>> AsyncStreamingDetectIntent(Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_es/sessions_connection.cc b/google/cloud/dialogflow_es/sessions_connection.cc index dc4a7aa673be1..b20fb2ae60217 100644 --- a/google/cloud/dialogflow_es/sessions_connection.cc +++ b/google/cloud/dialogflow_es/sessions_connection.cc @@ -26,6 +26,7 @@ #include "google/cloud/common_options.h" #include "google/cloud/credentials.h" #include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/unified_grpc_credentials.h" #include #include @@ -54,6 +55,19 @@ SessionsConnection::AsyncStreamingDetectIntent() { Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +SessionsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr SessionsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSessionsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include @@ -188,6 +190,12 @@ class SessionsConnection { google::cloud::dialogflow::v2::StreamingDetectIntentRequest, google::cloud::dialogflow::v2::StreamingDetectIntentResponse>> AsyncStreamingDetectIntent(); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_es/sessions_connection_idempotency_policy.cc b/google/cloud/dialogflow_es/sessions_connection_idempotency_policy.cc index d85273312bdfa..b56a7f0717664 100644 --- a/google/cloud/dialogflow_es/sessions_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/sessions_connection_idempotency_policy.cc @@ -39,6 +39,16 @@ Idempotency SessionsConnectionIdempotencyPolicy::DetectIntent( return Idempotency::kNonIdempotent; } +Idempotency SessionsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SessionsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultSessionsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_es/sessions_connection_idempotency_policy.h b/google/cloud/dialogflow_es/sessions_connection_idempotency_policy.h index b347fbd8f2be9..91bc1b510696a 100644 --- a/google/cloud/dialogflow_es/sessions_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/sessions_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -38,6 +39,12 @@ class SessionsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DetectIntent( google::cloud::dialogflow::v2::DetectIntentRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/dialogflow_es/versions_client.cc b/google/cloud/dialogflow_es/versions_client.cc index 7f430c25461c2..9133ce8d48862 100644 --- a/google/cloud/dialogflow_es/versions_client.cc +++ b/google/cloud/dialogflow_es/versions_client.cc @@ -110,6 +110,18 @@ Status VersionsClient::DeleteVersion( return connection_->DeleteVersion(request); } +StreamRange VersionsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr VersionsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dialogflow_es } // namespace cloud diff --git a/google/cloud/dialogflow_es/versions_client.h b/google/cloud/dialogflow_es/versions_client.h index c7834f11b878c..493445fbad03c 100644 --- a/google/cloud/dialogflow_es/versions_client.h +++ b/google/cloud/dialogflow_es/versions_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -416,6 +417,76 @@ class VersionsClient { google::cloud::dialogflow::v2::DeleteVersionRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/dialogflow_es/versions_connection.cc b/google/cloud/dialogflow_es/versions_connection.cc index a37fcddc95882..754b8070f9f25 100644 --- a/google/cloud/dialogflow_es/versions_connection.cc +++ b/google/cloud/dialogflow_es/versions_connection.cc @@ -68,6 +68,19 @@ Status VersionsConnection::DeleteVersion( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +VersionsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr VersionsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeVersionsConnection( std::string const& location, Options options) { internal::CheckExpectedOptions +#include #include #include @@ -194,6 +195,12 @@ class VersionsConnection { virtual Status DeleteVersion( google::cloud::dialogflow::v2::DeleteVersionRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/dialogflow_es/versions_connection_idempotency_policy.cc b/google/cloud/dialogflow_es/versions_connection_idempotency_policy.cc index 5d4e590b3dbfe..348bd0a10cbf7 100644 --- a/google/cloud/dialogflow_es/versions_connection_idempotency_policy.cc +++ b/google/cloud/dialogflow_es/versions_connection_idempotency_policy.cc @@ -59,6 +59,16 @@ Idempotency VersionsConnectionIdempotencyPolicy::DeleteVersion( return Idempotency::kNonIdempotent; } +Idempotency VersionsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency VersionsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultVersionsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/dialogflow_es/versions_connection_idempotency_policy.h b/google/cloud/dialogflow_es/versions_connection_idempotency_policy.h index 2ee543f6ddbbe..f269e068dad8e 100644 --- a/google/cloud/dialogflow_es/versions_connection_idempotency_policy.h +++ b/google/cloud/dialogflow_es/versions_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -50,6 +51,12 @@ class VersionsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteVersion( google::cloud::dialogflow::v2::DeleteVersionRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/discoveryengine/BUILD.bazel b/google/cloud/discoveryengine/BUILD.bazel index 3670e12cae5ab..3a2f788202be5 100644 --- a/google/cloud/discoveryengine/BUILD.bazel +++ b/google/cloud/discoveryengine/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/discoveryengine/v1:discoveryengine_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/discoveryengine/v1/completion_connection.h b/google/cloud/discoveryengine/v1/completion_connection.h index 0debf16d68285..ab7ac2d7edb96 100644 --- a/google/cloud/discoveryengine/v1/completion_connection.h +++ b/google/cloud/discoveryengine/v1/completion_connection.h @@ -30,6 +30,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include diff --git a/google/cloud/discoveryengine/v1/control_connection.h b/google/cloud/discoveryengine/v1/control_connection.h index 11e0605b4c482..7139fed257e9c 100644 --- a/google/cloud/discoveryengine/v1/control_connection.h +++ b/google/cloud/discoveryengine/v1/control_connection.h @@ -28,6 +28,7 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include #include namespace google { diff --git a/google/cloud/discoveryengine/v1/conversational_search_connection.h b/google/cloud/discoveryengine/v1/conversational_search_connection.h index 26650950cff14..d14016e6c9802 100644 --- a/google/cloud/discoveryengine/v1/conversational_search_connection.h +++ b/google/cloud/discoveryengine/v1/conversational_search_connection.h @@ -28,6 +28,7 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include #include namespace google { diff --git a/google/cloud/discoveryengine/v1/data_store_connection.h b/google/cloud/discoveryengine/v1/data_store_connection.h index 1e1000d206f97..85d8d3a84e225 100644 --- a/google/cloud/discoveryengine/v1/data_store_connection.h +++ b/google/cloud/discoveryengine/v1/data_store_connection.h @@ -31,6 +31,7 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include #include #include diff --git a/google/cloud/discoveryengine/v1/document_connection.h b/google/cloud/discoveryengine/v1/document_connection.h index 0d167e40877ca..acf0786351d1e 100644 --- a/google/cloud/discoveryengine/v1/document_connection.h +++ b/google/cloud/discoveryengine/v1/document_connection.h @@ -31,6 +31,7 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include #include #include diff --git a/google/cloud/discoveryengine/v1/engine_connection.h b/google/cloud/discoveryengine/v1/engine_connection.h index 87ef13fc14be6..6df6839e8805a 100644 --- a/google/cloud/discoveryengine/v1/engine_connection.h +++ b/google/cloud/discoveryengine/v1/engine_connection.h @@ -31,6 +31,7 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include #include #include diff --git a/google/cloud/discoveryengine/v1/grounded_generation_connection.h b/google/cloud/discoveryengine/v1/grounded_generation_connection.h index 9bb007268ba8b..1f3a4363c7fbf 100644 --- a/google/cloud/discoveryengine/v1/grounded_generation_connection.h +++ b/google/cloud/discoveryengine/v1/grounded_generation_connection.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include namespace google { diff --git a/google/cloud/discoveryengine/v1/internal/completion_stub.h b/google/cloud/discoveryengine/v1/internal/completion_stub.h index a6cd9fd0f813e..bf2578db121dc 100644 --- a/google/cloud/discoveryengine/v1/internal/completion_stub.h +++ b/google/cloud/discoveryengine/v1/internal/completion_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include diff --git a/google/cloud/discoveryengine/v1/internal/control_stub.h b/google/cloud/discoveryengine/v1/internal/control_stub.h index 6ee04e409abb8..194e5bcb0e3cd 100644 --- a/google/cloud/discoveryengine/v1/internal/control_stub.h +++ b/google/cloud/discoveryengine/v1/internal/control_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include diff --git a/google/cloud/discoveryengine/v1/internal/conversational_search_stub.h b/google/cloud/discoveryengine/v1/internal/conversational_search_stub.h index 60047978787a6..d192b63c5fcdc 100644 --- a/google/cloud/discoveryengine/v1/internal/conversational_search_stub.h +++ b/google/cloud/discoveryengine/v1/internal/conversational_search_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include diff --git a/google/cloud/discoveryengine/v1/internal/data_store_stub.h b/google/cloud/discoveryengine/v1/internal/data_store_stub.h index cd5bd11102c64..50e7f2078c1cd 100644 --- a/google/cloud/discoveryengine/v1/internal/data_store_stub.h +++ b/google/cloud/discoveryengine/v1/internal/data_store_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include diff --git a/google/cloud/discoveryengine/v1/internal/document_stub.h b/google/cloud/discoveryengine/v1/internal/document_stub.h index 3e10e3bec0787..33905cc4d03d8 100644 --- a/google/cloud/discoveryengine/v1/internal/document_stub.h +++ b/google/cloud/discoveryengine/v1/internal/document_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include diff --git a/google/cloud/discoveryengine/v1/internal/engine_stub.h b/google/cloud/discoveryengine/v1/internal/engine_stub.h index 0a3ffac79cf70..b8d1db844a51e 100644 --- a/google/cloud/discoveryengine/v1/internal/engine_stub.h +++ b/google/cloud/discoveryengine/v1/internal/engine_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include diff --git a/google/cloud/discoveryengine/v1/internal/grounded_generation_stub.h b/google/cloud/discoveryengine/v1/internal/grounded_generation_stub.h index af0127df93c55..ac5e94564c871 100644 --- a/google/cloud/discoveryengine/v1/internal/grounded_generation_stub.h +++ b/google/cloud/discoveryengine/v1/internal/grounded_generation_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include diff --git a/google/cloud/discoveryengine/v1/internal/project_stub.h b/google/cloud/discoveryengine/v1/internal/project_stub.h index 8da980b0a38b0..6551fa13c2c83 100644 --- a/google/cloud/discoveryengine/v1/internal/project_stub.h +++ b/google/cloud/discoveryengine/v1/internal/project_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include diff --git a/google/cloud/discoveryengine/v1/internal/rank_stub.h b/google/cloud/discoveryengine/v1/internal/rank_stub.h index 7d1be2e9aa182..79e64313f5942 100644 --- a/google/cloud/discoveryengine/v1/internal/rank_stub.h +++ b/google/cloud/discoveryengine/v1/internal/rank_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include diff --git a/google/cloud/discoveryengine/v1/internal/recommendation_stub.h b/google/cloud/discoveryengine/v1/internal/recommendation_stub.h index 2342ca9626a43..d61205dcc59cb 100644 --- a/google/cloud/discoveryengine/v1/internal/recommendation_stub.h +++ b/google/cloud/discoveryengine/v1/internal/recommendation_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include diff --git a/google/cloud/discoveryengine/v1/internal/schema_stub.h b/google/cloud/discoveryengine/v1/internal/schema_stub.h index a6f685111f997..c654d2bcba08f 100644 --- a/google/cloud/discoveryengine/v1/internal/schema_stub.h +++ b/google/cloud/discoveryengine/v1/internal/schema_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include diff --git a/google/cloud/discoveryengine/v1/internal/search_stub.h b/google/cloud/discoveryengine/v1/internal/search_stub.h index 3fdf351d6460e..c760f658fe6f3 100644 --- a/google/cloud/discoveryengine/v1/internal/search_stub.h +++ b/google/cloud/discoveryengine/v1/internal/search_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include diff --git a/google/cloud/discoveryengine/v1/internal/site_search_engine_stub.h b/google/cloud/discoveryengine/v1/internal/site_search_engine_stub.h index 8251c3b6653d0..32c73f75cb8e6 100644 --- a/google/cloud/discoveryengine/v1/internal/site_search_engine_stub.h +++ b/google/cloud/discoveryengine/v1/internal/site_search_engine_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include diff --git a/google/cloud/discoveryengine/v1/internal/user_event_stub.h b/google/cloud/discoveryengine/v1/internal/user_event_stub.h index 63a23ccae3ba4..49e49fbca6695 100644 --- a/google/cloud/discoveryengine/v1/internal/user_event_stub.h +++ b/google/cloud/discoveryengine/v1/internal/user_event_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include #include diff --git a/google/cloud/discoveryengine/v1/project_connection.h b/google/cloud/discoveryengine/v1/project_connection.h index 2f89608553e6e..8be5076652434 100644 --- a/google/cloud/discoveryengine/v1/project_connection.h +++ b/google/cloud/discoveryengine/v1/project_connection.h @@ -30,6 +30,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include diff --git a/google/cloud/discoveryengine/v1/rank_connection.h b/google/cloud/discoveryengine/v1/rank_connection.h index 0a7d121108f70..38746689e2658 100644 --- a/google/cloud/discoveryengine/v1/rank_connection.h +++ b/google/cloud/discoveryengine/v1/rank_connection.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include namespace google { diff --git a/google/cloud/discoveryengine/v1/recommendation_connection.h b/google/cloud/discoveryengine/v1/recommendation_connection.h index 044bac51a5779..8b84de7cf287d 100644 --- a/google/cloud/discoveryengine/v1/recommendation_connection.h +++ b/google/cloud/discoveryengine/v1/recommendation_connection.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include namespace google { diff --git a/google/cloud/discoveryengine/v1/schema_connection.h b/google/cloud/discoveryengine/v1/schema_connection.h index c9db9286c7da0..af2d462ca8602 100644 --- a/google/cloud/discoveryengine/v1/schema_connection.h +++ b/google/cloud/discoveryengine/v1/schema_connection.h @@ -31,6 +31,7 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include #include #include diff --git a/google/cloud/discoveryengine/v1/search_connection.h b/google/cloud/discoveryengine/v1/search_connection.h index cf28a0ebf53f3..69355ccc9910e 100644 --- a/google/cloud/discoveryengine/v1/search_connection.h +++ b/google/cloud/discoveryengine/v1/search_connection.h @@ -28,6 +28,7 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include #include namespace google { diff --git a/google/cloud/discoveryengine/v1/site_search_engine_connection.h b/google/cloud/discoveryengine/v1/site_search_engine_connection.h index 007910914e404..7e069dbd4a5e5 100644 --- a/google/cloud/discoveryengine/v1/site_search_engine_connection.h +++ b/google/cloud/discoveryengine/v1/site_search_engine_connection.h @@ -31,6 +31,7 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include #include #include diff --git a/google/cloud/discoveryengine/v1/user_event_connection.h b/google/cloud/discoveryengine/v1/user_event_connection.h index e67dea9bf5822..d75556161f4a6 100644 --- a/google/cloud/discoveryengine/v1/user_event_connection.h +++ b/google/cloud/discoveryengine/v1/user_event_connection.h @@ -30,6 +30,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include diff --git a/google/cloud/dlp/BUILD.bazel b/google/cloud/dlp/BUILD.bazel index b1826b24b1f30..f612df74e0cce 100644 --- a/google/cloud/dlp/BUILD.bazel +++ b/google/cloud/dlp/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/privacy/dlp/v2:dlp_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/dlp/v2/dlp_connection.h b/google/cloud/dlp/v2/dlp_connection.h index 09a2b450bc241..c7ed107c42648 100644 --- a/google/cloud/dlp/v2/dlp_connection.h +++ b/google/cloud/dlp/v2/dlp_connection.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/stream_range.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/dlp/v2/internal/dlp_stub.h b/google/cloud/dlp/v2/internal/dlp_stub.h index 360fbe7f6a7eb..f11f84777db4f 100644 --- a/google/cloud/dlp/v2/internal/dlp_stub.h +++ b/google/cloud/dlp/v2/internal/dlp_stub.h @@ -22,6 +22,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/documentai/BUILD.bazel b/google/cloud/documentai/BUILD.bazel index cbc64b17a5a32..ae522dc13d0f1 100644 --- a/google/cloud/documentai/BUILD.bazel +++ b/google/cloud/documentai/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/documentai/v1:documentai_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/documentai/v1/document_processor_client.cc b/google/cloud/documentai/v1/document_processor_client.cc index c5e10e95f13de..b71319a62f62f 100644 --- a/google/cloud/documentai/v1/document_processor_client.cc +++ b/google/cloud/documentai/v1/document_processor_client.cc @@ -654,6 +654,20 @@ DocumentProcessorServiceClient::ListEvaluations( return connection_->ListEvaluations(std::move(request)); } +StreamRange +DocumentProcessorServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +DocumentProcessorServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace documentai_v1 } // namespace cloud diff --git a/google/cloud/documentai/v1/document_processor_client.h b/google/cloud/documentai/v1/document_processor_client.h index d150c81082fc0..3875656ccc081 100644 --- a/google/cloud/documentai/v1/document_processor_client.h +++ b/google/cloud/documentai/v1/document_processor_client.h @@ -2027,6 +2027,76 @@ class DocumentProcessorServiceClient { google::cloud::documentai::v1::ListEvaluationsRequest request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/documentai/v1/document_processor_connection.cc b/google/cloud/documentai/v1/document_processor_connection.cc index 74fd91e8705ff..a069a9cdb4b04 100644 --- a/google/cloud/documentai/v1/document_processor_connection.cc +++ b/google/cloud/documentai/v1/document_processor_connection.cc @@ -378,6 +378,20 @@ DocumentProcessorServiceConnection::ListEvaluations( StreamRange>(); } +StreamRange +DocumentProcessorServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DocumentProcessorServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDocumentProcessorServiceConnection(std::string const& location, Options options) { diff --git a/google/cloud/documentai/v1/document_processor_connection.h b/google/cloud/documentai/v1/document_processor_connection.h index 5bbc403675b79..d13f4c4c24243 100644 --- a/google/cloud/documentai/v1/document_processor_connection.h +++ b/google/cloud/documentai/v1/document_processor_connection.h @@ -31,6 +31,7 @@ #include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include +#include #include #include #include @@ -392,6 +393,12 @@ class DocumentProcessorServiceConnection { virtual StreamRange ListEvaluations( google::cloud::documentai::v1::ListEvaluationsRequest request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/documentai/v1/document_processor_connection_idempotency_policy.cc b/google/cloud/documentai/v1/document_processor_connection_idempotency_policy.cc index fbd99c5ab2f50..3e15b9d3d1790 100644 --- a/google/cloud/documentai/v1/document_processor_connection_idempotency_policy.cc +++ b/google/cloud/documentai/v1/document_processor_connection_idempotency_policy.cc @@ -163,6 +163,16 @@ DocumentProcessorServiceConnectionIdempotencyPolicy::ListEvaluations( return Idempotency::kIdempotent; } +Idempotency DocumentProcessorServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DocumentProcessorServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultDocumentProcessorServiceConnectionIdempotencyPolicy() { return std::make_unique< diff --git a/google/cloud/documentai/v1/document_processor_connection_idempotency_policy.h b/google/cloud/documentai/v1/document_processor_connection_idempotency_policy.h index 0d4591dc055c4..4f513ad24ce07 100644 --- a/google/cloud/documentai/v1/document_processor_connection_idempotency_policy.h +++ b/google/cloud/documentai/v1/document_processor_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -108,6 +109,12 @@ class DocumentProcessorServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListEvaluations( google::cloud::documentai::v1::ListEvaluationsRequest request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/documentai/v1/internal/document_processor_auth_decorator.cc b/google/cloud/documentai/v1/internal/document_processor_auth_decorator.cc index 1e6f60890595f..4517135950ff3 100644 --- a/google/cloud/documentai/v1/internal/document_processor_auth_decorator.cc +++ b/google/cloud/documentai/v1/internal/document_processor_auth_decorator.cc @@ -462,6 +462,24 @@ DocumentProcessorServiceAuth::ListEvaluations( return child_->ListEvaluations(context, options, request); } +StatusOr +DocumentProcessorServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +DocumentProcessorServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> DocumentProcessorServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/documentai/v1/internal/document_processor_auth_decorator.h b/google/cloud/documentai/v1/internal/document_processor_auth_decorator.h index f1fa4247096fe..dfe7707e579f4 100644 --- a/google/cloud/documentai/v1/internal/document_processor_auth_decorator.h +++ b/google/cloud/documentai/v1/internal/document_processor_auth_decorator.h @@ -231,6 +231,14 @@ class DocumentProcessorServiceAuth : public DocumentProcessorServiceStub { google::cloud::documentai::v1::ListEvaluationsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/documentai/v1/internal/document_processor_connection_impl.cc b/google/cloud/documentai/v1/internal/document_processor_connection_impl.cc index 6ec2e0038ac2d..4bece4972d39d 100644 --- a/google/cloud/documentai/v1/internal/document_processor_connection_impl.cc +++ b/google/cloud/documentai/v1/internal/document_processor_connection_impl.cc @@ -1370,6 +1370,55 @@ DocumentProcessorServiceConnectionImpl::ListEvaluations( }); } +StreamRange +DocumentProcessorServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = + std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DocumentProcessorServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace documentai_v1_internal } // namespace cloud diff --git a/google/cloud/documentai/v1/internal/document_processor_connection_impl.h b/google/cloud/documentai/v1/internal/document_processor_connection_impl.h index 2d137010301e2..7ddd1ece54659 100644 --- a/google/cloud/documentai/v1/internal/document_processor_connection_impl.h +++ b/google/cloud/documentai/v1/internal/document_processor_connection_impl.h @@ -252,6 +252,12 @@ class DocumentProcessorServiceConnectionImpl StreamRange ListEvaluations( google::cloud::documentai::v1::ListEvaluationsRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/documentai/v1/internal/document_processor_logging_decorator.cc b/google/cloud/documentai/v1/internal/document_processor_logging_decorator.cc index 508389a8827e4..f03b2e7644b54 100644 --- a/google/cloud/documentai/v1/internal/document_processor_logging_decorator.cc +++ b/google/cloud/documentai/v1/internal/document_processor_logging_decorator.cc @@ -546,6 +546,30 @@ DocumentProcessorServiceLogging::ListEvaluations( context, options, request, __func__, tracing_options_); } +StatusOr +DocumentProcessorServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DocumentProcessorServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> DocumentProcessorServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/documentai/v1/internal/document_processor_logging_decorator.h b/google/cloud/documentai/v1/internal/document_processor_logging_decorator.h index be94f6bc2daab..038d7e3c898af 100644 --- a/google/cloud/documentai/v1/internal/document_processor_logging_decorator.h +++ b/google/cloud/documentai/v1/internal/document_processor_logging_decorator.h @@ -231,6 +231,14 @@ class DocumentProcessorServiceLogging : public DocumentProcessorServiceStub { google::cloud::documentai::v1::ListEvaluationsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/documentai/v1/internal/document_processor_metadata_decorator.cc b/google/cloud/documentai/v1/internal/document_processor_metadata_decorator.cc index 48076aa4f35d0..7f4792f3b3829 100644 --- a/google/cloud/documentai/v1/internal/document_processor_metadata_decorator.cc +++ b/google/cloud/documentai/v1/internal/document_processor_metadata_decorator.cc @@ -393,6 +393,24 @@ DocumentProcessorServiceMetadata::ListEvaluations( return child_->ListEvaluations(context, options, request); } +StatusOr +DocumentProcessorServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +DocumentProcessorServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> DocumentProcessorServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/documentai/v1/internal/document_processor_metadata_decorator.h b/google/cloud/documentai/v1/internal/document_processor_metadata_decorator.h index 1778109fcddea..88345c1d1d857 100644 --- a/google/cloud/documentai/v1/internal/document_processor_metadata_decorator.h +++ b/google/cloud/documentai/v1/internal/document_processor_metadata_decorator.h @@ -232,6 +232,14 @@ class DocumentProcessorServiceMetadata : public DocumentProcessorServiceStub { google::cloud::documentai::v1::ListEvaluationsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/documentai/v1/internal/document_processor_stub.cc b/google/cloud/documentai/v1/internal/document_processor_stub.cc index 85ad4262d21be..babec357e3b85 100644 --- a/google/cloud/documentai/v1/internal/document_processor_stub.cc +++ b/google/cloud/documentai/v1/internal/document_processor_stub.cc @@ -524,6 +524,30 @@ DefaultDocumentProcessorServiceStub::ListEvaluations( return response; } +StatusOr +DefaultDocumentProcessorServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDocumentProcessorServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultDocumentProcessorServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/documentai/v1/internal/document_processor_stub.h b/google/cloud/documentai/v1/internal/document_processor_stub.h index d68eb85bf1745..1c6a18bdc2210 100644 --- a/google/cloud/documentai/v1/internal/document_processor_stub.h +++ b/google/cloud/documentai/v1/internal/document_processor_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -226,6 +228,15 @@ class DocumentProcessorServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::documentai::v1::ListEvaluationsRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -246,9 +257,13 @@ class DefaultDocumentProcessorServiceStub std::unique_ptr grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ProcessDocument( grpc::ClientContext& context, Options const& options, @@ -442,6 +457,14 @@ class DefaultDocumentProcessorServiceStub google::cloud::documentai::v1::ListEvaluationsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -458,6 +481,8 @@ class DefaultDocumentProcessorServiceStub std::unique_ptr< google::cloud::documentai::v1::DocumentProcessorService::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/documentai/v1/internal/document_processor_stub_factory.cc b/google/cloud/documentai/v1/internal/document_processor_stub_factory.cc index d654d2d32648f..58e7126913b26 100644 --- a/google/cloud/documentai/v1/internal/document_processor_stub_factory.cc +++ b/google/cloud/documentai/v1/internal/document_processor_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -45,9 +46,11 @@ CreateDefaultDocumentProcessorServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::documentai::v1::DocumentProcessorService::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/documentai/v1/internal/document_processor_tracing_connection.cc b/google/cloud/documentai/v1/internal/document_processor_tracing_connection.cc index 6d368ebfac9a1..9a47b111ac9b4 100644 --- a/google/cloud/documentai/v1/internal/document_processor_tracing_connection.cc +++ b/google/cloud/documentai/v1/internal/document_processor_tracing_connection.cc @@ -519,6 +519,26 @@ DocumentProcessorServiceTracingConnection::ListEvaluations( std::move(sr)); } +StreamRange +DocumentProcessorServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "documentai_v1::DocumentProcessorServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DocumentProcessorServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "documentai_v1::DocumentProcessorServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/documentai/v1/internal/document_processor_tracing_connection.h b/google/cloud/documentai/v1/internal/document_processor_tracing_connection.h index 42dd4451c8a7e..6ab873352661e 100644 --- a/google/cloud/documentai/v1/internal/document_processor_tracing_connection.h +++ b/google/cloud/documentai/v1/internal/document_processor_tracing_connection.h @@ -239,6 +239,12 @@ class DocumentProcessorServiceTracingConnection StreamRange ListEvaluations( google::cloud::documentai::v1::ListEvaluationsRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/documentai/v1/internal/document_processor_tracing_stub.cc b/google/cloud/documentai/v1/internal/document_processor_tracing_stub.cc index 9e85a1f1ce23d..d1de167a286a8 100644 --- a/google/cloud/documentai/v1/internal/document_processor_tracing_stub.cc +++ b/google/cloud/documentai/v1/internal/document_processor_tracing_stub.cc @@ -500,6 +500,30 @@ DocumentProcessorServiceTracingStub::ListEvaluations( child_->ListEvaluations(context, options, request)); } +StatusOr +DocumentProcessorServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.documentai.v1.DocumentProcessorService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +DocumentProcessorServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.documentai.v1.DocumentProcessorService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> DocumentProcessorServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/documentai/v1/internal/document_processor_tracing_stub.h b/google/cloud/documentai/v1/internal/document_processor_tracing_stub.h index 20c22aa92fe05..a70a83e63f8b0 100644 --- a/google/cloud/documentai/v1/internal/document_processor_tracing_stub.h +++ b/google/cloud/documentai/v1/internal/document_processor_tracing_stub.h @@ -232,6 +232,14 @@ class DocumentProcessorServiceTracingStub google::cloud::documentai::v1::ListEvaluationsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/documentai/v1/mocks/mock_document_processor_connection.h b/google/cloud/documentai/v1/mocks/mock_document_processor_connection.h index 7ec966286b4d8..fda7f5ef20133 100644 --- a/google/cloud/documentai/v1/mocks/mock_document_processor_connection.h +++ b/google/cloud/documentai/v1/mocks/mock_document_processor_connection.h @@ -573,6 +573,14 @@ class MockDocumentProcessorServiceConnection ListEvaluations, (google::cloud::documentai::v1::ListEvaluationsRequest request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/edgecontainer/BUILD.bazel b/google/cloud/edgecontainer/BUILD.bazel index e6a738d6d2f8b..6de3f8d3700f0 100644 --- a/google/cloud/edgecontainer/BUILD.bazel +++ b/google/cloud/edgecontainer/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/edgecontainer/v1:edgecontainer_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/edgecontainer/v1/edge_container_client.cc b/google/cloud/edgecontainer/v1/edge_container_client.cc index e9be3a504401c..6b51242688fa0 100644 --- a/google/cloud/edgecontainer/v1/edge_container_client.cc +++ b/google/cloud/edgecontainer/v1/edge_container_client.cc @@ -614,6 +614,19 @@ EdgeContainerClient::GetServerConfig( return connection_->GetServerConfig(request); } +StreamRange +EdgeContainerClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr EdgeContainerClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace edgecontainer_v1 } // namespace cloud diff --git a/google/cloud/edgecontainer/v1/edge_container_client.h b/google/cloud/edgecontainer/v1/edge_container_client.h index b39e0e4b220e8..cdccaa3a822d2 100644 --- a/google/cloud/edgecontainer/v1/edge_container_client.h +++ b/google/cloud/edgecontainer/v1/edge_container_client.h @@ -1845,6 +1845,76 @@ class EdgeContainerClient { google::cloud::edgecontainer::v1::GetServerConfigRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/edgecontainer/v1/edge_container_connection.cc b/google/cloud/edgecontainer/v1/edge_container_connection.cc index 5bc352e1a6cd4..37423ab7fe55d 100644 --- a/google/cloud/edgecontainer/v1/edge_container_connection.cc +++ b/google/cloud/edgecontainer/v1/edge_container_connection.cc @@ -315,6 +315,20 @@ EdgeContainerConnection::GetServerConfig( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +EdgeContainerConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +EdgeContainerConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeEdgeContainerConnection( Options options) { internal::CheckExpectedOptions +#include #include #include @@ -330,6 +331,12 @@ class EdgeContainerConnection { virtual StatusOr GetServerConfig( google::cloud::edgecontainer::v1::GetServerConfigRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/edgecontainer/v1/edge_container_connection_idempotency_policy.cc b/google/cloud/edgecontainer/v1/edge_container_connection_idempotency_policy.cc index f0b145ade4115..b170a30a4d1c2 100644 --- a/google/cloud/edgecontainer/v1/edge_container_connection_idempotency_policy.cc +++ b/google/cloud/edgecontainer/v1/edge_container_connection_idempotency_policy.cc @@ -134,6 +134,16 @@ Idempotency EdgeContainerConnectionIdempotencyPolicy::GetServerConfig( return Idempotency::kIdempotent; } +Idempotency EdgeContainerConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency EdgeContainerConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultEdgeContainerConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/edgecontainer/v1/edge_container_connection_idempotency_policy.h b/google/cloud/edgecontainer/v1/edge_container_connection_idempotency_policy.h index 43ba010986427..74294152de276 100644 --- a/google/cloud/edgecontainer/v1/edge_container_connection_idempotency_policy.h +++ b/google/cloud/edgecontainer/v1/edge_container_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -100,6 +101,12 @@ class EdgeContainerConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GetServerConfig( google::cloud::edgecontainer::v1::GetServerConfigRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/edgecontainer/v1/internal/edge_container_auth_decorator.cc b/google/cloud/edgecontainer/v1/internal/edge_container_auth_decorator.cc index 5e269c0c087f4..61928d5d130f2 100644 --- a/google/cloud/edgecontainer/v1/internal/edge_container_auth_decorator.cc +++ b/google/cloud/edgecontainer/v1/internal/edge_container_auth_decorator.cc @@ -389,6 +389,23 @@ EdgeContainerAuth::GetServerConfig( return child_->GetServerConfig(context, options, request); } +StatusOr +EdgeContainerAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr EdgeContainerAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> EdgeContainerAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/edgecontainer/v1/internal/edge_container_auth_decorator.h b/google/cloud/edgecontainer/v1/internal/edge_container_auth_decorator.h index 3c9fead15edc1..cafeffb6dccb1 100644 --- a/google/cloud/edgecontainer/v1/internal/edge_container_auth_decorator.h +++ b/google/cloud/edgecontainer/v1/internal/edge_container_auth_decorator.h @@ -205,6 +205,14 @@ class EdgeContainerAuth : public EdgeContainerStub { google::cloud::edgecontainer::v1::GetServerConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/edgecontainer/v1/internal/edge_container_connection_impl.cc b/google/cloud/edgecontainer/v1/internal/edge_container_connection_impl.cc index 40337a2d3ea55..c32a8fc37ee95 100644 --- a/google/cloud/edgecontainer/v1/internal/edge_container_connection_impl.cc +++ b/google/cloud/edgecontainer/v1/internal/edge_container_connection_impl.cc @@ -1161,6 +1161,54 @@ EdgeContainerConnectionImpl::GetServerConfig( *current, request, __func__); } +StreamRange +EdgeContainerConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +EdgeContainerConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace edgecontainer_v1_internal } // namespace cloud diff --git a/google/cloud/edgecontainer/v1/internal/edge_container_connection_impl.h b/google/cloud/edgecontainer/v1/internal/edge_container_connection_impl.h index 519aaddf49c5b..2f32d48b7eaab 100644 --- a/google/cloud/edgecontainer/v1/internal/edge_container_connection_impl.h +++ b/google/cloud/edgecontainer/v1/internal/edge_container_connection_impl.h @@ -205,6 +205,12 @@ class EdgeContainerConnectionImpl google::cloud::edgecontainer::v1::GetServerConfigRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/edgecontainer/v1/internal/edge_container_logging_decorator.cc b/google/cloud/edgecontainer/v1/internal/edge_container_logging_decorator.cc index f5fc83be3dddb..997cd973de849 100644 --- a/google/cloud/edgecontainer/v1/internal/edge_container_logging_decorator.cc +++ b/google/cloud/edgecontainer/v1/internal/edge_container_logging_decorator.cc @@ -466,6 +466,29 @@ EdgeContainerLogging::GetServerConfig( context, options, request, __func__, tracing_options_); } +StatusOr +EdgeContainerLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EdgeContainerLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> EdgeContainerLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/edgecontainer/v1/internal/edge_container_logging_decorator.h b/google/cloud/edgecontainer/v1/internal/edge_container_logging_decorator.h index e5772d4ce0137..dedc9f21baf28 100644 --- a/google/cloud/edgecontainer/v1/internal/edge_container_logging_decorator.h +++ b/google/cloud/edgecontainer/v1/internal/edge_container_logging_decorator.h @@ -205,6 +205,14 @@ class EdgeContainerLogging : public EdgeContainerStub { google::cloud::edgecontainer::v1::GetServerConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/edgecontainer/v1/internal/edge_container_metadata_decorator.cc b/google/cloud/edgecontainer/v1/internal/edge_container_metadata_decorator.cc index 54e01507d2450..4147f184b8a25 100644 --- a/google/cloud/edgecontainer/v1/internal/edge_container_metadata_decorator.cc +++ b/google/cloud/edgecontainer/v1/internal/edge_container_metadata_decorator.cc @@ -336,6 +336,23 @@ EdgeContainerMetadata::GetServerConfig( return child_->GetServerConfig(context, options, request); } +StatusOr +EdgeContainerMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr EdgeContainerMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> EdgeContainerMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/edgecontainer/v1/internal/edge_container_metadata_decorator.h b/google/cloud/edgecontainer/v1/internal/edge_container_metadata_decorator.h index d19bc51e7e477..d18ebed57f43e 100644 --- a/google/cloud/edgecontainer/v1/internal/edge_container_metadata_decorator.h +++ b/google/cloud/edgecontainer/v1/internal/edge_container_metadata_decorator.h @@ -205,6 +205,14 @@ class EdgeContainerMetadata : public EdgeContainerStub { google::cloud::edgecontainer::v1::GetServerConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/edgecontainer/v1/internal/edge_container_stub.cc b/google/cloud/edgecontainer/v1/internal/edge_container_stub.cc index 68912affd1ef2..19f4865dd41bc 100644 --- a/google/cloud/edgecontainer/v1/internal/edge_container_stub.cc +++ b/google/cloud/edgecontainer/v1/internal/edge_container_stub.cc @@ -450,6 +450,30 @@ DefaultEdgeContainerStub::GetServerConfig( return response; } +StatusOr +DefaultEdgeContainerStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultEdgeContainerStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultEdgeContainerStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/edgecontainer/v1/internal/edge_container_stub.h b/google/cloud/edgecontainer/v1/internal/edge_container_stub.h index 5fbd6a73577c6..dd9d5ed3bc1a9 100644 --- a/google/cloud/edgecontainer/v1/internal/edge_container_stub.h +++ b/google/cloud/edgecontainer/v1/internal/edge_container_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -207,6 +209,15 @@ class EdgeContainerStub { google::cloud::edgecontainer::v1::GetServerConfigRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -226,9 +237,13 @@ class DefaultEdgeContainerStub : public EdgeContainerStub { std::unique_ptr< google::cloud::edgecontainer::v1::EdgeContainer::StubInterface> grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListClusters( grpc::ClientContext& context, Options const& options, @@ -396,6 +411,14 @@ class DefaultEdgeContainerStub : public EdgeContainerStub { google::cloud::edgecontainer::v1::GetServerConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -412,6 +435,8 @@ class DefaultEdgeContainerStub : public EdgeContainerStub { std::unique_ptr< google::cloud::edgecontainer::v1::EdgeContainer::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/edgecontainer/v1/internal/edge_container_stub_factory.cc b/google/cloud/edgecontainer/v1/internal/edge_container_stub_factory.cc index 5d6efbf12ffce..de50a36ad0af3 100644 --- a/google/cloud/edgecontainer/v1/internal/edge_container_stub_factory.cc +++ b/google/cloud/edgecontainer/v1/internal/edge_container_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultEdgeContainerStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::edgecontainer::v1::EdgeContainer::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/edgecontainer/v1/internal/edge_container_tracing_connection.cc b/google/cloud/edgecontainer/v1/internal/edge_container_tracing_connection.cc index 659fc7b138885..97a9ce6b40525 100644 --- a/google/cloud/edgecontainer/v1/internal/edge_container_tracing_connection.cc +++ b/google/cloud/edgecontainer/v1/internal/edge_container_tracing_connection.cc @@ -412,6 +412,26 @@ EdgeContainerTracingConnection::GetServerConfig( return internal::EndSpan(*span, child_->GetServerConfig(request)); } +StreamRange +EdgeContainerTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "edgecontainer_v1::EdgeContainerConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +EdgeContainerTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "edgecontainer_v1::EdgeContainerConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/edgecontainer/v1/internal/edge_container_tracing_connection.h b/google/cloud/edgecontainer/v1/internal/edge_container_tracing_connection.h index 4ca4ee328fbf4..79cc4fbc6a03d 100644 --- a/google/cloud/edgecontainer/v1/internal/edge_container_tracing_connection.h +++ b/google/cloud/edgecontainer/v1/internal/edge_container_tracing_connection.h @@ -193,6 +193,12 @@ class EdgeContainerTracingConnection google::cloud::edgecontainer::v1::GetServerConfigRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/edgecontainer/v1/internal/edge_container_tracing_stub.cc b/google/cloud/edgecontainer/v1/internal/edge_container_tracing_stub.cc index 79fb30fbac6b3..dad492f0a6eff 100644 --- a/google/cloud/edgecontainer/v1/internal/edge_container_tracing_stub.cc +++ b/google/cloud/edgecontainer/v1/internal/edge_container_tracing_stub.cc @@ -413,6 +413,30 @@ EdgeContainerTracingStub::GetServerConfig( child_->GetServerConfig(context, options, request)); } +StatusOr +EdgeContainerTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.edgecontainer.v1.EdgeContainer", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +EdgeContainerTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.edgecontainer.v1.EdgeContainer", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> EdgeContainerTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/edgecontainer/v1/internal/edge_container_tracing_stub.h b/google/cloud/edgecontainer/v1/internal/edge_container_tracing_stub.h index 44c6f3e100206..881e9c5b3a7f7 100644 --- a/google/cloud/edgecontainer/v1/internal/edge_container_tracing_stub.h +++ b/google/cloud/edgecontainer/v1/internal/edge_container_tracing_stub.h @@ -204,6 +204,14 @@ class EdgeContainerTracingStub : public EdgeContainerStub { google::cloud::edgecontainer::v1::GetServerConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/edgecontainer/v1/mocks/mock_edge_container_connection.h b/google/cloud/edgecontainer/v1/mocks/mock_edge_container_connection.h index 0e5fb3c2b7559..4a25c68ad0a68 100644 --- a/google/cloud/edgecontainer/v1/mocks/mock_edge_container_connection.h +++ b/google/cloud/edgecontainer/v1/mocks/mock_edge_container_connection.h @@ -466,6 +466,14 @@ class MockEdgeContainerConnection StatusOr, GetServerConfig, (google::cloud::edgecontainer::v1::GetServerConfigRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/edgenetwork/BUILD.bazel b/google/cloud/edgenetwork/BUILD.bazel index b0640f61a0395..1a8665084f133 100644 --- a/google/cloud/edgenetwork/BUILD.bazel +++ b/google/cloud/edgenetwork/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/edgenetwork/v1:edgenetwork_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/edgenetwork/v1/edge_network_client.cc b/google/cloud/edgenetwork/v1/edge_network_client.cc index d30b4ea5b5642..88a8b3af5e5a3 100644 --- a/google/cloud/edgenetwork/v1/edge_network_client.cc +++ b/google/cloud/edgenetwork/v1/edge_network_client.cc @@ -730,6 +730,18 @@ EdgeNetworkClient::DeleteRouter(google::longrunning::Operation const& operation, return connection_->DeleteRouter(operation); } +StreamRange EdgeNetworkClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr EdgeNetworkClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace edgenetwork_v1 } // namespace cloud diff --git a/google/cloud/edgenetwork/v1/edge_network_client.h b/google/cloud/edgenetwork/v1/edge_network_client.h index f6445d80e4693..336c600ab0f9d 100644 --- a/google/cloud/edgenetwork/v1/edge_network_client.h +++ b/google/cloud/edgenetwork/v1/edge_network_client.h @@ -2305,6 +2305,76 @@ class EdgeNetworkClient { DeleteRouter(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/edgenetwork/v1/edge_network_connection.cc b/google/cloud/edgenetwork/v1/edge_network_connection.cc index 2ca401afc19b8..c0bbaeacd4ac1 100644 --- a/google/cloud/edgenetwork/v1/edge_network_connection.cc +++ b/google/cloud/edgenetwork/v1/edge_network_connection.cc @@ -363,6 +363,19 @@ EdgeNetworkConnection::DeleteRouter(google::longrunning::Operation const&) { Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +EdgeNetworkConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr EdgeNetworkConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeEdgeNetworkConnection( Options options) { internal::CheckExpectedOptions +#include #include #include @@ -355,6 +356,12 @@ class EdgeNetworkConnection { virtual future> DeleteRouter(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/edgenetwork/v1/edge_network_connection_idempotency_policy.cc b/google/cloud/edgenetwork/v1/edge_network_connection_idempotency_policy.cc index f3cf3b2955e78..6368c0c1bd47b 100644 --- a/google/cloud/edgenetwork/v1/edge_network_connection_idempotency_policy.cc +++ b/google/cloud/edgenetwork/v1/edge_network_connection_idempotency_policy.cc @@ -169,6 +169,16 @@ Idempotency EdgeNetworkConnectionIdempotencyPolicy::DeleteRouter( return Idempotency::kNonIdempotent; } +Idempotency EdgeNetworkConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency EdgeNetworkConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultEdgeNetworkConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/edgenetwork/v1/edge_network_connection_idempotency_policy.h b/google/cloud/edgenetwork/v1/edge_network_connection_idempotency_policy.h index 015a9e3e8641e..56d2d7bb35f2a 100644 --- a/google/cloud/edgenetwork/v1/edge_network_connection_idempotency_policy.h +++ b/google/cloud/edgenetwork/v1/edge_network_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -118,6 +119,12 @@ class EdgeNetworkConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteRouter( google::cloud::edgenetwork::v1::DeleteRouterRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/edgenetwork/v1/internal/edge_network_auth_decorator.cc b/google/cloud/edgenetwork/v1/internal/edge_network_auth_decorator.cc index 870e6424f0355..e0758f632fcc1 100644 --- a/google/cloud/edgenetwork/v1/internal/edge_network_auth_decorator.cc +++ b/google/cloud/edgenetwork/v1/internal/edge_network_auth_decorator.cc @@ -460,6 +460,23 @@ StatusOr EdgeNetworkAuth::DeleteRouter( return child_->DeleteRouter(context, options, request); } +StatusOr +EdgeNetworkAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr EdgeNetworkAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> EdgeNetworkAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/edgenetwork/v1/internal/edge_network_auth_decorator.h b/google/cloud/edgenetwork/v1/internal/edge_network_auth_decorator.h index cc4256d263445..6b5c1a56125a1 100644 --- a/google/cloud/edgenetwork/v1/internal/edge_network_auth_decorator.h +++ b/google/cloud/edgenetwork/v1/internal/edge_network_auth_decorator.h @@ -241,6 +241,14 @@ class EdgeNetworkAuth : public EdgeNetworkStub { google::cloud::edgenetwork::v1::DeleteRouterRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/edgenetwork/v1/internal/edge_network_connection_impl.cc b/google/cloud/edgenetwork/v1/internal/edge_network_connection_impl.cc index a032bca7c1d2a..430e1f29e501e 100644 --- a/google/cloud/edgenetwork/v1/internal/edge_network_connection_impl.cc +++ b/google/cloud/edgenetwork/v1/internal/edge_network_connection_impl.cc @@ -1341,6 +1341,54 @@ EdgeNetworkConnectionImpl::DeleteRouter( polling_policy(*current), __func__); } +StreamRange +EdgeNetworkConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +EdgeNetworkConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace edgenetwork_v1_internal } // namespace cloud diff --git a/google/cloud/edgenetwork/v1/internal/edge_network_connection_impl.h b/google/cloud/edgenetwork/v1/internal/edge_network_connection_impl.h index 12bb1bdc7a2b8..220a363fb5f01 100644 --- a/google/cloud/edgenetwork/v1/internal/edge_network_connection_impl.h +++ b/google/cloud/edgenetwork/v1/internal/edge_network_connection_impl.h @@ -235,6 +235,12 @@ class EdgeNetworkConnectionImpl : public edgenetwork_v1::EdgeNetworkConnection { future> DeleteRouter(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/edgenetwork/v1/internal/edge_network_logging_decorator.cc b/google/cloud/edgenetwork/v1/internal/edge_network_logging_decorator.cc index 246ced3dd812b..d76885a4d28f7 100644 --- a/google/cloud/edgenetwork/v1/internal/edge_network_logging_decorator.cc +++ b/google/cloud/edgenetwork/v1/internal/edge_network_logging_decorator.cc @@ -554,6 +554,29 @@ StatusOr EdgeNetworkLogging::DeleteRouter( context, options, request, __func__, tracing_options_); } +StatusOr +EdgeNetworkLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EdgeNetworkLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> EdgeNetworkLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/edgenetwork/v1/internal/edge_network_logging_decorator.h b/google/cloud/edgenetwork/v1/internal/edge_network_logging_decorator.h index f67ae97407598..de2bcfa3cf24a 100644 --- a/google/cloud/edgenetwork/v1/internal/edge_network_logging_decorator.h +++ b/google/cloud/edgenetwork/v1/internal/edge_network_logging_decorator.h @@ -241,6 +241,14 @@ class EdgeNetworkLogging : public EdgeNetworkStub { google::cloud::edgenetwork::v1::DeleteRouterRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/edgenetwork/v1/internal/edge_network_metadata_decorator.cc b/google/cloud/edgenetwork/v1/internal/edge_network_metadata_decorator.cc index 579adeebbd87a..d69a0e91365f5 100644 --- a/google/cloud/edgenetwork/v1/internal/edge_network_metadata_decorator.cc +++ b/google/cloud/edgenetwork/v1/internal/edge_network_metadata_decorator.cc @@ -398,6 +398,23 @@ StatusOr EdgeNetworkMetadata::DeleteRouter( return child_->DeleteRouter(context, options, request); } +StatusOr +EdgeNetworkMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr EdgeNetworkMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> EdgeNetworkMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/edgenetwork/v1/internal/edge_network_metadata_decorator.h b/google/cloud/edgenetwork/v1/internal/edge_network_metadata_decorator.h index 27e5cf9fc7188..091b14f0d3b36 100644 --- a/google/cloud/edgenetwork/v1/internal/edge_network_metadata_decorator.h +++ b/google/cloud/edgenetwork/v1/internal/edge_network_metadata_decorator.h @@ -241,6 +241,14 @@ class EdgeNetworkMetadata : public EdgeNetworkStub { google::cloud::edgenetwork::v1::DeleteRouterRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/edgenetwork/v1/internal/edge_network_stub.cc b/google/cloud/edgenetwork/v1/internal/edge_network_stub.cc index 51303c427a10d..e3ab68899d05a 100644 --- a/google/cloud/edgenetwork/v1/internal/edge_network_stub.cc +++ b/google/cloud/edgenetwork/v1/internal/edge_network_stub.cc @@ -531,6 +531,29 @@ StatusOr DefaultEdgeNetworkStub::DeleteRouter( return response; } +StatusOr +DefaultEdgeNetworkStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultEdgeNetworkStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultEdgeNetworkStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/edgenetwork/v1/internal/edge_network_stub.h b/google/cloud/edgenetwork/v1/internal/edge_network_stub.h index 2f5ab3f08692d..0919425f5ddf6 100644 --- a/google/cloud/edgenetwork/v1/internal/edge_network_stub.h +++ b/google/cloud/edgenetwork/v1/internal/edge_network_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -224,6 +226,15 @@ class EdgeNetworkStub { grpc::ClientContext& context, Options options, google::cloud::edgenetwork::v1::DeleteRouterRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -243,9 +254,13 @@ class DefaultEdgeNetworkStub : public EdgeNetworkStub { std::unique_ptr< google::cloud::edgenetwork::v1::EdgeNetwork::StubInterface> grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr InitializeZone(grpc::ClientContext& context, Options const& options, @@ -449,6 +464,14 @@ class DefaultEdgeNetworkStub : public EdgeNetworkStub { google::cloud::edgenetwork::v1::DeleteRouterRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -464,6 +487,8 @@ class DefaultEdgeNetworkStub : public EdgeNetworkStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/edgenetwork/v1/internal/edge_network_stub_factory.cc b/google/cloud/edgenetwork/v1/internal/edge_network_stub_factory.cc index 5400da9e7eafc..366508e204dba 100644 --- a/google/cloud/edgenetwork/v1/internal/edge_network_stub_factory.cc +++ b/google/cloud/edgenetwork/v1/internal/edge_network_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultEdgeNetworkStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::edgenetwork::v1::EdgeNetwork::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/edgenetwork/v1/internal/edge_network_tracing_connection.cc b/google/cloud/edgenetwork/v1/internal/edge_network_tracing_connection.cc index 0e6e2056863fd..1afbfe8ddbccb 100644 --- a/google/cloud/edgenetwork/v1/internal/edge_network_tracing_connection.cc +++ b/google/cloud/edgenetwork/v1/internal/edge_network_tracing_connection.cc @@ -484,6 +484,26 @@ EdgeNetworkTracingConnection::DeleteRouter( return internal::EndSpan(std::move(span), child_->DeleteRouter(operation)); } +StreamRange +EdgeNetworkTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "edgenetwork_v1::EdgeNetworkConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +EdgeNetworkTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("edgenetwork_v1::EdgeNetworkConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/edgenetwork/v1/internal/edge_network_tracing_connection.h b/google/cloud/edgenetwork/v1/internal/edge_network_tracing_connection.h index ddb6ef8e360f3..da9fc20c11b25 100644 --- a/google/cloud/edgenetwork/v1/internal/edge_network_tracing_connection.h +++ b/google/cloud/edgenetwork/v1/internal/edge_network_tracing_connection.h @@ -224,6 +224,12 @@ class EdgeNetworkTracingConnection future> DeleteRouter(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/edgenetwork/v1/internal/edge_network_tracing_stub.cc b/google/cloud/edgenetwork/v1/internal/edge_network_tracing_stub.cc index a8d2d23b9fed4..46a8226b856d7 100644 --- a/google/cloud/edgenetwork/v1/internal/edge_network_tracing_stub.cc +++ b/google/cloud/edgenetwork/v1/internal/edge_network_tracing_stub.cc @@ -488,6 +488,29 @@ StatusOr EdgeNetworkTracingStub::DeleteRouter( child_->DeleteRouter(context, options, request)); } +StatusOr +EdgeNetworkTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.edgenetwork.v1.EdgeNetwork", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr EdgeNetworkTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.edgenetwork.v1.EdgeNetwork", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> EdgeNetworkTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/edgenetwork/v1/internal/edge_network_tracing_stub.h b/google/cloud/edgenetwork/v1/internal/edge_network_tracing_stub.h index d3bcefcf9e4ba..999d0c0b9ce74 100644 --- a/google/cloud/edgenetwork/v1/internal/edge_network_tracing_stub.h +++ b/google/cloud/edgenetwork/v1/internal/edge_network_tracing_stub.h @@ -240,6 +240,14 @@ class EdgeNetworkTracingStub : public EdgeNetworkStub { google::cloud::edgenetwork::v1::DeleteRouterRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/edgenetwork/v1/mocks/mock_edge_network_connection.h b/google/cloud/edgenetwork/v1/mocks/mock_edge_network_connection.h index 4b52b87820be8..45de16fe3ca4e 100644 --- a/google/cloud/edgenetwork/v1/mocks/mock_edge_network_connection.h +++ b/google/cloud/edgenetwork/v1/mocks/mock_edge_network_connection.h @@ -527,6 +527,14 @@ class MockEdgeNetworkConnection : public edgenetwork_v1::EdgeNetworkConnection { future>, DeleteRouter, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/eventarc/BUILD.bazel b/google/cloud/eventarc/BUILD.bazel index 9ce87af2e1f78..8aff6c0edd08f 100644 --- a/google/cloud/eventarc/BUILD.bazel +++ b/google/cloud/eventarc/BUILD.bazel @@ -27,6 +27,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/eventarc/publishing/v1:publishing_cc_grpc", "@com_google_googleapis//google/cloud/eventarc/v1:eventarc_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/eventarc/v1/eventarc_client.cc b/google/cloud/eventarc/v1/eventarc_client.cc index a44f419ee76e5..3f85cbd64a632 100644 --- a/google/cloud/eventarc/v1/eventarc_client.cc +++ b/google/cloud/eventarc/v1/eventarc_client.cc @@ -550,6 +550,37 @@ EventarcClient::UpdateGoogleChannelConfig( return connection_->UpdateGoogleChannelConfig(request); } +StreamRange EventarcClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr EventarcClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr EventarcClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr EventarcClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +EventarcClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace eventarc_v1 } // namespace cloud diff --git a/google/cloud/eventarc/v1/eventarc_client.h b/google/cloud/eventarc/v1/eventarc_client.h index b2d9c9d4f09b4..f44772287d004 100644 --- a/google/cloud/eventarc/v1/eventarc_client.h +++ b/google/cloud/eventarc/v1/eventarc_client.h @@ -1669,6 +1669,178 @@ class EventarcClient { request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/eventarc/v1/eventarc_connection.cc b/google/cloud/eventarc/v1/eventarc_connection.cc index c4e262959948f..a28feda617f75 100644 --- a/google/cloud/eventarc/v1/eventarc_connection.cc +++ b/google/cloud/eventarc/v1/eventarc_connection.cc @@ -277,6 +277,35 @@ EventarcConnection::UpdateGoogleChannelConfig( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +EventarcConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr EventarcConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr EventarcConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr EventarcConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +EventarcConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeEventarcConnection(Options options) { internal::CheckExpectedOptions +#include +#include #include #include @@ -306,6 +308,21 @@ class EventarcConnection { UpdateGoogleChannelConfig( google::cloud::eventarc::v1::UpdateGoogleChannelConfigRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/eventarc/v1/eventarc_connection_idempotency_policy.cc b/google/cloud/eventarc/v1/eventarc_connection_idempotency_policy.cc index 73822f3fa1100..72c7138b8e302 100644 --- a/google/cloud/eventarc/v1/eventarc_connection_idempotency_policy.cc +++ b/google/cloud/eventarc/v1/eventarc_connection_idempotency_policy.cc @@ -124,6 +124,32 @@ Idempotency EventarcConnectionIdempotencyPolicy::UpdateGoogleChannelConfig( return Idempotency::kNonIdempotent; } +Idempotency EventarcConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency EventarcConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency EventarcConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency EventarcConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency EventarcConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultEventarcConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/eventarc/v1/eventarc_connection_idempotency_policy.h b/google/cloud/eventarc/v1/eventarc_connection_idempotency_policy.h index 932873fad7bf9..00d8c19fe4a92 100644 --- a/google/cloud/eventarc/v1/eventarc_connection_idempotency_policy.h +++ b/google/cloud/eventarc/v1/eventarc_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -93,6 +95,21 @@ class EventarcConnectionIdempotencyPolicy { virtual google::cloud::Idempotency UpdateGoogleChannelConfig( google::cloud::eventarc::v1::UpdateGoogleChannelConfigRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/eventarc/v1/internal/eventarc_auth_decorator.cc b/google/cloud/eventarc/v1/internal/eventarc_auth_decorator.cc index a2ef14f9b88b0..1ce99c9dd6a40 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_auth_decorator.cc +++ b/google/cloud/eventarc/v1/internal/eventarc_auth_decorator.cc @@ -347,6 +347,48 @@ EventarcAuth::UpdateGoogleChannelConfig( return child_->UpdateGoogleChannelConfig(context, options, request); } +StatusOr +EventarcAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr EventarcAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr EventarcAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr EventarcAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +EventarcAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> EventarcAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/eventarc/v1/internal/eventarc_auth_decorator.h b/google/cloud/eventarc/v1/internal/eventarc_auth_decorator.h index fff592423e36e..cd64c2f166043 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_auth_decorator.h +++ b/google/cloud/eventarc/v1/internal/eventarc_auth_decorator.h @@ -183,6 +183,26 @@ class EventarcAuth : public EventarcStub { google::cloud::eventarc::v1::UpdateGoogleChannelConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/eventarc/v1/internal/eventarc_connection_impl.cc b/google/cloud/eventarc/v1/internal/eventarc_connection_impl.cc index 7b2d53970afe8..37e610b941caf 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_connection_impl.cc +++ b/google/cloud/eventarc/v1/internal/eventarc_connection_impl.cc @@ -1012,6 +1012,93 @@ EventarcConnectionImpl::UpdateGoogleChannelConfig( *current, request, __func__); } +StreamRange +EventarcConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr EventarcConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr EventarcConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr EventarcConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +EventarcConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace eventarc_v1_internal } // namespace cloud diff --git a/google/cloud/eventarc/v1/internal/eventarc_connection_impl.h b/google/cloud/eventarc/v1/internal/eventarc_connection_impl.h index 326ccd3f700c4..1eb04d1f2d0bc 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_connection_impl.h +++ b/google/cloud/eventarc/v1/internal/eventarc_connection_impl.h @@ -188,6 +188,21 @@ class EventarcConnectionImpl : public eventarc_v1::EventarcConnection { google::cloud::eventarc::v1::UpdateGoogleChannelConfigRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/eventarc/v1/internal/eventarc_logging_decorator.cc b/google/cloud/eventarc/v1/internal/eventarc_logging_decorator.cc index f72914e4a202e..29e1d985e4771 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_logging_decorator.cc +++ b/google/cloud/eventarc/v1/internal/eventarc_logging_decorator.cc @@ -400,6 +400,63 @@ EventarcLogging::UpdateGoogleChannelConfig( context, options, request, __func__, tracing_options_); } +StatusOr +EventarcLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EventarcLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EventarcLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EventarcLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +EventarcLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> EventarcLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/eventarc/v1/internal/eventarc_logging_decorator.h b/google/cloud/eventarc/v1/internal/eventarc_logging_decorator.h index baac262040137..5a98f1c338b8b 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_logging_decorator.h +++ b/google/cloud/eventarc/v1/internal/eventarc_logging_decorator.h @@ -183,6 +183,26 @@ class EventarcLogging : public EventarcStub { google::cloud::eventarc::v1::UpdateGoogleChannelConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/eventarc/v1/internal/eventarc_metadata_decorator.cc b/google/cloud/eventarc/v1/internal/eventarc_metadata_decorator.cc index ac56e67b92852..fef6bf27f3155 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_metadata_decorator.cc +++ b/google/cloud/eventarc/v1/internal/eventarc_metadata_decorator.cc @@ -304,6 +304,51 @@ EventarcMetadata::UpdateGoogleChannelConfig( return child_->UpdateGoogleChannelConfig(context, options, request); } +StatusOr +EventarcMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr EventarcMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr EventarcMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr EventarcMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +EventarcMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> EventarcMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/eventarc/v1/internal/eventarc_metadata_decorator.h b/google/cloud/eventarc/v1/internal/eventarc_metadata_decorator.h index f5ae25e47e9d6..ef6d365d14ce3 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_metadata_decorator.h +++ b/google/cloud/eventarc/v1/internal/eventarc_metadata_decorator.h @@ -183,6 +183,26 @@ class EventarcMetadata : public EventarcStub { google::cloud::eventarc::v1::UpdateGoogleChannelConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/eventarc/v1/internal/eventarc_stub.cc b/google/cloud/eventarc/v1/internal/eventarc_stub.cc index 3115c4fcacb72..c316d65e4b4ff 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_stub.cc +++ b/google/cloud/eventarc/v1/internal/eventarc_stub.cc @@ -395,6 +395,64 @@ DefaultEventarcStub::UpdateGoogleChannelConfig( return response; } +StatusOr +DefaultEventarcStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultEventarcStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultEventarcStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultEventarcStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultEventarcStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultEventarcStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/eventarc/v1/internal/eventarc_stub.h b/google/cloud/eventarc/v1/internal/eventarc_stub.h index 4d3af1b41fa86..d88af4d300309 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_stub.h +++ b/google/cloud/eventarc/v1/internal/eventarc_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -175,6 +179,28 @@ class EventarcStub { google::cloud::eventarc::v1::UpdateGoogleChannelConfigRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -193,9 +219,15 @@ class DefaultEventarcStub : public EventarcStub { DefaultEventarcStub( std::unique_ptr grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr GetTrigger( grpc::ClientContext& context, Options const& options, @@ -341,6 +373,26 @@ class DefaultEventarcStub : public EventarcStub { google::cloud::eventarc::v1::UpdateGoogleChannelConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -356,6 +408,9 @@ class DefaultEventarcStub : public EventarcStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/eventarc/v1/internal/eventarc_stub_factory.cc b/google/cloud/eventarc/v1/internal/eventarc_stub_factory.cc index 98cbacf94c0f4..0510dbdde95f1 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_stub_factory.cc +++ b/google/cloud/eventarc/v1/internal/eventarc_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,8 +46,12 @@ std::shared_ptr CreateDefaultEventarcStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::eventarc::v1::Eventarc::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/eventarc/v1/internal/eventarc_tracing_connection.cc b/google/cloud/eventarc/v1/internal/eventarc_tracing_connection.cc index bc4f0e380353f..4099003e5f5c5 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_tracing_connection.cc +++ b/google/cloud/eventarc/v1/internal/eventarc_tracing_connection.cc @@ -365,6 +365,51 @@ EventarcTracingConnection::UpdateGoogleChannelConfig( return internal::EndSpan(*span, child_->UpdateGoogleChannelConfig(request)); } +StreamRange +EventarcTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("eventarc_v1::EventarcConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +EventarcTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("eventarc_v1::EventarcConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr EventarcTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("eventarc_v1::EventarcConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr EventarcTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("eventarc_v1::EventarcConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +EventarcTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = + internal::MakeSpan("eventarc_v1::EventarcConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeEventarcTracingConnection( diff --git a/google/cloud/eventarc/v1/internal/eventarc_tracing_connection.h b/google/cloud/eventarc/v1/internal/eventarc_tracing_connection.h index 37a629a79659d..65468bc400e93 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_tracing_connection.h +++ b/google/cloud/eventarc/v1/internal/eventarc_tracing_connection.h @@ -176,6 +176,21 @@ class EventarcTracingConnection : public eventarc_v1::EventarcConnection { google::cloud::eventarc::v1::UpdateGoogleChannelConfigRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/eventarc/v1/internal/eventarc_tracing_stub.cc b/google/cloud/eventarc/v1/internal/eventarc_tracing_stub.cc index b37ab2b9e011f..cdb7b9ba02be2 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_tracing_stub.cc +++ b/google/cloud/eventarc/v1/internal/eventarc_tracing_stub.cc @@ -363,6 +363,63 @@ EventarcTracingStub::UpdateGoogleChannelConfig( child_->UpdateGoogleChannelConfig(context, options, request)); } +StatusOr +EventarcTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.eventarc.v1.Eventarc", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr EventarcTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.eventarc.v1.Eventarc", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr EventarcTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.eventarc.v1.Eventarc", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr EventarcTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.eventarc.v1.Eventarc", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +EventarcTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.eventarc.v1.Eventarc", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> EventarcTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/eventarc/v1/internal/eventarc_tracing_stub.h b/google/cloud/eventarc/v1/internal/eventarc_tracing_stub.h index fd72777de32a0..775d511e7f3a7 100644 --- a/google/cloud/eventarc/v1/internal/eventarc_tracing_stub.h +++ b/google/cloud/eventarc/v1/internal/eventarc_tracing_stub.h @@ -182,6 +182,26 @@ class EventarcTracingStub : public EventarcStub { google::cloud::eventarc::v1::UpdateGoogleChannelConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/eventarc/v1/mocks/mock_eventarc_connection.h b/google/cloud/eventarc/v1/mocks/mock_eventarc_connection.h index cfd8a87f47122..cbf814cb35afb 100644 --- a/google/cloud/eventarc/v1/mocks/mock_eventarc_connection.h +++ b/google/cloud/eventarc/v1/mocks/mock_eventarc_connection.h @@ -407,6 +407,27 @@ class MockEventarcConnection : public eventarc_v1::EventarcConnection { (google::cloud::eventarc::v1::UpdateGoogleChannelConfigRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/filestore/BUILD.bazel b/google/cloud/filestore/BUILD.bazel index d90f41dfd7641..c648a3e9b6b3e 100644 --- a/google/cloud/filestore/BUILD.bazel +++ b/google/cloud/filestore/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/filestore/v1:filestore_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/filestore/v1/cloud_filestore_manager_client.cc b/google/cloud/filestore/v1/cloud_filestore_manager_client.cc index c376e38cecb4d..ec03bee8b5e4d 100644 --- a/google/cloud/filestore/v1/cloud_filestore_manager_client.cc +++ b/google/cloud/filestore/v1/cloud_filestore_manager_client.cc @@ -592,6 +592,20 @@ CloudFilestoreManagerClient::UpdateBackup( return connection_->UpdateBackup(operation); } +StreamRange +CloudFilestoreManagerClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +CloudFilestoreManagerClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace filestore_v1 } // namespace cloud diff --git a/google/cloud/filestore/v1/cloud_filestore_manager_client.h b/google/cloud/filestore/v1/cloud_filestore_manager_client.h index 665ce4d12c62f..1b360141f3ac5 100644 --- a/google/cloud/filestore/v1/cloud_filestore_manager_client.h +++ b/google/cloud/filestore/v1/cloud_filestore_manager_client.h @@ -1727,6 +1727,76 @@ class CloudFilestoreManagerClient { future> UpdateBackup( google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/filestore/v1/cloud_filestore_manager_connection.cc b/google/cloud/filestore/v1/cloud_filestore_manager_connection.cc index e4f8dc73b2816..24e1a82e99488 100644 --- a/google/cloud/filestore/v1/cloud_filestore_manager_connection.cc +++ b/google/cloud/filestore/v1/cloud_filestore_manager_connection.cc @@ -333,6 +333,20 @@ CloudFilestoreManagerConnection::UpdateBackup( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +CloudFilestoreManagerConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +CloudFilestoreManagerConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCloudFilestoreManagerConnection(Options options) { internal::CheckExpectedOptions +#include #include #include @@ -328,6 +329,12 @@ class CloudFilestoreManagerConnection { virtual future> UpdateBackup( google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/filestore/v1/cloud_filestore_manager_connection_idempotency_policy.cc b/google/cloud/filestore/v1/cloud_filestore_manager_connection_idempotency_policy.cc index e24ffeff8a546..ae1a2125ebfb8 100644 --- a/google/cloud/filestore/v1/cloud_filestore_manager_connection_idempotency_policy.cc +++ b/google/cloud/filestore/v1/cloud_filestore_manager_connection_idempotency_policy.cc @@ -120,6 +120,16 @@ Idempotency CloudFilestoreManagerConnectionIdempotencyPolicy::UpdateBackup( return Idempotency::kNonIdempotent; } +Idempotency CloudFilestoreManagerConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CloudFilestoreManagerConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultCloudFilestoreManagerConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/filestore/v1/cloud_filestore_manager_connection_idempotency_policy.h b/google/cloud/filestore/v1/cloud_filestore_manager_connection_idempotency_policy.h index 5d4743eae2520..ad2d916b57367 100644 --- a/google/cloud/filestore/v1/cloud_filestore_manager_connection_idempotency_policy.h +++ b/google/cloud/filestore/v1/cloud_filestore_manager_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -87,6 +88,12 @@ class CloudFilestoreManagerConnectionIdempotencyPolicy { virtual google::cloud::Idempotency UpdateBackup( google::cloud::filestore::v1::UpdateBackupRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/filestore/v1/internal/cloud_filestore_manager_auth_decorator.cc b/google/cloud/filestore/v1/internal/cloud_filestore_manager_auth_decorator.cc index 1d5dd99d4a8ce..ea6664ae5935f 100644 --- a/google/cloud/filestore/v1/internal/cloud_filestore_manager_auth_decorator.cc +++ b/google/cloud/filestore/v1/internal/cloud_filestore_manager_auth_decorator.cc @@ -404,6 +404,24 @@ CloudFilestoreManagerAuth::UpdateBackup( return child_->UpdateBackup(context, options, request); } +StatusOr +CloudFilestoreManagerAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +CloudFilestoreManagerAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> CloudFilestoreManagerAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/filestore/v1/internal/cloud_filestore_manager_auth_decorator.h b/google/cloud/filestore/v1/internal/cloud_filestore_manager_auth_decorator.h index 32aad387b89ac..a429f87c1a44d 100644 --- a/google/cloud/filestore/v1/internal/cloud_filestore_manager_auth_decorator.h +++ b/google/cloud/filestore/v1/internal/cloud_filestore_manager_auth_decorator.h @@ -197,6 +197,14 @@ class CloudFilestoreManagerAuth : public CloudFilestoreManagerStub { google::cloud::filestore::v1::UpdateBackupRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/filestore/v1/internal/cloud_filestore_manager_connection_impl.cc b/google/cloud/filestore/v1/internal/cloud_filestore_manager_connection_impl.cc index 26723af53e34a..ab2f1f43cfd01 100644 --- a/google/cloud/filestore/v1/internal/cloud_filestore_manager_connection_impl.cc +++ b/google/cloud/filestore/v1/internal/cloud_filestore_manager_connection_impl.cc @@ -1213,6 +1213,54 @@ CloudFilestoreManagerConnectionImpl::UpdateBackup( polling_policy(*current), __func__); } +StreamRange +CloudFilestoreManagerConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +CloudFilestoreManagerConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace filestore_v1_internal } // namespace cloud diff --git a/google/cloud/filestore/v1/internal/cloud_filestore_manager_connection_impl.h b/google/cloud/filestore/v1/internal/cloud_filestore_manager_connection_impl.h index 678449a5a53ea..c8eecf6f0d3a6 100644 --- a/google/cloud/filestore/v1/internal/cloud_filestore_manager_connection_impl.h +++ b/google/cloud/filestore/v1/internal/cloud_filestore_manager_connection_impl.h @@ -202,6 +202,12 @@ class CloudFilestoreManagerConnectionImpl future> UpdateBackup( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/filestore/v1/internal/cloud_filestore_manager_logging_decorator.cc b/google/cloud/filestore/v1/internal/cloud_filestore_manager_logging_decorator.cc index b139c0aada9b9..bb1af3491dd6a 100644 --- a/google/cloud/filestore/v1/internal/cloud_filestore_manager_logging_decorator.cc +++ b/google/cloud/filestore/v1/internal/cloud_filestore_manager_logging_decorator.cc @@ -455,6 +455,30 @@ CloudFilestoreManagerLogging::UpdateBackup( context, options, request, __func__, tracing_options_); } +StatusOr +CloudFilestoreManagerLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +CloudFilestoreManagerLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> CloudFilestoreManagerLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/filestore/v1/internal/cloud_filestore_manager_logging_decorator.h b/google/cloud/filestore/v1/internal/cloud_filestore_manager_logging_decorator.h index 64db588b3ed72..6232e59632997 100644 --- a/google/cloud/filestore/v1/internal/cloud_filestore_manager_logging_decorator.h +++ b/google/cloud/filestore/v1/internal/cloud_filestore_manager_logging_decorator.h @@ -197,6 +197,14 @@ class CloudFilestoreManagerLogging : public CloudFilestoreManagerStub { google::cloud::filestore::v1::UpdateBackupRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/filestore/v1/internal/cloud_filestore_manager_metadata_decorator.cc b/google/cloud/filestore/v1/internal/cloud_filestore_manager_metadata_decorator.cc index c9ad8fe382885..64bcac0cdc826 100644 --- a/google/cloud/filestore/v1/internal/cloud_filestore_manager_metadata_decorator.cc +++ b/google/cloud/filestore/v1/internal/cloud_filestore_manager_metadata_decorator.cc @@ -335,6 +335,24 @@ CloudFilestoreManagerMetadata::UpdateBackup( return child_->UpdateBackup(context, options, request); } +StatusOr +CloudFilestoreManagerMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +CloudFilestoreManagerMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> CloudFilestoreManagerMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/filestore/v1/internal/cloud_filestore_manager_metadata_decorator.h b/google/cloud/filestore/v1/internal/cloud_filestore_manager_metadata_decorator.h index 82d76c56ca90b..351573a0fdc5a 100644 --- a/google/cloud/filestore/v1/internal/cloud_filestore_manager_metadata_decorator.h +++ b/google/cloud/filestore/v1/internal/cloud_filestore_manager_metadata_decorator.h @@ -198,6 +198,14 @@ class CloudFilestoreManagerMetadata : public CloudFilestoreManagerStub { google::cloud::filestore::v1::UpdateBackupRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/filestore/v1/internal/cloud_filestore_manager_stub.cc b/google/cloud/filestore/v1/internal/cloud_filestore_manager_stub.cc index 20cb54a16329d..3601074dbdb59 100644 --- a/google/cloud/filestore/v1/internal/cloud_filestore_manager_stub.cc +++ b/google/cloud/filestore/v1/internal/cloud_filestore_manager_stub.cc @@ -434,6 +434,30 @@ DefaultCloudFilestoreManagerStub::UpdateBackup( return response; } +StatusOr +DefaultCloudFilestoreManagerStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultCloudFilestoreManagerStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultCloudFilestoreManagerStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/filestore/v1/internal/cloud_filestore_manager_stub.h b/google/cloud/filestore/v1/internal/cloud_filestore_manager_stub.h index 18c6a1723f4de..dc45ac7eaf579 100644 --- a/google/cloud/filestore/v1/internal/cloud_filestore_manager_stub.h +++ b/google/cloud/filestore/v1/internal/cloud_filestore_manager_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -175,6 +177,15 @@ class CloudFilestoreManagerStub { grpc::ClientContext& context, Options options, google::cloud::filestore::v1::UpdateBackupRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -194,9 +205,13 @@ class DefaultCloudFilestoreManagerStub : public CloudFilestoreManagerStub { std::unique_ptr< google::cloud::filestore::v1::CloudFilestoreManager::StubInterface> grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListInstances( grpc::ClientContext& context, Options const& options, @@ -356,6 +371,14 @@ class DefaultCloudFilestoreManagerStub : public CloudFilestoreManagerStub { google::cloud::filestore::v1::UpdateBackupRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -372,6 +395,8 @@ class DefaultCloudFilestoreManagerStub : public CloudFilestoreManagerStub { std::unique_ptr< google::cloud::filestore::v1::CloudFilestoreManager::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/filestore/v1/internal/cloud_filestore_manager_stub_factory.cc b/google/cloud/filestore/v1/internal/cloud_filestore_manager_stub_factory.cc index f1b4980895348..7175016186200 100644 --- a/google/cloud/filestore/v1/internal/cloud_filestore_manager_stub_factory.cc +++ b/google/cloud/filestore/v1/internal/cloud_filestore_manager_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -45,9 +46,11 @@ CreateDefaultCloudFilestoreManagerStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::filestore::v1::CloudFilestoreManager::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/filestore/v1/internal/cloud_filestore_manager_tracing_connection.cc b/google/cloud/filestore/v1/internal/cloud_filestore_manager_tracing_connection.cc index 91df184434640..207be775b17a4 100644 --- a/google/cloud/filestore/v1/internal/cloud_filestore_manager_tracing_connection.cc +++ b/google/cloud/filestore/v1/internal/cloud_filestore_manager_tracing_connection.cc @@ -409,6 +409,26 @@ CloudFilestoreManagerTracingConnection::UpdateBackup( return internal::EndSpan(std::move(span), child_->UpdateBackup(operation)); } +StreamRange +CloudFilestoreManagerTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "filestore_v1::CloudFilestoreManagerConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CloudFilestoreManagerTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "filestore_v1::CloudFilestoreManagerConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/filestore/v1/internal/cloud_filestore_manager_tracing_connection.h b/google/cloud/filestore/v1/internal/cloud_filestore_manager_tracing_connection.h index 1bc4732b60614..2e0dbec089182 100644 --- a/google/cloud/filestore/v1/internal/cloud_filestore_manager_tracing_connection.h +++ b/google/cloud/filestore/v1/internal/cloud_filestore_manager_tracing_connection.h @@ -190,6 +190,12 @@ class CloudFilestoreManagerTracingConnection future> UpdateBackup( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/filestore/v1/internal/cloud_filestore_manager_tracing_stub.cc b/google/cloud/filestore/v1/internal/cloud_filestore_manager_tracing_stub.cc index c4f2ec061d6ae..c075c7d70ba62 100644 --- a/google/cloud/filestore/v1/internal/cloud_filestore_manager_tracing_stub.cc +++ b/google/cloud/filestore/v1/internal/cloud_filestore_manager_tracing_stub.cc @@ -398,6 +398,30 @@ CloudFilestoreManagerTracingStub::UpdateBackup( child_->UpdateBackup(context, options, request)); } +StatusOr +CloudFilestoreManagerTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.filestore.v1.CloudFilestoreManager", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +CloudFilestoreManagerTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.filestore.v1.CloudFilestoreManager", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> CloudFilestoreManagerTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/filestore/v1/internal/cloud_filestore_manager_tracing_stub.h b/google/cloud/filestore/v1/internal/cloud_filestore_manager_tracing_stub.h index 1a83c3746a7a8..0ae098b7e96d0 100644 --- a/google/cloud/filestore/v1/internal/cloud_filestore_manager_tracing_stub.h +++ b/google/cloud/filestore/v1/internal/cloud_filestore_manager_tracing_stub.h @@ -197,6 +197,14 @@ class CloudFilestoreManagerTracingStub : public CloudFilestoreManagerStub { google::cloud::filestore::v1::UpdateBackupRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/filestore/v1/mocks/mock_cloud_filestore_manager_connection.h b/google/cloud/filestore/v1/mocks/mock_cloud_filestore_manager_connection.h index 7418cf8d8e579..da5eacecd24e3 100644 --- a/google/cloud/filestore/v1/mocks/mock_cloud_filestore_manager_connection.h +++ b/google/cloud/filestore/v1/mocks/mock_cloud_filestore_manager_connection.h @@ -492,6 +492,14 @@ class MockCloudFilestoreManagerConnection MOCK_METHOD(future>, UpdateBackup, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/functions/BUILD.bazel b/google/cloud/functions/BUILD.bazel index 6cc8a2816c353..0820f405ba538 100644 --- a/google/cloud/functions/BUILD.bazel +++ b/google/cloud/functions/BUILD.bazel @@ -27,6 +27,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/functions/v1:functions_cc_grpc", "@com_google_googleapis//google/cloud/functions/v2:functions_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/functions/v1/cloud_functions_client.cc b/google/cloud/functions/v1/cloud_functions_client.cc index 00ef25e0e35c2..1efac6909c294 100644 --- a/google/cloud/functions/v1/cloud_functions_client.cc +++ b/google/cloud/functions/v1/cloud_functions_client.cc @@ -241,6 +241,13 @@ CloudFunctionsServiceClient::TestIamPermissions( return connection_->TestIamPermissions(request); } +StreamRange +CloudFunctionsServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace functions_v1 } // namespace cloud diff --git a/google/cloud/functions/v1/cloud_functions_client.h b/google/cloud/functions/v1/cloud_functions_client.h index db8fd79d27d2c..0e999cab602eb 100644 --- a/google/cloud/functions/v1/cloud_functions_client.h +++ b/google/cloud/functions/v1/cloud_functions_client.h @@ -793,6 +793,45 @@ class CloudFunctionsServiceClient { google::iam::v1::TestIamPermissionsRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/functions/v1/cloud_functions_connection.cc b/google/cloud/functions/v1/cloud_functions_connection.cc index 03122a29fbe92..4fb290c1e671d 100644 --- a/google/cloud/functions/v1/cloud_functions_connection.cc +++ b/google/cloud/functions/v1/cloud_functions_connection.cc @@ -155,6 +155,14 @@ CloudFunctionsServiceConnection::TestIamPermissions( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +CloudFunctionsServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + std::shared_ptr MakeCloudFunctionsServiceConnection(Options options) { internal::CheckExpectedOptions #include +#include +#include #include #include @@ -252,6 +254,9 @@ class CloudFunctionsServiceConnection { virtual StatusOr TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); }; /** diff --git a/google/cloud/functions/v1/cloud_functions_connection_idempotency_policy.cc b/google/cloud/functions/v1/cloud_functions_connection_idempotency_policy.cc index def42c84763a6..4c6ef55226f54 100644 --- a/google/cloud/functions/v1/cloud_functions_connection_idempotency_policy.cc +++ b/google/cloud/functions/v1/cloud_functions_connection_idempotency_policy.cc @@ -93,6 +93,11 @@ CloudFunctionsServiceConnectionIdempotencyPolicy::TestIamPermissions( return Idempotency::kIdempotent; } +Idempotency CloudFunctionsServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultCloudFunctionsServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/functions/v1/cloud_functions_connection_idempotency_policy.h b/google/cloud/functions/v1/cloud_functions_connection_idempotency_policy.h index 7dd25c8e4a35d..7e2223008d963 100644 --- a/google/cloud/functions/v1/cloud_functions_connection_idempotency_policy.h +++ b/google/cloud/functions/v1/cloud_functions_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -69,6 +70,9 @@ class CloudFunctionsServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); }; std::unique_ptr diff --git a/google/cloud/functions/v1/internal/cloud_functions_auth_decorator.cc b/google/cloud/functions/v1/internal/cloud_functions_auth_decorator.cc index 2011a630871b7..02bdb7b64abde 100644 --- a/google/cloud/functions/v1/internal/cloud_functions_auth_decorator.cc +++ b/google/cloud/functions/v1/internal/cloud_functions_auth_decorator.cc @@ -188,6 +188,15 @@ CloudFunctionsServiceAuth::TestIamPermissions( return child_->TestIamPermissions(context, options, request); } +StatusOr +CloudFunctionsServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + future> CloudFunctionsServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/functions/v1/internal/cloud_functions_auth_decorator.h b/google/cloud/functions/v1/internal/cloud_functions_auth_decorator.h index 7154f62f8d579..68a40c2d629e6 100644 --- a/google/cloud/functions/v1/internal/cloud_functions_auth_decorator.h +++ b/google/cloud/functions/v1/internal/cloud_functions_auth_decorator.h @@ -113,6 +113,10 @@ class CloudFunctionsServiceAuth : public CloudFunctionsServiceStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/functions/v1/internal/cloud_functions_connection_impl.cc b/google/cloud/functions/v1/internal/cloud_functions_connection_impl.cc index 7809d8230f91d..8d22080829efd 100644 --- a/google/cloud/functions/v1/internal/cloud_functions_connection_impl.cc +++ b/google/cloud/functions/v1/internal/cloud_functions_connection_impl.cc @@ -478,6 +478,40 @@ CloudFunctionsServiceConnectionImpl::TestIamPermissions( *current, request, __func__); } +StreamRange +CloudFunctionsServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace functions_v1_internal } // namespace cloud diff --git a/google/cloud/functions/v1/internal/cloud_functions_connection_impl.h b/google/cloud/functions/v1/internal/cloud_functions_connection_impl.h index df0d4d2fc7690..6060256f3bb44 100644 --- a/google/cloud/functions/v1/internal/cloud_functions_connection_impl.h +++ b/google/cloud/functions/v1/internal/cloud_functions_connection_impl.h @@ -117,6 +117,9 @@ class CloudFunctionsServiceConnectionImpl StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/functions/v1/internal/cloud_functions_logging_decorator.cc b/google/cloud/functions/v1/internal/cloud_functions_logging_decorator.cc index 064239680eb74..f5682be306626 100644 --- a/google/cloud/functions/v1/internal/cloud_functions_logging_decorator.cc +++ b/google/cloud/functions/v1/internal/cloud_functions_logging_decorator.cc @@ -228,6 +228,18 @@ CloudFunctionsServiceLogging::TestIamPermissions( context, options, request, __func__, tracing_options_); } +StatusOr +CloudFunctionsServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> CloudFunctionsServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/functions/v1/internal/cloud_functions_logging_decorator.h b/google/cloud/functions/v1/internal/cloud_functions_logging_decorator.h index f20a93efab6c0..1e113b8218654 100644 --- a/google/cloud/functions/v1/internal/cloud_functions_logging_decorator.h +++ b/google/cloud/functions/v1/internal/cloud_functions_logging_decorator.h @@ -113,6 +113,10 @@ class CloudFunctionsServiceLogging : public CloudFunctionsServiceStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/functions/v1/internal/cloud_functions_metadata_decorator.cc b/google/cloud/functions/v1/internal/cloud_functions_metadata_decorator.cc index 5cd5a274186f9..b4c97ae910aca 100644 --- a/google/cloud/functions/v1/internal/cloud_functions_metadata_decorator.cc +++ b/google/cloud/functions/v1/internal/cloud_functions_metadata_decorator.cc @@ -184,6 +184,15 @@ CloudFunctionsServiceMetadata::TestIamPermissions( return child_->TestIamPermissions(context, options, request); } +StatusOr +CloudFunctionsServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + future> CloudFunctionsServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/functions/v1/internal/cloud_functions_metadata_decorator.h b/google/cloud/functions/v1/internal/cloud_functions_metadata_decorator.h index 05db508fd4078..7e5f93ca2f978 100644 --- a/google/cloud/functions/v1/internal/cloud_functions_metadata_decorator.h +++ b/google/cloud/functions/v1/internal/cloud_functions_metadata_decorator.h @@ -114,6 +114,10 @@ class CloudFunctionsServiceMetadata : public CloudFunctionsServiceStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/functions/v1/internal/cloud_functions_stub.cc b/google/cloud/functions/v1/internal/cloud_functions_stub.cc index cda91c547eab1..8e37275e22f95 100644 --- a/google/cloud/functions/v1/internal/cloud_functions_stub.cc +++ b/google/cloud/functions/v1/internal/cloud_functions_stub.cc @@ -217,6 +217,18 @@ DefaultCloudFunctionsServiceStub::TestIamPermissions( return response; } +StatusOr +DefaultCloudFunctionsServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultCloudFunctionsServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/functions/v1/internal/cloud_functions_stub.h b/google/cloud/functions/v1/internal/cloud_functions_stub.h index 30ebc6ab44bf6..21481f5652f47 100644 --- a/google/cloud/functions/v1/internal/cloud_functions_stub.h +++ b/google/cloud/functions/v1/internal/cloud_functions_stub.h @@ -26,6 +26,9 @@ #include "google/cloud/version.h" #include #include +#include +#include +#include #include #include #include @@ -108,6 +111,11 @@ class CloudFunctionsServiceStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -127,9 +135,13 @@ class DefaultCloudFunctionsServiceStub : public CloudFunctionsServiceStub { std::unique_ptr< google::cloud::functions::v1::CloudFunctionsService::StubInterface> grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListFunctions( grpc::ClientContext& context, Options const& options, @@ -205,6 +217,10 @@ class DefaultCloudFunctionsServiceStub : public CloudFunctionsServiceStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -221,6 +237,8 @@ class DefaultCloudFunctionsServiceStub : public CloudFunctionsServiceStub { std::unique_ptr< google::cloud::functions::v1::CloudFunctionsService::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/functions/v1/internal/cloud_functions_stub_factory.cc b/google/cloud/functions/v1/internal/cloud_functions_stub_factory.cc index ae778b2c554ad..6a53364e93f14 100644 --- a/google/cloud/functions/v1/internal/cloud_functions_stub_factory.cc +++ b/google/cloud/functions/v1/internal/cloud_functions_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -45,9 +46,11 @@ CreateDefaultCloudFunctionsServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::functions::v1::CloudFunctionsService::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/functions/v1/internal/cloud_functions_tracing_connection.cc b/google/cloud/functions/v1/internal/cloud_functions_tracing_connection.cc index 4746e1f6a1dfe..36bcc2cc63598 100644 --- a/google/cloud/functions/v1/internal/cloud_functions_tracing_connection.cc +++ b/google/cloud/functions/v1/internal/cloud_functions_tracing_connection.cc @@ -195,6 +195,17 @@ CloudFunctionsServiceTracingConnection::TestIamPermissions( return internal::EndSpan(*span, child_->TestIamPermissions(request)); } +StreamRange +CloudFunctionsServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "functions_v1::CloudFunctionsServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/functions/v1/internal/cloud_functions_tracing_connection.h b/google/cloud/functions/v1/internal/cloud_functions_tracing_connection.h index 393afcc4165bc..cef4a880d1fb9 100644 --- a/google/cloud/functions/v1/internal/cloud_functions_tracing_connection.h +++ b/google/cloud/functions/v1/internal/cloud_functions_tracing_connection.h @@ -105,6 +105,9 @@ class CloudFunctionsServiceTracingConnection StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/functions/v1/internal/cloud_functions_tracing_stub.cc b/google/cloud/functions/v1/internal/cloud_functions_tracing_stub.cc index fce9174432ec2..ea161fc7101aa 100644 --- a/google/cloud/functions/v1/internal/cloud_functions_tracing_stub.cc +++ b/google/cloud/functions/v1/internal/cloud_functions_tracing_stub.cc @@ -209,6 +209,18 @@ CloudFunctionsServiceTracingStub::TestIamPermissions( context, *span, child_->TestIamPermissions(context, options, request)); } +StatusOr +CloudFunctionsServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.functions.v1.CloudFunctionsService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + future> CloudFunctionsServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/functions/v1/internal/cloud_functions_tracing_stub.h b/google/cloud/functions/v1/internal/cloud_functions_tracing_stub.h index 3f5d21d16b2fb..f28a6708893f5 100644 --- a/google/cloud/functions/v1/internal/cloud_functions_tracing_stub.h +++ b/google/cloud/functions/v1/internal/cloud_functions_tracing_stub.h @@ -113,6 +113,10 @@ class CloudFunctionsServiceTracingStub : public CloudFunctionsServiceStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/functions/v1/mocks/mock_cloud_functions_connection.h b/google/cloud/functions/v1/mocks/mock_cloud_functions_connection.h index ccdaa78d3de91..f1a53454596ef 100644 --- a/google/cloud/functions/v1/mocks/mock_cloud_functions_connection.h +++ b/google/cloud/functions/v1/mocks/mock_cloud_functions_connection.h @@ -205,6 +205,10 @@ class MockCloudFunctionsServiceConnection TestIamPermissions, (google::iam::v1::TestIamPermissionsRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/functions/v2/function_client.cc b/google/cloud/functions/v2/function_client.cc index 7dfe49d29f324..657bc10f27f3c 100644 --- a/google/cloud/functions/v2/function_client.cc +++ b/google/cloud/functions/v2/function_client.cc @@ -226,6 +226,32 @@ FunctionServiceClient::ListRuntimes( return connection_->ListRuntimes(request); } +StreamRange +FunctionServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr FunctionServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr FunctionServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +FunctionServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace functions_v2 } // namespace cloud diff --git a/google/cloud/functions/v2/function_client.h b/google/cloud/functions/v2/function_client.h index 8f2e4efe6489a..8dc36b0f59e47 100644 --- a/google/cloud/functions/v2/function_client.h +++ b/google/cloud/functions/v2/function_client.h @@ -737,6 +737,147 @@ class FunctionServiceClient { google::cloud::functions::v2::ListRuntimesRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/functions/v2/function_connection.cc b/google/cloud/functions/v2/function_connection.cc index 04e57126f358a..d563dbb701ff8 100644 --- a/google/cloud/functions/v2/function_connection.cc +++ b/google/cloud/functions/v2/function_connection.cc @@ -139,6 +139,30 @@ FunctionServiceConnection::ListRuntimes( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +FunctionServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr FunctionServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr FunctionServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +FunctionServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeFunctionServiceConnection( Options options) { internal::CheckExpectedOptions +#include +#include #include #include @@ -237,6 +239,18 @@ class FunctionServiceConnection { virtual StatusOr ListRuntimes( google::cloud::functions::v2::ListRuntimesRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/functions/v2/function_connection_idempotency_policy.cc b/google/cloud/functions/v2/function_connection_idempotency_policy.cc index bd51ead84485f..f63f6ff57c073 100644 --- a/google/cloud/functions/v2/function_connection_idempotency_policy.cc +++ b/google/cloud/functions/v2/function_connection_idempotency_policy.cc @@ -74,6 +74,27 @@ Idempotency FunctionServiceConnectionIdempotencyPolicy::ListRuntimes( return Idempotency::kIdempotent; } +Idempotency FunctionServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency FunctionServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency FunctionServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency FunctionServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultFunctionServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/functions/v2/function_connection_idempotency_policy.h b/google/cloud/functions/v2/function_connection_idempotency_policy.h index da31a840d6f13..1e51b54d0454b 100644 --- a/google/cloud/functions/v2/function_connection_idempotency_policy.h +++ b/google/cloud/functions/v2/function_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -60,6 +62,18 @@ class FunctionServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListRuntimes( google::cloud::functions::v2::ListRuntimesRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/functions/v2/internal/function_auth_decorator.cc b/google/cloud/functions/v2/internal/function_auth_decorator.cc index 5138fdd400a59..ab3902da5057f 100644 --- a/google/cloud/functions/v2/internal/function_auth_decorator.cc +++ b/google/cloud/functions/v2/internal/function_auth_decorator.cc @@ -160,6 +160,40 @@ FunctionServiceAuth::ListRuntimes( return child_->ListRuntimes(context, options, request); } +StatusOr +FunctionServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr FunctionServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr FunctionServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +FunctionServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> FunctionServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/functions/v2/internal/function_auth_decorator.h b/google/cloud/functions/v2/internal/function_auth_decorator.h index 7f2de521be3ce..31a032d0dbda7 100644 --- a/google/cloud/functions/v2/internal/function_auth_decorator.h +++ b/google/cloud/functions/v2/internal/function_auth_decorator.h @@ -101,6 +101,22 @@ class FunctionServiceAuth : public FunctionServiceStub { google::cloud::functions::v2::ListRuntimesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/functions/v2/internal/function_connection_impl.cc b/google/cloud/functions/v2/internal/function_connection_impl.cc index 214c36d45f324..1cbd552d5a5a6 100644 --- a/google/cloud/functions/v2/internal/function_connection_impl.cc +++ b/google/cloud/functions/v2/internal/function_connection_impl.cc @@ -432,6 +432,80 @@ FunctionServiceConnectionImpl::ListRuntimes( *current, request, __func__); } +StreamRange +FunctionServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr FunctionServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr FunctionServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +FunctionServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace functions_v2_internal } // namespace cloud diff --git a/google/cloud/functions/v2/internal/function_connection_impl.h b/google/cloud/functions/v2/internal/function_connection_impl.h index e05cc1d050a38..41ed6b2799ccb 100644 --- a/google/cloud/functions/v2/internal/function_connection_impl.h +++ b/google/cloud/functions/v2/internal/function_connection_impl.h @@ -108,6 +108,18 @@ class FunctionServiceConnectionImpl google::cloud::functions::v2::ListRuntimesRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/functions/v2/internal/function_logging_decorator.cc b/google/cloud/functions/v2/internal/function_logging_decorator.cc index 5f0a4f9608553..9a388c3eac9e6 100644 --- a/google/cloud/functions/v2/internal/function_logging_decorator.cc +++ b/google/cloud/functions/v2/internal/function_logging_decorator.cc @@ -191,6 +191,52 @@ FunctionServiceLogging::ListRuntimes( context, options, request, __func__, tracing_options_); } +StatusOr +FunctionServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr FunctionServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr FunctionServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +FunctionServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> FunctionServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/functions/v2/internal/function_logging_decorator.h b/google/cloud/functions/v2/internal/function_logging_decorator.h index 5eb2fc6bc06c9..ebcbba0fa6dd4 100644 --- a/google/cloud/functions/v2/internal/function_logging_decorator.h +++ b/google/cloud/functions/v2/internal/function_logging_decorator.h @@ -101,6 +101,22 @@ class FunctionServiceLogging : public FunctionServiceStub { google::cloud::functions::v2::ListRuntimesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/functions/v2/internal/function_metadata_decorator.cc b/google/cloud/functions/v2/internal/function_metadata_decorator.cc index 29b9f4fefe373..b2339ea194d62 100644 --- a/google/cloud/functions/v2/internal/function_metadata_decorator.cc +++ b/google/cloud/functions/v2/internal/function_metadata_decorator.cc @@ -154,6 +154,43 @@ FunctionServiceMetadata::ListRuntimes( return child_->ListRuntimes(context, options, request); } +StatusOr +FunctionServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr FunctionServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr FunctionServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +FunctionServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> FunctionServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/functions/v2/internal/function_metadata_decorator.h b/google/cloud/functions/v2/internal/function_metadata_decorator.h index 5a24b01113f81..e369c3dc949ba 100644 --- a/google/cloud/functions/v2/internal/function_metadata_decorator.h +++ b/google/cloud/functions/v2/internal/function_metadata_decorator.h @@ -102,6 +102,22 @@ class FunctionServiceMetadata : public FunctionServiceStub { google::cloud::functions::v2::ListRuntimesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/functions/v2/internal/function_stub.cc b/google/cloud/functions/v2/internal/function_stub.cc index 138743402f85a..69d58de5813f6 100644 --- a/google/cloud/functions/v2/internal/function_stub.cc +++ b/google/cloud/functions/v2/internal/function_stub.cc @@ -181,6 +181,53 @@ DefaultFunctionServiceStub::ListRuntimes( return response; } +StatusOr +DefaultFunctionServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultFunctionServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultFunctionServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultFunctionServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultFunctionServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/functions/v2/internal/function_stub.h b/google/cloud/functions/v2/internal/function_stub.h index 8934b7a48e76d..8ca5d227852a0 100644 --- a/google/cloud/functions/v2/internal/function_stub.h +++ b/google/cloud/functions/v2/internal/function_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -94,6 +98,24 @@ class FunctionServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::functions::v2::ListRuntimesRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -113,9 +135,15 @@ class DefaultFunctionServiceStub : public FunctionServiceStub { std::unique_ptr< google::cloud::functions::v2::FunctionService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr GetFunction( grpc::ClientContext& context, Options const& options, @@ -179,6 +207,22 @@ class DefaultFunctionServiceStub : public FunctionServiceStub { google::cloud::functions::v2::ListRuntimesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -194,6 +238,9 @@ class DefaultFunctionServiceStub : public FunctionServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/functions/v2/internal/function_stub_factory.cc b/google/cloud/functions/v2/internal/function_stub_factory.cc index 7df17b2f53533..504041c15c708 100644 --- a/google/cloud/functions/v2/internal/function_stub_factory.cc +++ b/google/cloud/functions/v2/internal/function_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultFunctionServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::functions::v2::FunctionService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/functions/v2/internal/function_tracing_connection.cc b/google/cloud/functions/v2/internal/function_tracing_connection.cc index bb96edc637268..09d42dba28d94 100644 --- a/google/cloud/functions/v2/internal/function_tracing_connection.cc +++ b/google/cloud/functions/v2/internal/function_tracing_connection.cc @@ -167,6 +167,44 @@ FunctionServiceTracingConnection::ListRuntimes( return internal::EndSpan(*span, child_->ListRuntimes(request)); } +StreamRange +FunctionServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "functions_v2::FunctionServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +FunctionServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "functions_v2::FunctionServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +FunctionServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "functions_v2::FunctionServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +FunctionServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "functions_v2::FunctionServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/functions/v2/internal/function_tracing_connection.h b/google/cloud/functions/v2/internal/function_tracing_connection.h index 99bfcee066a70..53d0faeb4487d 100644 --- a/google/cloud/functions/v2/internal/function_tracing_connection.h +++ b/google/cloud/functions/v2/internal/function_tracing_connection.h @@ -96,6 +96,18 @@ class FunctionServiceTracingConnection google::cloud::functions::v2::ListRuntimesRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/functions/v2/internal/function_tracing_stub.cc b/google/cloud/functions/v2/internal/function_tracing_stub.cc index bc1b142ec1e80..17a6c9bdeddbb 100644 --- a/google/cloud/functions/v2/internal/function_tracing_stub.cc +++ b/google/cloud/functions/v2/internal/function_tracing_stub.cc @@ -173,6 +173,52 @@ FunctionServiceTracingStub::ListRuntimes( child_->ListRuntimes(context, options, request)); } +StatusOr +FunctionServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.functions.v2.FunctionService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr FunctionServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.functions.v2.FunctionService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr FunctionServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.functions.v2.FunctionService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +FunctionServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.functions.v2.FunctionService", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> FunctionServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/functions/v2/internal/function_tracing_stub.h b/google/cloud/functions/v2/internal/function_tracing_stub.h index 3e0ec0e9c33ce..0681089c2f260 100644 --- a/google/cloud/functions/v2/internal/function_tracing_stub.h +++ b/google/cloud/functions/v2/internal/function_tracing_stub.h @@ -101,6 +101,22 @@ class FunctionServiceTracingStub : public FunctionServiceStub { google::cloud::functions::v2::ListRuntimesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/functions/v2/mocks/mock_function_connection.h b/google/cloud/functions/v2/mocks/mock_function_connection.h index 2e33629d1be7f..826e293c9d69c 100644 --- a/google/cloud/functions/v2/mocks/mock_function_connection.h +++ b/google/cloud/functions/v2/mocks/mock_function_connection.h @@ -188,6 +188,23 @@ class MockFunctionServiceConnection ListRuntimes, (google::cloud::functions::v2::ListRuntimesRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/gkebackup/BUILD.bazel b/google/cloud/gkebackup/BUILD.bazel index 8a288759bd8e3..5143c8da00ccd 100644 --- a/google/cloud/gkebackup/BUILD.bazel +++ b/google/cloud/gkebackup/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/gkebackup/v1:gkebackup_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/gkebackup/v1/backup_for_gke_client.cc b/google/cloud/gkebackup/v1/backup_for_gke_client.cc index c141768954299..af6975bd0808b 100644 --- a/google/cloud/gkebackup/v1/backup_for_gke_client.cc +++ b/google/cloud/gkebackup/v1/backup_for_gke_client.cc @@ -763,6 +763,38 @@ BackupForGKEClient::GetBackupIndexDownloadUrl( return connection_->GetBackupIndexDownloadUrl(request); } +StreamRange +BackupForGKEClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr BackupForGKEClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr BackupForGKEClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr BackupForGKEClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +BackupForGKEClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace gkebackup_v1 } // namespace cloud diff --git a/google/cloud/gkebackup/v1/backup_for_gke_client.h b/google/cloud/gkebackup/v1/backup_for_gke_client.h index b35e6e4ef4eb5..5fa244557640b 100644 --- a/google/cloud/gkebackup/v1/backup_for_gke_client.h +++ b/google/cloud/gkebackup/v1/backup_for_gke_client.h @@ -2398,6 +2398,178 @@ class BackupForGKEClient { request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/gkebackup/v1/backup_for_gke_connection.cc b/google/cloud/gkebackup/v1/backup_for_gke_connection.cc index 3fbc5cad36075..c8352c73afc3e 100644 --- a/google/cloud/gkebackup/v1/backup_for_gke_connection.cc +++ b/google/cloud/gkebackup/v1/backup_for_gke_connection.cc @@ -392,6 +392,35 @@ BackupForGKEConnection::GetBackupIndexDownloadUrl( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +BackupForGKEConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr BackupForGKEConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr BackupForGKEConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr BackupForGKEConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +BackupForGKEConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeBackupForGKEConnection( Options options) { internal::CheckExpectedOptions +#include +#include #include #include @@ -359,6 +361,21 @@ class BackupForGKEConnection { GetBackupIndexDownloadUrl( google::cloud::gkebackup::v1::GetBackupIndexDownloadUrlRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/gkebackup/v1/backup_for_gke_connection_idempotency_policy.cc b/google/cloud/gkebackup/v1/backup_for_gke_connection_idempotency_policy.cc index 8ce20ac598a06..1be9acec7f34c 100644 --- a/google/cloud/gkebackup/v1/backup_for_gke_connection_idempotency_policy.cc +++ b/google/cloud/gkebackup/v1/backup_for_gke_connection_idempotency_policy.cc @@ -159,6 +159,32 @@ Idempotency BackupForGKEConnectionIdempotencyPolicy::GetBackupIndexDownloadUrl( return Idempotency::kIdempotent; } +Idempotency BackupForGKEConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency BackupForGKEConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency BackupForGKEConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency BackupForGKEConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency BackupForGKEConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultBackupForGKEConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/gkebackup/v1/backup_for_gke_connection_idempotency_policy.h b/google/cloud/gkebackup/v1/backup_for_gke_connection_idempotency_policy.h index c913a1fb5b022..bb0d279f8913a 100644 --- a/google/cloud/gkebackup/v1/backup_for_gke_connection_idempotency_policy.h +++ b/google/cloud/gkebackup/v1/backup_for_gke_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -112,6 +114,21 @@ class BackupForGKEConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GetBackupIndexDownloadUrl( google::cloud::gkebackup::v1::GetBackupIndexDownloadUrlRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/gkebackup/v1/internal/backup_for_gke_auth_decorator.cc b/google/cloud/gkebackup/v1/internal/backup_for_gke_auth_decorator.cc index 773fc2cd51109..9ccffb2674870 100644 --- a/google/cloud/gkebackup/v1/internal/backup_for_gke_auth_decorator.cc +++ b/google/cloud/gkebackup/v1/internal/backup_for_gke_auth_decorator.cc @@ -483,6 +483,48 @@ BackupForGKEAuth::GetBackupIndexDownloadUrl( return child_->GetBackupIndexDownloadUrl(context, options, request); } +StatusOr +BackupForGKEAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr BackupForGKEAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr BackupForGKEAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr BackupForGKEAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +BackupForGKEAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> BackupForGKEAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/gkebackup/v1/internal/backup_for_gke_auth_decorator.h b/google/cloud/gkebackup/v1/internal/backup_for_gke_auth_decorator.h index c48b8a9739869..eb4e0ef871a1e 100644 --- a/google/cloud/gkebackup/v1/internal/backup_for_gke_auth_decorator.h +++ b/google/cloud/gkebackup/v1/internal/backup_for_gke_auth_decorator.h @@ -248,6 +248,26 @@ class BackupForGKEAuth : public BackupForGKEStub { google::cloud::gkebackup::v1::GetBackupIndexDownloadUrlRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/gkebackup/v1/internal/backup_for_gke_connection_impl.cc b/google/cloud/gkebackup/v1/internal/backup_for_gke_connection_impl.cc index a0e71d95417ef..9a109623c6884 100644 --- a/google/cloud/gkebackup/v1/internal/backup_for_gke_connection_impl.cc +++ b/google/cloud/gkebackup/v1/internal/backup_for_gke_connection_impl.cc @@ -1477,6 +1477,94 @@ BackupForGKEConnectionImpl::GetBackupIndexDownloadUrl( *current, request, __func__); } +StreamRange +BackupForGKEConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +BackupForGKEConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr BackupForGKEConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr BackupForGKEConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +BackupForGKEConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace gkebackup_v1_internal } // namespace cloud diff --git a/google/cloud/gkebackup/v1/internal/backup_for_gke_connection_impl.h b/google/cloud/gkebackup/v1/internal/backup_for_gke_connection_impl.h index 475171ae24d9a..14e4486f65e1e 100644 --- a/google/cloud/gkebackup/v1/internal/backup_for_gke_connection_impl.h +++ b/google/cloud/gkebackup/v1/internal/backup_for_gke_connection_impl.h @@ -241,6 +241,21 @@ class BackupForGKEConnectionImpl : public gkebackup_v1::BackupForGKEConnection { google::cloud::gkebackup::v1::GetBackupIndexDownloadUrlRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/gkebackup/v1/internal/backup_for_gke_logging_decorator.cc b/google/cloud/gkebackup/v1/internal/backup_for_gke_logging_decorator.cc index 870c9c3a2c9ec..7ffc738633173 100644 --- a/google/cloud/gkebackup/v1/internal/backup_for_gke_logging_decorator.cc +++ b/google/cloud/gkebackup/v1/internal/backup_for_gke_logging_decorator.cc @@ -566,6 +566,63 @@ BackupForGKELogging::GetBackupIndexDownloadUrl( context, options, request, __func__, tracing_options_); } +StatusOr +BackupForGKELogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr BackupForGKELogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr BackupForGKELogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr BackupForGKELogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +BackupForGKELogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> BackupForGKELogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/gkebackup/v1/internal/backup_for_gke_logging_decorator.h b/google/cloud/gkebackup/v1/internal/backup_for_gke_logging_decorator.h index 33b148a806e1a..fd3fc98143443 100644 --- a/google/cloud/gkebackup/v1/internal/backup_for_gke_logging_decorator.h +++ b/google/cloud/gkebackup/v1/internal/backup_for_gke_logging_decorator.h @@ -248,6 +248,26 @@ class BackupForGKELogging : public BackupForGKEStub { google::cloud::gkebackup::v1::GetBackupIndexDownloadUrlRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/gkebackup/v1/internal/backup_for_gke_metadata_decorator.cc b/google/cloud/gkebackup/v1/internal/backup_for_gke_metadata_decorator.cc index 487b4c9cba37c..e0666bd3850bc 100644 --- a/google/cloud/gkebackup/v1/internal/backup_for_gke_metadata_decorator.cc +++ b/google/cloud/gkebackup/v1/internal/backup_for_gke_metadata_decorator.cc @@ -412,6 +412,51 @@ BackupForGKEMetadata::GetBackupIndexDownloadUrl( return child_->GetBackupIndexDownloadUrl(context, options, request); } +StatusOr +BackupForGKEMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr BackupForGKEMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr BackupForGKEMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr BackupForGKEMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +BackupForGKEMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> BackupForGKEMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/gkebackup/v1/internal/backup_for_gke_metadata_decorator.h b/google/cloud/gkebackup/v1/internal/backup_for_gke_metadata_decorator.h index a523fe1d0013e..a040f06b9efd5 100644 --- a/google/cloud/gkebackup/v1/internal/backup_for_gke_metadata_decorator.h +++ b/google/cloud/gkebackup/v1/internal/backup_for_gke_metadata_decorator.h @@ -248,6 +248,26 @@ class BackupForGKEMetadata : public BackupForGKEStub { google::cloud::gkebackup::v1::GetBackupIndexDownloadUrlRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/gkebackup/v1/internal/backup_for_gke_stub.cc b/google/cloud/gkebackup/v1/internal/backup_for_gke_stub.cc index 765e696d30008..8b1aa693f43bd 100644 --- a/google/cloud/gkebackup/v1/internal/backup_for_gke_stub.cc +++ b/google/cloud/gkebackup/v1/internal/backup_for_gke_stub.cc @@ -549,6 +549,65 @@ DefaultBackupForGKEStub::GetBackupIndexDownloadUrl( return response; } +StatusOr +DefaultBackupForGKEStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultBackupForGKEStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultBackupForGKEStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultBackupForGKEStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultBackupForGKEStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultBackupForGKEStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/gkebackup/v1/internal/backup_for_gke_stub.h b/google/cloud/gkebackup/v1/internal/backup_for_gke_stub.h index ad8f93b0a74d8..7512638882310 100644 --- a/google/cloud/gkebackup/v1/internal/backup_for_gke_stub.h +++ b/google/cloud/gkebackup/v1/internal/backup_for_gke_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -234,6 +238,28 @@ class BackupForGKEStub { google::cloud::gkebackup::v1::GetBackupIndexDownloadUrlRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -252,9 +278,15 @@ class DefaultBackupForGKEStub : public BackupForGKEStub { DefaultBackupForGKEStub( std::unique_ptr grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateBackupPlan( google::cloud::CompletionQueue& cq, @@ -465,6 +497,26 @@ class DefaultBackupForGKEStub : public BackupForGKEStub { google::cloud::gkebackup::v1::GetBackupIndexDownloadUrlRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -480,6 +532,9 @@ class DefaultBackupForGKEStub : public BackupForGKEStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/gkebackup/v1/internal/backup_for_gke_stub_factory.cc b/google/cloud/gkebackup/v1/internal/backup_for_gke_stub_factory.cc index a701f057b9662..ab7b1994a96f8 100644 --- a/google/cloud/gkebackup/v1/internal/backup_for_gke_stub_factory.cc +++ b/google/cloud/gkebackup/v1/internal/backup_for_gke_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultBackupForGKEStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::gkebackup::v1::BackupForGKE::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/gkebackup/v1/internal/backup_for_gke_tracing_connection.cc b/google/cloud/gkebackup/v1/internal/backup_for_gke_tracing_connection.cc index cb9cec716d74e..be7f0bcc0aab3 100644 --- a/google/cloud/gkebackup/v1/internal/backup_for_gke_tracing_connection.cc +++ b/google/cloud/gkebackup/v1/internal/backup_for_gke_tracing_connection.cc @@ -514,6 +514,51 @@ BackupForGKETracingConnection::GetBackupIndexDownloadUrl( return internal::EndSpan(*span, child_->GetBackupIndexDownloadUrl(request)); } +StreamRange +BackupForGKETracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("gkebackup_v1::BackupForGKEConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +BackupForGKETracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("gkebackup_v1::BackupForGKEConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr BackupForGKETracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("gkebackup_v1::BackupForGKEConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr BackupForGKETracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("gkebackup_v1::BackupForGKEConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +BackupForGKETracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "gkebackup_v1::BackupForGKEConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/gkebackup/v1/internal/backup_for_gke_tracing_connection.h b/google/cloud/gkebackup/v1/internal/backup_for_gke_tracing_connection.h index cb0ae07a2ac50..dd0382f54b1b4 100644 --- a/google/cloud/gkebackup/v1/internal/backup_for_gke_tracing_connection.h +++ b/google/cloud/gkebackup/v1/internal/backup_for_gke_tracing_connection.h @@ -230,6 +230,21 @@ class BackupForGKETracingConnection google::cloud::gkebackup::v1::GetBackupIndexDownloadUrlRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/gkebackup/v1/internal/backup_for_gke_tracing_stub.cc b/google/cloud/gkebackup/v1/internal/backup_for_gke_tracing_stub.cc index 0fc4e8d1363d5..8af004fd8058f 100644 --- a/google/cloud/gkebackup/v1/internal/backup_for_gke_tracing_stub.cc +++ b/google/cloud/gkebackup/v1/internal/backup_for_gke_tracing_stub.cc @@ -502,6 +502,64 @@ BackupForGKETracingStub::GetBackupIndexDownloadUrl( child_->GetBackupIndexDownloadUrl(context, options, request)); } +StatusOr +BackupForGKETracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.gkebackup.v1.BackupForGKE", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +BackupForGKETracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.gkebackup.v1.BackupForGKE", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr BackupForGKETracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.gkebackup.v1.BackupForGKE", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr BackupForGKETracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.gkebackup.v1.BackupForGKE", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +BackupForGKETracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.gkebackup.v1.BackupForGKE", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> BackupForGKETracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/gkebackup/v1/internal/backup_for_gke_tracing_stub.h b/google/cloud/gkebackup/v1/internal/backup_for_gke_tracing_stub.h index 881f3310f0653..c81ab5201d0b0 100644 --- a/google/cloud/gkebackup/v1/internal/backup_for_gke_tracing_stub.h +++ b/google/cloud/gkebackup/v1/internal/backup_for_gke_tracing_stub.h @@ -247,6 +247,26 @@ class BackupForGKETracingStub : public BackupForGKEStub { google::cloud::gkebackup::v1::GetBackupIndexDownloadUrlRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/gkebackup/v1/mocks/mock_backup_for_gke_connection.h b/google/cloud/gkebackup/v1/mocks/mock_backup_for_gke_connection.h index ca4cccdafc0de..f814fde69f426 100644 --- a/google/cloud/gkebackup/v1/mocks/mock_backup_for_gke_connection.h +++ b/google/cloud/gkebackup/v1/mocks/mock_backup_for_gke_connection.h @@ -573,6 +573,27 @@ class MockBackupForGKEConnection : public gkebackup_v1::BackupForGKEConnection { (google::cloud::gkebackup::v1::GetBackupIndexDownloadUrlRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/iam/v1/internal/iam_policy_stub.h b/google/cloud/iam/v1/internal/iam_policy_stub.h index 84764974b5d0b..f106c046b899c 100644 --- a/google/cloud/iam/v1/internal/iam_policy_stub.h +++ b/google/cloud/iam/v1/internal/iam_policy_stub.h @@ -23,6 +23,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include diff --git a/google/cloud/kms/BUILD.bazel b/google/cloud/kms/BUILD.bazel index fc09b67a3c903..ff7a60f1ed3f9 100644 --- a/google/cloud/kms/BUILD.bazel +++ b/google/cloud/kms/BUILD.bazel @@ -27,6 +27,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/kms/inventory/v1:inventory_cc_grpc", "@com_google_googleapis//google/cloud/kms/v1:kms_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/kms/v1/autokey_admin_client.cc b/google/cloud/kms/v1/autokey_admin_client.cc index ab4d9cb1c88b5..d5137002ebeb3 100644 --- a/google/cloud/kms/v1/autokey_admin_client.cc +++ b/google/cloud/kms/v1/autokey_admin_client.cc @@ -84,6 +84,38 @@ AutokeyAdminClient::ShowEffectiveAutokeyConfig( return connection_->ShowEffectiveAutokeyConfig(request); } +StreamRange +AutokeyAdminClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr AutokeyAdminClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr AutokeyAdminClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr AutokeyAdminClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +AutokeyAdminClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace kms_v1 } // namespace cloud diff --git a/google/cloud/kms/v1/autokey_admin_client.h b/google/cloud/kms/v1/autokey_admin_client.h index 5de5f8ac37ba2..25137e2be6bee 100644 --- a/google/cloud/kms/v1/autokey_admin_client.h +++ b/google/cloud/kms/v1/autokey_admin_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -282,6 +283,178 @@ class AutokeyAdminClient { google::cloud::kms::v1::ShowEffectiveAutokeyConfigRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/kms/v1/autokey_admin_connection.cc b/google/cloud/kms/v1/autokey_admin_connection.cc index 027efd2c79601..3cb655def89c2 100644 --- a/google/cloud/kms/v1/autokey_admin_connection.cc +++ b/google/cloud/kms/v1/autokey_admin_connection.cc @@ -26,6 +26,7 @@ #include "google/cloud/common_options.h" #include "google/cloud/credentials.h" #include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/unified_grpc_credentials.h" #include #include @@ -55,6 +56,35 @@ AutokeyAdminConnection::ShowEffectiveAutokeyConfig( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +AutokeyAdminConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr AutokeyAdminConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr AutokeyAdminConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr AutokeyAdminConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +AutokeyAdminConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAutokeyAdminConnection( Options options) { internal::CheckExpectedOptions +#include +#include #include namespace google { @@ -190,6 +193,21 @@ class AutokeyAdminConnection { virtual StatusOr ShowEffectiveAutokeyConfig( google::cloud::kms::v1::ShowEffectiveAutokeyConfigRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/kms/v1/autokey_admin_connection_idempotency_policy.cc b/google/cloud/kms/v1/autokey_admin_connection_idempotency_policy.cc index b6dc04682a6a7..77b9cca2da84c 100644 --- a/google/cloud/kms/v1/autokey_admin_connection_idempotency_policy.cc +++ b/google/cloud/kms/v1/autokey_admin_connection_idempotency_policy.cc @@ -49,6 +49,32 @@ Idempotency AutokeyAdminConnectionIdempotencyPolicy::ShowEffectiveAutokeyConfig( return Idempotency::kIdempotent; } +Idempotency AutokeyAdminConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AutokeyAdminConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AutokeyAdminConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency AutokeyAdminConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AutokeyAdminConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultAutokeyAdminConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/kms/v1/autokey_admin_connection_idempotency_policy.h b/google/cloud/kms/v1/autokey_admin_connection_idempotency_policy.h index 57fc0b85f066f..373a88fb29385 100644 --- a/google/cloud/kms/v1/autokey_admin_connection_idempotency_policy.h +++ b/google/cloud/kms/v1/autokey_admin_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -45,6 +47,21 @@ class AutokeyAdminConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ShowEffectiveAutokeyConfig( google::cloud::kms::v1::ShowEffectiveAutokeyConfigRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/kms/v1/autokey_client.cc b/google/cloud/kms/v1/autokey_client.cc index fa5d733f2d135..ad2faec237c7f 100644 --- a/google/cloud/kms/v1/autokey_client.cc +++ b/google/cloud/kms/v1/autokey_client.cc @@ -109,6 +109,37 @@ AutokeyClient::ListKeyHandles( return connection_->ListKeyHandles(request); } +StreamRange AutokeyClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr AutokeyClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr AutokeyClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr AutokeyClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +AutokeyClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace kms_v1 } // namespace cloud diff --git a/google/cloud/kms/v1/autokey_client.h b/google/cloud/kms/v1/autokey_client.h index e026bc69e5178..12507f627c67d 100644 --- a/google/cloud/kms/v1/autokey_client.h +++ b/google/cloud/kms/v1/autokey_client.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -355,6 +356,178 @@ class AutokeyClient { google::cloud::kms::v1::ListKeyHandlesRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/kms/v1/autokey_connection.cc b/google/cloud/kms/v1/autokey_connection.cc index cfc851cdd744c..578b6b4647491 100644 --- a/google/cloud/kms/v1/autokey_connection.cc +++ b/google/cloud/kms/v1/autokey_connection.cc @@ -26,6 +26,7 @@ #include "google/cloud/common_options.h" #include "google/cloud/credentials.h" #include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/unified_grpc_credentials.h" #include #include @@ -69,6 +70,34 @@ AutokeyConnection::ListKeyHandles( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange AutokeyConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr AutokeyConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr AutokeyConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr AutokeyConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +AutokeyConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeAutokeyConnection(Options options) { internal::CheckExpectedOptions +#include +#include #include #include @@ -197,6 +200,21 @@ class AutokeyConnection { virtual StatusOr ListKeyHandles(google::cloud::kms::v1::ListKeyHandlesRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/kms/v1/autokey_connection_idempotency_policy.cc b/google/cloud/kms/v1/autokey_connection_idempotency_policy.cc index f0c4844d5a6ba..30fd24855ef3b 100644 --- a/google/cloud/kms/v1/autokey_connection_idempotency_policy.cc +++ b/google/cloud/kms/v1/autokey_connection_idempotency_policy.cc @@ -49,6 +49,32 @@ Idempotency AutokeyConnectionIdempotencyPolicy::ListKeyHandles( return Idempotency::kIdempotent; } +Idempotency AutokeyConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency AutokeyConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AutokeyConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency AutokeyConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency AutokeyConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultAutokeyConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/kms/v1/autokey_connection_idempotency_policy.h b/google/cloud/kms/v1/autokey_connection_idempotency_policy.h index 5a960a5acb1b1..f0b7c8f000a9a 100644 --- a/google/cloud/kms/v1/autokey_connection_idempotency_policy.h +++ b/google/cloud/kms/v1/autokey_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -44,6 +46,21 @@ class AutokeyConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListKeyHandles( google::cloud::kms::v1::ListKeyHandlesRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/kms/v1/ekm_client.cc b/google/cloud/kms/v1/ekm_client.cc index 8e8c0687ebe92..6cfd0bc2fe43c 100644 --- a/google/cloud/kms/v1/ekm_client.cc +++ b/google/cloud/kms/v1/ekm_client.cc @@ -149,6 +149,37 @@ EkmServiceClient::VerifyConnectivity( return connection_->VerifyConnectivity(request); } +StreamRange EkmServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr EkmServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr EkmServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr EkmServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +EkmServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace kms_v1 } // namespace cloud diff --git a/google/cloud/kms/v1/ekm_client.h b/google/cloud/kms/v1/ekm_client.h index 2e1df5f58895f..448b1c1eeb5f2 100644 --- a/google/cloud/kms/v1/ekm_client.h +++ b/google/cloud/kms/v1/ekm_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -540,6 +541,178 @@ class EkmServiceClient { google::cloud::kms::v1::VerifyConnectivityRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/kms/v1/ekm_connection.cc b/google/cloud/kms/v1/ekm_connection.cc index 1475d0b389006..91f7a2cb02ef4 100644 --- a/google/cloud/kms/v1/ekm_connection.cc +++ b/google/cloud/kms/v1/ekm_connection.cc @@ -81,6 +81,35 @@ EkmServiceConnection::VerifyConnectivity( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +EkmServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr EkmServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr EkmServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr EkmServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +EkmServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeEkmServiceConnection( Options options) { internal::CheckExpectedOptions +#include +#include #include namespace google { @@ -202,6 +204,21 @@ class EkmServiceConnection { virtual StatusOr VerifyConnectivity( google::cloud::kms::v1::VerifyConnectivityRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/kms/v1/ekm_connection_idempotency_policy.cc b/google/cloud/kms/v1/ekm_connection_idempotency_policy.cc index 6595897e77b39..609454f98a9ba 100644 --- a/google/cloud/kms/v1/ekm_connection_idempotency_policy.cc +++ b/google/cloud/kms/v1/ekm_connection_idempotency_policy.cc @@ -69,6 +69,32 @@ Idempotency EkmServiceConnectionIdempotencyPolicy::VerifyConnectivity( return Idempotency::kIdempotent; } +Idempotency EkmServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency EkmServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency EkmServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency EkmServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency EkmServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultEkmServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/kms/v1/ekm_connection_idempotency_policy.h b/google/cloud/kms/v1/ekm_connection_idempotency_policy.h index 095422a1764dd..b667f3ec393f1 100644 --- a/google/cloud/kms/v1/ekm_connection_idempotency_policy.h +++ b/google/cloud/kms/v1/ekm_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -56,6 +58,21 @@ class EkmServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency VerifyConnectivity( google::cloud::kms::v1::VerifyConnectivityRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/kms/v1/internal/autokey_admin_auth_decorator.cc b/google/cloud/kms/v1/internal/autokey_admin_auth_decorator.cc index 5dd557966d332..037269e19bda3 100644 --- a/google/cloud/kms/v1/internal/autokey_admin_auth_decorator.cc +++ b/google/cloud/kms/v1/internal/autokey_admin_auth_decorator.cc @@ -58,6 +58,48 @@ AutokeyAdminAuth::ShowEffectiveAutokeyConfig( return child_->ShowEffectiveAutokeyConfig(context, options, request); } +StatusOr +AutokeyAdminAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr AutokeyAdminAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr AutokeyAdminAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr AutokeyAdminAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +AutokeyAdminAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace kms_v1_internal } // namespace cloud diff --git a/google/cloud/kms/v1/internal/autokey_admin_auth_decorator.h b/google/cloud/kms/v1/internal/autokey_admin_auth_decorator.h index 66687e234e36c..b92ae402ff0d5 100644 --- a/google/cloud/kms/v1/internal/autokey_admin_auth_decorator.h +++ b/google/cloud/kms/v1/internal/autokey_admin_auth_decorator.h @@ -53,6 +53,26 @@ class AutokeyAdminAuth : public AutokeyAdminStub { google::cloud::kms::v1::ShowEffectiveAutokeyConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/kms/v1/internal/autokey_admin_connection_impl.cc b/google/cloud/kms/v1/internal/autokey_admin_connection_impl.cc index 112242b6c2aca..9bd801951d76a 100644 --- a/google/cloud/kms/v1/internal/autokey_admin_connection_impl.cc +++ b/google/cloud/kms/v1/internal/autokey_admin_connection_impl.cc @@ -21,6 +21,7 @@ #include "google/cloud/background_threads.h" #include "google/cloud/common_options.h" #include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/retry_loop.h" #include #include @@ -100,6 +101,94 @@ AutokeyAdminConnectionImpl::ShowEffectiveAutokeyConfig( *current, request, __func__); } +StreamRange +AutokeyAdminConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +AutokeyAdminConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr AutokeyAdminConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr AutokeyAdminConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +AutokeyAdminConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace kms_v1_internal } // namespace cloud diff --git a/google/cloud/kms/v1/internal/autokey_admin_connection_impl.h b/google/cloud/kms/v1/internal/autokey_admin_connection_impl.h index bffc3f4d0b0b9..3a5f67e55c538 100644 --- a/google/cloud/kms/v1/internal/autokey_admin_connection_impl.h +++ b/google/cloud/kms/v1/internal/autokey_admin_connection_impl.h @@ -28,6 +28,7 @@ #include "google/cloud/backoff_policy.h" #include "google/cloud/options.h" #include "google/cloud/status_or.h" +#include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include @@ -58,6 +59,21 @@ class AutokeyAdminConnectionImpl : public kms_v1::AutokeyAdminConnection { google::cloud::kms::v1::ShowEffectiveAutokeyConfigRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/kms/v1/internal/autokey_admin_logging_decorator.cc b/google/cloud/kms/v1/internal/autokey_admin_logging_decorator.cc index 1e28295c34d90..3636adcac245c 100644 --- a/google/cloud/kms/v1/internal/autokey_admin_logging_decorator.cc +++ b/google/cloud/kms/v1/internal/autokey_admin_logging_decorator.cc @@ -73,6 +73,63 @@ AutokeyAdminLogging::ShowEffectiveAutokeyConfig( context, options, request, __func__, tracing_options_); } +StatusOr +AutokeyAdminLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AutokeyAdminLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AutokeyAdminLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AutokeyAdminLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AutokeyAdminLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace kms_v1_internal } // namespace cloud diff --git a/google/cloud/kms/v1/internal/autokey_admin_logging_decorator.h b/google/cloud/kms/v1/internal/autokey_admin_logging_decorator.h index ae6b1550b992a..f018800ac498c 100644 --- a/google/cloud/kms/v1/internal/autokey_admin_logging_decorator.h +++ b/google/cloud/kms/v1/internal/autokey_admin_logging_decorator.h @@ -53,6 +53,26 @@ class AutokeyAdminLogging : public AutokeyAdminStub { google::cloud::kms::v1::ShowEffectiveAutokeyConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/kms/v1/internal/autokey_admin_metadata_decorator.cc b/google/cloud/kms/v1/internal/autokey_admin_metadata_decorator.cc index 19f11eb8f9f43..632d5f2a81d46 100644 --- a/google/cloud/kms/v1/internal/autokey_admin_metadata_decorator.cc +++ b/google/cloud/kms/v1/internal/autokey_admin_metadata_decorator.cc @@ -73,6 +73,51 @@ AutokeyAdminMetadata::ShowEffectiveAutokeyConfig( return child_->ShowEffectiveAutokeyConfig(context, options, request); } +StatusOr +AutokeyAdminMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr AutokeyAdminMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr AutokeyAdminMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr AutokeyAdminMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +AutokeyAdminMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + void AutokeyAdminMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/kms/v1/internal/autokey_admin_metadata_decorator.h b/google/cloud/kms/v1/internal/autokey_admin_metadata_decorator.h index 8720b358bc372..dfe1d6458117f 100644 --- a/google/cloud/kms/v1/internal/autokey_admin_metadata_decorator.h +++ b/google/cloud/kms/v1/internal/autokey_admin_metadata_decorator.h @@ -53,6 +53,26 @@ class AutokeyAdminMetadata : public AutokeyAdminStub { google::cloud::kms::v1::ShowEffectiveAutokeyConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/kms/v1/internal/autokey_admin_stub.cc b/google/cloud/kms/v1/internal/autokey_admin_stub.cc index e9b3ec3cc1131..9591721105cfb 100644 --- a/google/cloud/kms/v1/internal/autokey_admin_stub.cc +++ b/google/cloud/kms/v1/internal/autokey_admin_stub.cc @@ -67,6 +67,65 @@ DefaultAutokeyAdminStub::ShowEffectiveAutokeyConfig( return response; } +StatusOr +DefaultAutokeyAdminStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAutokeyAdminStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAutokeyAdminStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAutokeyAdminStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAutokeyAdminStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace kms_v1_internal } // namespace cloud diff --git a/google/cloud/kms/v1/internal/autokey_admin_stub.h b/google/cloud/kms/v1/internal/autokey_admin_stub.h index dc422e8cf2163..63e2b6dfc1d2b 100644 --- a/google/cloud/kms/v1/internal/autokey_admin_stub.h +++ b/google/cloud/kms/v1/internal/autokey_admin_stub.h @@ -23,6 +23,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include @@ -48,14 +52,41 @@ class AutokeyAdminStub { grpc::ClientContext& context, Options const& options, google::cloud::kms::v1::ShowEffectiveAutokeyConfigRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; }; class DefaultAutokeyAdminStub : public AutokeyAdminStub { public: explicit DefaultAutokeyAdminStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr UpdateAutokeyConfig( grpc::ClientContext& context, Options const& options, @@ -72,9 +103,32 @@ class DefaultAutokeyAdminStub : public AutokeyAdminStub { google::cloud::kms::v1::ShowEffectiveAutokeyConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/kms/v1/internal/autokey_admin_stub_factory.cc b/google/cloud/kms/v1/internal/autokey_admin_stub_factory.cc index e8f4ef63d7a30..1978bd7121cd7 100644 --- a/google/cloud/kms/v1/internal/autokey_admin_stub_factory.cc +++ b/google/cloud/kms/v1/internal/autokey_admin_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,8 +46,13 @@ std::shared_ptr CreateDefaultAutokeyAdminStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::kms::v1::AutokeyAdmin::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + std::make_shared( + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), std::move(stub)); diff --git a/google/cloud/kms/v1/internal/autokey_admin_tracing_connection.cc b/google/cloud/kms/v1/internal/autokey_admin_tracing_connection.cc index d8a4d71ced151..9b4fcf4ffdbeb 100644 --- a/google/cloud/kms/v1/internal/autokey_admin_tracing_connection.cc +++ b/google/cloud/kms/v1/internal/autokey_admin_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/kms/v1/internal/autokey_admin_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -59,6 +60,50 @@ AutokeyAdminTracingConnection::ShowEffectiveAutokeyConfig( return internal::EndSpan(*span, child_->ShowEffectiveAutokeyConfig(request)); } +StreamRange +AutokeyAdminTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("kms_v1::AutokeyAdminConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AutokeyAdminTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan("kms_v1::AutokeyAdminConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr AutokeyAdminTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("kms_v1::AutokeyAdminConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr AutokeyAdminTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = + internal::MakeSpan("kms_v1::AutokeyAdminConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +AutokeyAdminTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = + internal::MakeSpan("kms_v1::AutokeyAdminConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/kms/v1/internal/autokey_admin_tracing_connection.h b/google/cloud/kms/v1/internal/autokey_admin_tracing_connection.h index 108e969da50e2..6d7f490a6a400 100644 --- a/google/cloud/kms/v1/internal/autokey_admin_tracing_connection.h +++ b/google/cloud/kms/v1/internal/autokey_admin_tracing_connection.h @@ -51,6 +51,21 @@ class AutokeyAdminTracingConnection : public kms_v1::AutokeyAdminConnection { google::cloud::kms::v1::ShowEffectiveAutokeyConfigRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/kms/v1/internal/autokey_admin_tracing_stub.cc b/google/cloud/kms/v1/internal/autokey_admin_tracing_stub.cc index 518c19604c7da..55ee2b30c3df5 100644 --- a/google/cloud/kms/v1/internal/autokey_admin_tracing_stub.cc +++ b/google/cloud/kms/v1/internal/autokey_admin_tracing_stub.cc @@ -69,6 +69,64 @@ AutokeyAdminTracingStub::ShowEffectiveAutokeyConfig( child_->ShowEffectiveAutokeyConfig(context, options, request)); } +StatusOr +AutokeyAdminTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.kms.v1.AutokeyAdmin", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +AutokeyAdminTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.kms.v1.AutokeyAdmin", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr AutokeyAdminTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.kms.v1.AutokeyAdmin", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr AutokeyAdminTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.kms.v1.AutokeyAdmin", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +AutokeyAdminTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.kms.v1.AutokeyAdmin", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeAutokeyAdminTracingStub( diff --git a/google/cloud/kms/v1/internal/autokey_admin_tracing_stub.h b/google/cloud/kms/v1/internal/autokey_admin_tracing_stub.h index 006b0af067afb..4212137d6a3d9 100644 --- a/google/cloud/kms/v1/internal/autokey_admin_tracing_stub.h +++ b/google/cloud/kms/v1/internal/autokey_admin_tracing_stub.h @@ -53,6 +53,26 @@ class AutokeyAdminTracingStub : public AutokeyAdminStub { google::cloud::kms::v1::ShowEffectiveAutokeyConfigRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/kms/v1/internal/autokey_auth_decorator.cc b/google/cloud/kms/v1/internal/autokey_auth_decorator.cc index 65b8d3b33ce2d..2f30a3dc4994c 100644 --- a/google/cloud/kms/v1/internal/autokey_auth_decorator.cc +++ b/google/cloud/kms/v1/internal/autokey_auth_decorator.cc @@ -76,6 +76,48 @@ AutokeyAuth::ListKeyHandles( return child_->ListKeyHandles(context, options, request); } +StatusOr +AutokeyAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr AutokeyAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr AutokeyAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr AutokeyAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +AutokeyAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> AutokeyAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/kms/v1/internal/autokey_auth_decorator.h b/google/cloud/kms/v1/internal/autokey_auth_decorator.h index b9c3e3cc3fc64..7ac8969b38590 100644 --- a/google/cloud/kms/v1/internal/autokey_auth_decorator.h +++ b/google/cloud/kms/v1/internal/autokey_auth_decorator.h @@ -57,6 +57,26 @@ class AutokeyAuth : public AutokeyStub { grpc::ClientContext& context, Options const& options, google::cloud::kms::v1::ListKeyHandlesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/kms/v1/internal/autokey_connection_impl.cc b/google/cloud/kms/v1/internal/autokey_connection_impl.cc index 90e9238a04035..67cc9917c4968 100644 --- a/google/cloud/kms/v1/internal/autokey_connection_impl.cc +++ b/google/cloud/kms/v1/internal/autokey_connection_impl.cc @@ -22,6 +22,7 @@ #include "google/cloud/common_options.h" #include "google/cloud/grpc_options.h" #include "google/cloud/internal/async_long_running_operation.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/retry_loop.h" #include #include @@ -176,6 +177,93 @@ AutokeyConnectionImpl::ListKeyHandles( *current, request, __func__); } +StreamRange +AutokeyConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = + std::shared_ptr(retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr AutokeyConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr AutokeyConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr AutokeyConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +AutokeyConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace kms_v1_internal } // namespace cloud diff --git a/google/cloud/kms/v1/internal/autokey_connection_impl.h b/google/cloud/kms/v1/internal/autokey_connection_impl.h index ad1ce73f35f6e..bc8857b1e411f 100644 --- a/google/cloud/kms/v1/internal/autokey_connection_impl.h +++ b/google/cloud/kms/v1/internal/autokey_connection_impl.h @@ -30,6 +30,7 @@ #include "google/cloud/options.h" #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" +#include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include #include @@ -65,6 +66,21 @@ class AutokeyConnectionImpl : public kms_v1::AutokeyConnection { StatusOr ListKeyHandles( google::cloud::kms::v1::ListKeyHandlesRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/kms/v1/internal/autokey_logging_decorator.cc b/google/cloud/kms/v1/internal/autokey_logging_decorator.cc index c95b5aa987421..399f84b44276b 100644 --- a/google/cloud/kms/v1/internal/autokey_logging_decorator.cc +++ b/google/cloud/kms/v1/internal/autokey_logging_decorator.cc @@ -87,6 +87,63 @@ AutokeyLogging::ListKeyHandles( context, options, request, __func__, tracing_options_); } +StatusOr +AutokeyLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AutokeyLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AutokeyLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr AutokeyLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +AutokeyLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> AutokeyLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/kms/v1/internal/autokey_logging_decorator.h b/google/cloud/kms/v1/internal/autokey_logging_decorator.h index 9a19bd794f0ea..95b6e67be7793 100644 --- a/google/cloud/kms/v1/internal/autokey_logging_decorator.h +++ b/google/cloud/kms/v1/internal/autokey_logging_decorator.h @@ -57,6 +57,26 @@ class AutokeyLogging : public AutokeyStub { grpc::ClientContext& context, Options const& options, google::cloud::kms::v1::ListKeyHandlesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/kms/v1/internal/autokey_metadata_decorator.cc b/google/cloud/kms/v1/internal/autokey_metadata_decorator.cc index 3223abf871cef..f094ddd71c1c3 100644 --- a/google/cloud/kms/v1/internal/autokey_metadata_decorator.cc +++ b/google/cloud/kms/v1/internal/autokey_metadata_decorator.cc @@ -81,6 +81,51 @@ AutokeyMetadata::ListKeyHandles( return child_->ListKeyHandles(context, options, request); } +StatusOr +AutokeyMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr AutokeyMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr AutokeyMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr AutokeyMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +AutokeyMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> AutokeyMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/kms/v1/internal/autokey_metadata_decorator.h b/google/cloud/kms/v1/internal/autokey_metadata_decorator.h index 4cfb9d281893c..2ded04dbe1bb0 100644 --- a/google/cloud/kms/v1/internal/autokey_metadata_decorator.h +++ b/google/cloud/kms/v1/internal/autokey_metadata_decorator.h @@ -57,6 +57,26 @@ class AutokeyMetadata : public AutokeyStub { grpc::ClientContext& context, Options const& options, google::cloud::kms::v1::ListKeyHandlesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/kms/v1/internal/autokey_stub.cc b/google/cloud/kms/v1/internal/autokey_stub.cc index 0a2a4f5fe1cdb..9ef50f03ec481 100644 --- a/google/cloud/kms/v1/internal/autokey_stub.cc +++ b/google/cloud/kms/v1/internal/autokey_stub.cc @@ -83,6 +83,64 @@ DefaultAutokeyStub::ListKeyHandles( return response; } +StatusOr +DefaultAutokeyStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAutokeyStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAutokeyStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultAutokeyStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultAutokeyStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultAutokeyStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/kms/v1/internal/autokey_stub.h b/google/cloud/kms/v1/internal/autokey_stub.h index 6394634fc5b17..6d91630dc30b6 100644 --- a/google/cloud/kms/v1/internal/autokey_stub.h +++ b/google/cloud/kms/v1/internal/autokey_stub.h @@ -25,6 +25,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include #include @@ -57,6 +61,28 @@ class AutokeyStub { grpc::ClientContext& context, Options const& options, google::cloud::kms::v1::ListKeyHandlesRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -74,9 +100,15 @@ class DefaultAutokeyStub : public AutokeyStub { public: DefaultAutokeyStub( std::unique_ptr grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateKeyHandle( google::cloud::CompletionQueue& cq, @@ -96,6 +128,26 @@ class DefaultAutokeyStub : public AutokeyStub { grpc::ClientContext& context, Options const& options, google::cloud::kms::v1::ListKeyHandlesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -110,6 +162,9 @@ class DefaultAutokeyStub : public AutokeyStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/kms/v1/internal/autokey_stub_factory.cc b/google/cloud/kms/v1/internal/autokey_stub_factory.cc index b941f8ddc1f58..57f829690bd84 100644 --- a/google/cloud/kms/v1/internal/autokey_stub_factory.cc +++ b/google/cloud/kms/v1/internal/autokey_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -43,8 +45,12 @@ std::shared_ptr CreateDefaultAutokeyStub( auto channel = auth->CreateChannel(options.get(), internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::kms::v1::Autokey::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/kms/v1/internal/autokey_tracing_connection.cc b/google/cloud/kms/v1/internal/autokey_tracing_connection.cc index d7609ff83d223..398ab93ed1fe6 100644 --- a/google/cloud/kms/v1/internal/autokey_tracing_connection.cc +++ b/google/cloud/kms/v1/internal/autokey_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/kms/v1/internal/autokey_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -73,6 +74,47 @@ AutokeyTracingConnection::ListKeyHandles( return internal::EndSpan(*span, child_->ListKeyHandles(request)); } +StreamRange +AutokeyTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan("kms_v1::AutokeyConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +AutokeyTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan("kms_v1::AutokeyConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr AutokeyTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan("kms_v1::AutokeyConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr AutokeyTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan("kms_v1::AutokeyConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +AutokeyTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = + internal::MakeSpan("kms_v1::AutokeyConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeAutokeyTracingConnection( diff --git a/google/cloud/kms/v1/internal/autokey_tracing_connection.h b/google/cloud/kms/v1/internal/autokey_tracing_connection.h index 22fb35e64dcd6..63af6bfbaec6f 100644 --- a/google/cloud/kms/v1/internal/autokey_tracing_connection.h +++ b/google/cloud/kms/v1/internal/autokey_tracing_connection.h @@ -55,6 +55,21 @@ class AutokeyTracingConnection : public kms_v1::AutokeyConnection { StatusOr ListKeyHandles( google::cloud::kms::v1::ListKeyHandlesRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/kms/v1/internal/autokey_tracing_stub.cc b/google/cloud/kms/v1/internal/autokey_tracing_stub.cc index 0ea23b47ec17a..9d2bef32c1150 100644 --- a/google/cloud/kms/v1/internal/autokey_tracing_stub.cc +++ b/google/cloud/kms/v1/internal/autokey_tracing_stub.cc @@ -80,6 +80,63 @@ AutokeyTracingStub::ListKeyHandles( child_->ListKeyHandles(context, options, request)); } +StatusOr +AutokeyTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.kms.v1.Autokey", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr AutokeyTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.kms.v1.Autokey", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr AutokeyTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.kms.v1.Autokey", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr AutokeyTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.kms.v1.Autokey", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +AutokeyTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.kms.v1.Autokey", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> AutokeyTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/kms/v1/internal/autokey_tracing_stub.h b/google/cloud/kms/v1/internal/autokey_tracing_stub.h index e1d73e7ccec9a..d3a1ce571af79 100644 --- a/google/cloud/kms/v1/internal/autokey_tracing_stub.h +++ b/google/cloud/kms/v1/internal/autokey_tracing_stub.h @@ -56,6 +56,26 @@ class AutokeyTracingStub : public AutokeyStub { grpc::ClientContext& context, Options const& options, google::cloud::kms::v1::ListKeyHandlesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/kms/v1/internal/ekm_auth_decorator.cc b/google/cloud/kms/v1/internal/ekm_auth_decorator.cc index 87ea4692fa7b0..cc02f2fcfd8e3 100644 --- a/google/cloud/kms/v1/internal/ekm_auth_decorator.cc +++ b/google/cloud/kms/v1/internal/ekm_auth_decorator.cc @@ -92,6 +92,48 @@ EkmServiceAuth::VerifyConnectivity( return child_->VerifyConnectivity(context, options, request); } +StatusOr +EkmServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr EkmServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr EkmServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr EkmServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +EkmServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace kms_v1_internal } // namespace cloud diff --git a/google/cloud/kms/v1/internal/ekm_auth_decorator.h b/google/cloud/kms/v1/internal/ekm_auth_decorator.h index 038dfc3752fc5..66ead98aff6f5 100644 --- a/google/cloud/kms/v1/internal/ekm_auth_decorator.h +++ b/google/cloud/kms/v1/internal/ekm_auth_decorator.h @@ -70,6 +70,26 @@ class EkmServiceAuth : public EkmServiceStub { google::cloud::kms::v1::VerifyConnectivityRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/kms/v1/internal/ekm_connection_impl.cc b/google/cloud/kms/v1/internal/ekm_connection_impl.cc index 570bb67c4b1df..af84635edec29 100644 --- a/google/cloud/kms/v1/internal/ekm_connection_impl.cc +++ b/google/cloud/kms/v1/internal/ekm_connection_impl.cc @@ -177,6 +177,94 @@ EkmServiceConnectionImpl::VerifyConnectivity( *current, request, __func__); } +StreamRange +EkmServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +EkmServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr EkmServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr EkmServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +EkmServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace kms_v1_internal } // namespace cloud diff --git a/google/cloud/kms/v1/internal/ekm_connection_impl.h b/google/cloud/kms/v1/internal/ekm_connection_impl.h index 88e561fd89c97..630008ef75c0c 100644 --- a/google/cloud/kms/v1/internal/ekm_connection_impl.h +++ b/google/cloud/kms/v1/internal/ekm_connection_impl.h @@ -71,6 +71,21 @@ class EkmServiceConnectionImpl : public kms_v1::EkmServiceConnection { VerifyConnectivity(google::cloud::kms::v1::VerifyConnectivityRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/kms/v1/internal/ekm_logging_decorator.cc b/google/cloud/kms/v1/internal/ekm_logging_decorator.cc index bfa6cf16f68fa..8b7d66b95db60 100644 --- a/google/cloud/kms/v1/internal/ekm_logging_decorator.cc +++ b/google/cloud/kms/v1/internal/ekm_logging_decorator.cc @@ -119,6 +119,63 @@ EkmServiceLogging::VerifyConnectivity( context, options, request, __func__, tracing_options_); } +StatusOr +EkmServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EkmServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EkmServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr EkmServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +EkmServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace kms_v1_internal } // namespace cloud diff --git a/google/cloud/kms/v1/internal/ekm_logging_decorator.h b/google/cloud/kms/v1/internal/ekm_logging_decorator.h index 33c7c0b771421..c3e7c0486e108 100644 --- a/google/cloud/kms/v1/internal/ekm_logging_decorator.h +++ b/google/cloud/kms/v1/internal/ekm_logging_decorator.h @@ -70,6 +70,26 @@ class EkmServiceLogging : public EkmServiceStub { google::cloud::kms::v1::VerifyConnectivityRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/kms/v1/internal/ekm_metadata_decorator.cc b/google/cloud/kms/v1/internal/ekm_metadata_decorator.cc index 5ccc403d7e221..bbaf90ebc0dfa 100644 --- a/google/cloud/kms/v1/internal/ekm_metadata_decorator.cc +++ b/google/cloud/kms/v1/internal/ekm_metadata_decorator.cc @@ -108,6 +108,51 @@ EkmServiceMetadata::VerifyConnectivity( return child_->VerifyConnectivity(context, options, request); } +StatusOr +EkmServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr EkmServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr EkmServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr EkmServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +EkmServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + void EkmServiceMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/kms/v1/internal/ekm_metadata_decorator.h b/google/cloud/kms/v1/internal/ekm_metadata_decorator.h index 32065912f2473..2d2cb0a0a4076 100644 --- a/google/cloud/kms/v1/internal/ekm_metadata_decorator.h +++ b/google/cloud/kms/v1/internal/ekm_metadata_decorator.h @@ -70,6 +70,26 @@ class EkmServiceMetadata : public EkmServiceStub { google::cloud::kms::v1::VerifyConnectivityRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/kms/v1/internal/ekm_stub.cc b/google/cloud/kms/v1/internal/ekm_stub.cc index bdf938e181030..e8b8f0e443f07 100644 --- a/google/cloud/kms/v1/internal/ekm_stub.cc +++ b/google/cloud/kms/v1/internal/ekm_stub.cc @@ -113,6 +113,64 @@ DefaultEkmServiceStub::VerifyConnectivity( return response; } +StatusOr +DefaultEkmServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultEkmServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultEkmServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultEkmServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultEkmServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace kms_v1_internal } // namespace cloud diff --git a/google/cloud/kms/v1/internal/ekm_stub.h b/google/cloud/kms/v1/internal/ekm_stub.h index 3de1da07b3e07..7e09d5439d06b 100644 --- a/google/cloud/kms/v1/internal/ekm_stub.h +++ b/google/cloud/kms/v1/internal/ekm_stub.h @@ -23,6 +23,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include @@ -64,14 +68,41 @@ class EkmServiceStub { VerifyConnectivity( grpc::ClientContext& context, Options const& options, google::cloud::kms::v1::VerifyConnectivityRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; }; class DefaultEkmServiceStub : public EkmServiceStub { public: explicit DefaultEkmServiceStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListEkmConnections(grpc::ClientContext& context, Options const& options, @@ -105,8 +136,31 @@ class DefaultEkmServiceStub : public EkmServiceStub { google::cloud::kms::v1::VerifyConnectivityRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/kms/v1/internal/ekm_stub_factory.cc b/google/cloud/kms/v1/internal/ekm_stub_factory.cc index 7e3e1e5aafe32..ab0e3e7e611c3 100644 --- a/google/cloud/kms/v1/internal/ekm_stub_factory.cc +++ b/google/cloud/kms/v1/internal/ekm_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -43,8 +45,13 @@ std::shared_ptr CreateDefaultEkmServiceStub( auto channel = auth->CreateChannel(options.get(), internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::kms::v1::EkmService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + std::make_shared( + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), std::move(stub)); diff --git a/google/cloud/kms/v1/internal/ekm_tracing_connection.cc b/google/cloud/kms/v1/internal/ekm_tracing_connection.cc index fbc3f49a4a93e..e9a4a6bb83e0f 100644 --- a/google/cloud/kms/v1/internal/ekm_tracing_connection.cc +++ b/google/cloud/kms/v1/internal/ekm_tracing_connection.cc @@ -97,6 +97,47 @@ EkmServiceTracingConnection::VerifyConnectivity( return internal::EndSpan(*span, child_->VerifyConnectivity(request)); } +StreamRange +EkmServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan("kms_v1::EkmServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +EkmServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan("kms_v1::EkmServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr EkmServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan("kms_v1::EkmServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr EkmServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan("kms_v1::EkmServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +EkmServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = + internal::MakeSpan("kms_v1::EkmServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeEkmServiceTracingConnection( diff --git a/google/cloud/kms/v1/internal/ekm_tracing_connection.h b/google/cloud/kms/v1/internal/ekm_tracing_connection.h index 7f542ed735087..53caeed1ebe0c 100644 --- a/google/cloud/kms/v1/internal/ekm_tracing_connection.h +++ b/google/cloud/kms/v1/internal/ekm_tracing_connection.h @@ -63,6 +63,21 @@ class EkmServiceTracingConnection : public kms_v1::EkmServiceConnection { VerifyConnectivity(google::cloud::kms::v1::VerifyConnectivityRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/kms/v1/internal/ekm_tracing_stub.cc b/google/cloud/kms/v1/internal/ekm_tracing_stub.cc index ff17bbc939345..3b3c9bf39d86b 100644 --- a/google/cloud/kms/v1/internal/ekm_tracing_stub.cc +++ b/google/cloud/kms/v1/internal/ekm_tracing_stub.cc @@ -115,6 +115,63 @@ EkmServiceTracingStub::VerifyConnectivity( context, *span, child_->VerifyConnectivity(context, options, request)); } +StatusOr +EkmServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.kms.v1.EkmService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr EkmServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.kms.v1.EkmService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr EkmServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.kms.v1.EkmService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr EkmServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.kms.v1.EkmService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +EkmServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.kms.v1.EkmService", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeEkmServiceTracingStub( diff --git a/google/cloud/kms/v1/internal/ekm_tracing_stub.h b/google/cloud/kms/v1/internal/ekm_tracing_stub.h index 9338b272cae33..eb29d00266ffe 100644 --- a/google/cloud/kms/v1/internal/ekm_tracing_stub.h +++ b/google/cloud/kms/v1/internal/ekm_tracing_stub.h @@ -70,6 +70,26 @@ class EkmServiceTracingStub : public EkmServiceStub { google::cloud::kms::v1::VerifyConnectivityRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/kms/v1/internal/key_management_auth_decorator.cc b/google/cloud/kms/v1/internal/key_management_auth_decorator.cc index ff7721dfa934a..65bdcef42585f 100644 --- a/google/cloud/kms/v1/internal/key_management_auth_decorator.cc +++ b/google/cloud/kms/v1/internal/key_management_auth_decorator.cc @@ -283,6 +283,49 @@ KeyManagementServiceAuth::GenerateRandomBytes( return child_->GenerateRandomBytes(context, options, request); } +StatusOr +KeyManagementServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +KeyManagementServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr KeyManagementServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr KeyManagementServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +KeyManagementServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace kms_v1_internal } // namespace cloud diff --git a/google/cloud/kms/v1/internal/key_management_auth_decorator.h b/google/cloud/kms/v1/internal/key_management_auth_decorator.h index d344ea6355701..66a714b22a889 100644 --- a/google/cloud/kms/v1/internal/key_management_auth_decorator.h +++ b/google/cloud/kms/v1/internal/key_management_auth_decorator.h @@ -160,6 +160,26 @@ class KeyManagementServiceAuth : public KeyManagementServiceStub { google::cloud::kms::v1::GenerateRandomBytesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/kms/v1/internal/key_management_connection_impl.cc b/google/cloud/kms/v1/internal/key_management_connection_impl.cc index 13e7be24a47c0..8cce65ebd2704 100644 --- a/google/cloud/kms/v1/internal/key_management_connection_impl.cc +++ b/google/cloud/kms/v1/internal/key_management_connection_impl.cc @@ -541,6 +541,96 @@ KeyManagementServiceConnectionImpl::GenerateRandomBytes( *current, request, __func__); } +StreamRange +KeyManagementServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +KeyManagementServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +KeyManagementServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +KeyManagementServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +KeyManagementServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace kms_v1_internal } // namespace cloud diff --git a/google/cloud/kms/v1/internal/key_management_connection_impl.h b/google/cloud/kms/v1/internal/key_management_connection_impl.h index cc876a133f91f..caeb435fe8133 100644 --- a/google/cloud/kms/v1/internal/key_management_connection_impl.h +++ b/google/cloud/kms/v1/internal/key_management_connection_impl.h @@ -141,6 +141,21 @@ class KeyManagementServiceConnectionImpl GenerateRandomBytes(google::cloud::kms::v1::GenerateRandomBytesRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/kms/v1/internal/key_management_logging_decorator.cc b/google/cloud/kms/v1/internal/key_management_logging_decorator.cc index 6198f1184c307..690380d897e81 100644 --- a/google/cloud/kms/v1/internal/key_management_logging_decorator.cc +++ b/google/cloud/kms/v1/internal/key_management_logging_decorator.cc @@ -381,6 +381,64 @@ KeyManagementServiceLogging::GenerateRandomBytes( context, options, request, __func__, tracing_options_); } +StatusOr +KeyManagementServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +KeyManagementServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr KeyManagementServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr KeyManagementServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +KeyManagementServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace kms_v1_internal } // namespace cloud diff --git a/google/cloud/kms/v1/internal/key_management_logging_decorator.h b/google/cloud/kms/v1/internal/key_management_logging_decorator.h index 737cd445708b4..5dac70f713c1b 100644 --- a/google/cloud/kms/v1/internal/key_management_logging_decorator.h +++ b/google/cloud/kms/v1/internal/key_management_logging_decorator.h @@ -160,6 +160,26 @@ class KeyManagementServiceLogging : public KeyManagementServiceStub { google::cloud::kms::v1::GenerateRandomBytesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/kms/v1/internal/key_management_metadata_decorator.cc b/google/cloud/kms/v1/internal/key_management_metadata_decorator.cc index 271d5db2e85eb..af775eebaae5d 100644 --- a/google/cloud/kms/v1/internal/key_management_metadata_decorator.cc +++ b/google/cloud/kms/v1/internal/key_management_metadata_decorator.cc @@ -301,6 +301,52 @@ KeyManagementServiceMetadata::GenerateRandomBytes( return child_->GenerateRandomBytes(context, options, request); } +StatusOr +KeyManagementServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +KeyManagementServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr KeyManagementServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr KeyManagementServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +KeyManagementServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + void KeyManagementServiceMetadata::SetMetadata( grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/kms/v1/internal/key_management_metadata_decorator.h b/google/cloud/kms/v1/internal/key_management_metadata_decorator.h index 8e9a90fb7b0dc..68ef1eaa6fecc 100644 --- a/google/cloud/kms/v1/internal/key_management_metadata_decorator.h +++ b/google/cloud/kms/v1/internal/key_management_metadata_decorator.h @@ -161,6 +161,26 @@ class KeyManagementServiceMetadata : public KeyManagementServiceStub { google::cloud::kms::v1::GenerateRandomBytesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/kms/v1/internal/key_management_stub.cc b/google/cloud/kms/v1/internal/key_management_stub.cc index a7377ea80ffb2..1fcdc5e7f43a4 100644 --- a/google/cloud/kms/v1/internal/key_management_stub.cc +++ b/google/cloud/kms/v1/internal/key_management_stub.cc @@ -373,6 +373,65 @@ DefaultKeyManagementServiceStub::GenerateRandomBytes( return response; } +StatusOr +DefaultKeyManagementServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultKeyManagementServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultKeyManagementServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultKeyManagementServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultKeyManagementServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace kms_v1_internal } // namespace cloud diff --git a/google/cloud/kms/v1/internal/key_management_stub.h b/google/cloud/kms/v1/internal/key_management_stub.h index 4d665bedf301d..3657903da8bed 100644 --- a/google/cloud/kms/v1/internal/key_management_stub.h +++ b/google/cloud/kms/v1/internal/key_management_stub.h @@ -23,6 +23,10 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include +#include +#include #include #include @@ -162,6 +166,28 @@ class KeyManagementServiceStub { GenerateRandomBytes( grpc::ClientContext& context, Options const& options, google::cloud::kms::v1::GenerateRandomBytesRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; }; class DefaultKeyManagementServiceStub : public KeyManagementServiceStub { @@ -169,8 +195,13 @@ class DefaultKeyManagementServiceStub : public KeyManagementServiceStub { explicit DefaultKeyManagementServiceStub( std::unique_ptr< google::cloud::kms::v1::KeyManagementService::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListKeyRings( grpc::ClientContext& context, Options const& options, @@ -294,9 +325,32 @@ class DefaultKeyManagementServiceStub : public KeyManagementServiceStub { google::cloud::kms::v1::GenerateRandomBytesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/kms/v1/internal/key_management_stub_factory.cc b/google/cloud/kms/v1/internal/key_management_stub_factory.cc index 97c6278f3f5eb..a3f3263a24cba 100644 --- a/google/cloud/kms/v1/internal/key_management_stub_factory.cc +++ b/google/cloud/kms/v1/internal/key_management_stub_factory.cc @@ -29,6 +29,8 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultKeyManagementServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::kms::v1::KeyManagementService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/kms/v1/internal/key_management_tracing_connection.cc b/google/cloud/kms/v1/internal/key_management_tracing_connection.cc index e00c70279a2d6..2fae1b3eb9fec 100644 --- a/google/cloud/kms/v1/internal/key_management_tracing_connection.cc +++ b/google/cloud/kms/v1/internal/key_management_tracing_connection.cc @@ -295,6 +295,53 @@ KeyManagementServiceTracingConnection::GenerateRandomBytes( return internal::EndSpan(*span, child_->GenerateRandomBytes(request)); } +StreamRange +KeyManagementServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "kms_v1::KeyManagementServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +KeyManagementServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("kms_v1::KeyManagementServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +KeyManagementServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "kms_v1::KeyManagementServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +KeyManagementServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "kms_v1::KeyManagementServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +KeyManagementServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "kms_v1::KeyManagementServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/kms/v1/internal/key_management_tracing_connection.h b/google/cloud/kms/v1/internal/key_management_tracing_connection.h index daf513cf050e0..963a93a55269d 100644 --- a/google/cloud/kms/v1/internal/key_management_tracing_connection.h +++ b/google/cloud/kms/v1/internal/key_management_tracing_connection.h @@ -132,6 +132,21 @@ class KeyManagementServiceTracingConnection GenerateRandomBytes(google::cloud::kms::v1::GenerateRandomBytesRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/kms/v1/internal/key_management_tracing_stub.cc b/google/cloud/kms/v1/internal/key_management_tracing_stub.cc index 1dc895a6b6778..97ba0160db1bc 100644 --- a/google/cloud/kms/v1/internal/key_management_tracing_stub.cc +++ b/google/cloud/kms/v1/internal/key_management_tracing_stub.cc @@ -375,6 +375,64 @@ KeyManagementServiceTracingStub::GenerateRandomBytes( context, *span, child_->GenerateRandomBytes(context, options, request)); } +StatusOr +KeyManagementServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.kms.v1.KeyManagementService", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +KeyManagementServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.kms.v1.KeyManagementService", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr KeyManagementServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.kms.v1.KeyManagementService", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr KeyManagementServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.kms.v1.KeyManagementService", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +KeyManagementServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.kms.v1.KeyManagementService", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeKeyManagementServiceTracingStub( diff --git a/google/cloud/kms/v1/internal/key_management_tracing_stub.h b/google/cloud/kms/v1/internal/key_management_tracing_stub.h index 111847cffa13d..25b256ea422d6 100644 --- a/google/cloud/kms/v1/internal/key_management_tracing_stub.h +++ b/google/cloud/kms/v1/internal/key_management_tracing_stub.h @@ -161,6 +161,26 @@ class KeyManagementServiceTracingStub : public KeyManagementServiceStub { google::cloud::kms::v1::GenerateRandomBytesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/kms/v1/key_management_client.cc b/google/cloud/kms/v1/key_management_client.cc index 3a97d93b8d985..fbbd417f6b76c 100644 --- a/google/cloud/kms/v1/key_management_client.cc +++ b/google/cloud/kms/v1/key_management_client.cc @@ -499,6 +499,39 @@ KeyManagementServiceClient::GenerateRandomBytes( return connection_->GenerateRandomBytes(request); } +StreamRange +KeyManagementServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +KeyManagementServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr KeyManagementServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr KeyManagementServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +KeyManagementServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace kms_v1 } // namespace cloud diff --git a/google/cloud/kms/v1/key_management_client.h b/google/cloud/kms/v1/key_management_client.h index 1499efbff06ec..197b168a8a7c8 100644 --- a/google/cloud/kms/v1/key_management_client.h +++ b/google/cloud/kms/v1/key_management_client.h @@ -2092,6 +2092,178 @@ class KeyManagementServiceClient { google::cloud::kms::v1::GenerateRandomBytesRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/kms/v1/key_management_connection.cc b/google/cloud/kms/v1/key_management_connection.cc index 6d2e3c7e2042f..7b99594ae607f 100644 --- a/google/cloud/kms/v1/key_management_connection.cc +++ b/google/cloud/kms/v1/key_management_connection.cc @@ -214,6 +214,36 @@ KeyManagementServiceConnection::GenerateRandomBytes( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +KeyManagementServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +KeyManagementServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr KeyManagementServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr KeyManagementServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +KeyManagementServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeKeyManagementServiceConnection(Options options) { internal::CheckExpectedOptions +#include +#include #include namespace google { @@ -280,6 +282,21 @@ class KeyManagementServiceConnection { virtual StatusOr GenerateRandomBytes( google::cloud::kms::v1::GenerateRandomBytesRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/kms/v1/key_management_connection_idempotency_policy.cc b/google/cloud/kms/v1/key_management_connection_idempotency_policy.cc index 8d971b5b6f4ce..4a7b93a307094 100644 --- a/google/cloud/kms/v1/key_management_connection_idempotency_policy.cc +++ b/google/cloud/kms/v1/key_management_connection_idempotency_policy.cc @@ -184,6 +184,32 @@ KeyManagementServiceConnectionIdempotencyPolicy::GenerateRandomBytes( return Idempotency::kNonIdempotent; } +Idempotency KeyManagementServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency KeyManagementServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency KeyManagementServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency KeyManagementServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency KeyManagementServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultKeyManagementServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/kms/v1/key_management_connection_idempotency_policy.h b/google/cloud/kms/v1/key_management_connection_idempotency_policy.h index 20ba6c910d1d0..4718bbd1de80c 100644 --- a/google/cloud/kms/v1/key_management_connection_idempotency_policy.h +++ b/google/cloud/kms/v1/key_management_connection_idempotency_policy.h @@ -22,6 +22,8 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include +#include #include namespace google { @@ -121,6 +123,21 @@ class KeyManagementServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GenerateRandomBytes( google::cloud::kms::v1::GenerateRandomBytesRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/kms/v1/mocks/mock_autokey_admin_connection.h b/google/cloud/kms/v1/mocks/mock_autokey_admin_connection.h index 0075aba6ada6f..798084b796630 100644 --- a/google/cloud/kms/v1/mocks/mock_autokey_admin_connection.h +++ b/google/cloud/kms/v1/mocks/mock_autokey_admin_connection.h @@ -61,6 +61,27 @@ class MockAutokeyAdminConnection : public kms_v1::AutokeyAdminConnection { (google::cloud::kms::v1::ShowEffectiveAutokeyConfigRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/kms/v1/mocks/mock_autokey_connection.h b/google/cloud/kms/v1/mocks/mock_autokey_connection.h index 14dd1c8750cc2..996ebeb10b64f 100644 --- a/google/cloud/kms/v1/mocks/mock_autokey_connection.h +++ b/google/cloud/kms/v1/mocks/mock_autokey_connection.h @@ -91,6 +91,27 @@ class MockAutokeyConnection : public kms_v1::AutokeyConnection { ListKeyHandles, (google::cloud::kms::v1::ListKeyHandlesRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/kms/v1/mocks/mock_ekm_connection.h b/google/cloud/kms/v1/mocks/mock_ekm_connection.h index 2e0dacc6c8366..83a6bf80a38dd 100644 --- a/google/cloud/kms/v1/mocks/mock_ekm_connection.h +++ b/google/cloud/kms/v1/mocks/mock_ekm_connection.h @@ -78,6 +78,27 @@ class MockEkmServiceConnection : public kms_v1::EkmServiceConnection { VerifyConnectivity, (google::cloud::kms::v1::VerifyConnectivityRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/kms/v1/mocks/mock_key_management_connection.h b/google/cloud/kms/v1/mocks/mock_key_management_connection.h index 943ea42960ab3..2ee3497b5c785 100644 --- a/google/cloud/kms/v1/mocks/mock_key_management_connection.h +++ b/google/cloud/kms/v1/mocks/mock_key_management_connection.h @@ -177,6 +177,27 @@ class MockKeyManagementServiceConnection GenerateRandomBytes, (google::cloud::kms::v1::GenerateRandomBytesRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/managedkafka/BUILD.bazel b/google/cloud/managedkafka/BUILD.bazel index d7a728015a37a..fc1b491b40ce6 100644 --- a/google/cloud/managedkafka/BUILD.bazel +++ b/google/cloud/managedkafka/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/managedkafka/v1:managedkafka_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/managedkafka/v1/internal/managed_kafka_auth_decorator.cc b/google/cloud/managedkafka/v1/internal/managed_kafka_auth_decorator.cc index acf240a6cbb6d..f67ea06c44aa8 100644 --- a/google/cloud/managedkafka/v1/internal/managed_kafka_auth_decorator.cc +++ b/google/cloud/managedkafka/v1/internal/managed_kafka_auth_decorator.cc @@ -210,6 +210,23 @@ Status ManagedKafkaAuth::DeleteConsumerGroup( return child_->DeleteConsumerGroup(context, options, request); } +StatusOr +ManagedKafkaAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr ManagedKafkaAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> ManagedKafkaAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/managedkafka/v1/internal/managed_kafka_auth_decorator.h b/google/cloud/managedkafka/v1/internal/managed_kafka_auth_decorator.h index 8356f3a9aa5a3..ce28dd3c88d48 100644 --- a/google/cloud/managedkafka/v1/internal/managed_kafka_auth_decorator.h +++ b/google/cloud/managedkafka/v1/internal/managed_kafka_auth_decorator.h @@ -129,6 +129,14 @@ class ManagedKafkaAuth : public ManagedKafkaStub { google::cloud::managedkafka::v1::DeleteConsumerGroupRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/managedkafka/v1/internal/managed_kafka_connection_impl.cc b/google/cloud/managedkafka/v1/internal/managed_kafka_connection_impl.cc index 037054a68b6b6..7e66fa1eb047b 100644 --- a/google/cloud/managedkafka/v1/internal/managed_kafka_connection_impl.cc +++ b/google/cloud/managedkafka/v1/internal/managed_kafka_connection_impl.cc @@ -566,6 +566,54 @@ Status ManagedKafkaConnectionImpl::DeleteConsumerGroup( *current, request, __func__); } +StreamRange +ManagedKafkaConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ManagedKafkaConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace managedkafka_v1_internal } // namespace cloud diff --git a/google/cloud/managedkafka/v1/internal/managed_kafka_connection_impl.h b/google/cloud/managedkafka/v1/internal/managed_kafka_connection_impl.h index fc7daa1ceb9f6..836125aab37fb 100644 --- a/google/cloud/managedkafka/v1/internal/managed_kafka_connection_impl.h +++ b/google/cloud/managedkafka/v1/internal/managed_kafka_connection_impl.h @@ -128,6 +128,12 @@ class ManagedKafkaConnectionImpl google::cloud::managedkafka::v1::DeleteConsumerGroupRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/managedkafka/v1/internal/managed_kafka_logging_decorator.cc b/google/cloud/managedkafka/v1/internal/managed_kafka_logging_decorator.cc index dc585a78cd56e..ab7e50ef89af9 100644 --- a/google/cloud/managedkafka/v1/internal/managed_kafka_logging_decorator.cc +++ b/google/cloud/managedkafka/v1/internal/managed_kafka_logging_decorator.cc @@ -269,6 +269,29 @@ Status ManagedKafkaLogging::DeleteConsumerGroup( context, options, request, __func__, tracing_options_); } +StatusOr +ManagedKafkaLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ManagedKafkaLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ManagedKafkaLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/managedkafka/v1/internal/managed_kafka_logging_decorator.h b/google/cloud/managedkafka/v1/internal/managed_kafka_logging_decorator.h index cbd21ee569145..14f07cfea0458 100644 --- a/google/cloud/managedkafka/v1/internal/managed_kafka_logging_decorator.h +++ b/google/cloud/managedkafka/v1/internal/managed_kafka_logging_decorator.h @@ -129,6 +129,14 @@ class ManagedKafkaLogging : public ManagedKafkaStub { google::cloud::managedkafka::v1::DeleteConsumerGroupRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/managedkafka/v1/internal/managed_kafka_metadata_decorator.cc b/google/cloud/managedkafka/v1/internal/managed_kafka_metadata_decorator.cc index 45bbcfbc825ac..4f81e82af08a2 100644 --- a/google/cloud/managedkafka/v1/internal/managed_kafka_metadata_decorator.cc +++ b/google/cloud/managedkafka/v1/internal/managed_kafka_metadata_decorator.cc @@ -207,6 +207,23 @@ Status ManagedKafkaMetadata::DeleteConsumerGroup( return child_->DeleteConsumerGroup(context, options, request); } +StatusOr +ManagedKafkaMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr ManagedKafkaMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> ManagedKafkaMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/managedkafka/v1/internal/managed_kafka_metadata_decorator.h b/google/cloud/managedkafka/v1/internal/managed_kafka_metadata_decorator.h index 8007ecf180e36..b1472da9c7218 100644 --- a/google/cloud/managedkafka/v1/internal/managed_kafka_metadata_decorator.h +++ b/google/cloud/managedkafka/v1/internal/managed_kafka_metadata_decorator.h @@ -129,6 +129,14 @@ class ManagedKafkaMetadata : public ManagedKafkaStub { google::cloud::managedkafka::v1::DeleteConsumerGroupRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/managedkafka/v1/internal/managed_kafka_stub.cc b/google/cloud/managedkafka/v1/internal/managed_kafka_stub.cc index 632e7430f0005..8005e88a72bd0 100644 --- a/google/cloud/managedkafka/v1/internal/managed_kafka_stub.cc +++ b/google/cloud/managedkafka/v1/internal/managed_kafka_stub.cc @@ -253,6 +253,30 @@ Status DefaultManagedKafkaStub::DeleteConsumerGroup( return google::cloud::Status(); } +StatusOr +DefaultManagedKafkaStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultManagedKafkaStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultManagedKafkaStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/managedkafka/v1/internal/managed_kafka_stub.h b/google/cloud/managedkafka/v1/internal/managed_kafka_stub.h index 890b04b2109a7..2f0e760a17507 100644 --- a/google/cloud/managedkafka/v1/internal/managed_kafka_stub.h +++ b/google/cloud/managedkafka/v1/internal/managed_kafka_stub.h @@ -24,6 +24,8 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include #include @@ -121,6 +123,15 @@ class ManagedKafkaStub { google::cloud::managedkafka::v1::DeleteConsumerGroupRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -140,9 +151,13 @@ class DefaultManagedKafkaStub : public ManagedKafkaStub { std::unique_ptr< google::cloud::managedkafka::v1::ManagedKafka::StubInterface> grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListClusters( grpc::ClientContext& context, Options const& options, @@ -234,6 +249,14 @@ class DefaultManagedKafkaStub : public ManagedKafkaStub { google::cloud::managedkafka::v1::DeleteConsumerGroupRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -249,6 +272,8 @@ class DefaultManagedKafkaStub : public ManagedKafkaStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/managedkafka/v1/internal/managed_kafka_stub_factory.cc b/google/cloud/managedkafka/v1/internal/managed_kafka_stub_factory.cc index ecc8e78b2787d..a08bcc6b7426d 100644 --- a/google/cloud/managedkafka/v1/internal/managed_kafka_stub_factory.cc +++ b/google/cloud/managedkafka/v1/internal/managed_kafka_stub_factory.cc @@ -28,6 +28,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultManagedKafkaStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::managedkafka::v1::ManagedKafka::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/managedkafka/v1/internal/managed_kafka_tracing_connection.cc b/google/cloud/managedkafka/v1/internal/managed_kafka_tracing_connection.cc index 3212982383a97..be9ef5fa62de1 100644 --- a/google/cloud/managedkafka/v1/internal/managed_kafka_tracing_connection.cc +++ b/google/cloud/managedkafka/v1/internal/managed_kafka_tracing_connection.cc @@ -223,6 +223,26 @@ Status ManagedKafkaTracingConnection::DeleteConsumerGroup( return internal::EndSpan(*span, child_->DeleteConsumerGroup(request)); } +StreamRange +ManagedKafkaTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "managedkafka_v1::ManagedKafkaConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ManagedKafkaTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "managedkafka_v1::ManagedKafkaConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/managedkafka/v1/internal/managed_kafka_tracing_connection.h b/google/cloud/managedkafka/v1/internal/managed_kafka_tracing_connection.h index e9823571f3a7d..3dd8b568efb04 100644 --- a/google/cloud/managedkafka/v1/internal/managed_kafka_tracing_connection.h +++ b/google/cloud/managedkafka/v1/internal/managed_kafka_tracing_connection.h @@ -116,6 +116,12 @@ class ManagedKafkaTracingConnection google::cloud::managedkafka::v1::DeleteConsumerGroupRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/managedkafka/v1/internal/managed_kafka_tracing_stub.cc b/google/cloud/managedkafka/v1/internal/managed_kafka_tracing_stub.cc index aab8d0f7b1c7e..01974ac89f442 100644 --- a/google/cloud/managedkafka/v1/internal/managed_kafka_tracing_stub.cc +++ b/google/cloud/managedkafka/v1/internal/managed_kafka_tracing_stub.cc @@ -239,6 +239,30 @@ Status ManagedKafkaTracingStub::DeleteConsumerGroup( context, *span, child_->DeleteConsumerGroup(context, options, request)); } +StatusOr +ManagedKafkaTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.managedkafka.v1.ManagedKafka", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +ManagedKafkaTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.managedkafka.v1.ManagedKafka", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> ManagedKafkaTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/managedkafka/v1/internal/managed_kafka_tracing_stub.h b/google/cloud/managedkafka/v1/internal/managed_kafka_tracing_stub.h index 7c74c39c5670f..8006f3babc428 100644 --- a/google/cloud/managedkafka/v1/internal/managed_kafka_tracing_stub.h +++ b/google/cloud/managedkafka/v1/internal/managed_kafka_tracing_stub.h @@ -128,6 +128,14 @@ class ManagedKafkaTracingStub : public ManagedKafkaStub { google::cloud::managedkafka::v1::DeleteConsumerGroupRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/managedkafka/v1/managed_kafka_client.cc b/google/cloud/managedkafka/v1/managed_kafka_client.cc index 6f3b324a08c5c..01ece7c73966d 100644 --- a/google/cloud/managedkafka/v1/managed_kafka_client.cc +++ b/google/cloud/managedkafka/v1/managed_kafka_client.cc @@ -346,6 +346,19 @@ Status ManagedKafkaClient::DeleteConsumerGroup( return connection_->DeleteConsumerGroup(request); } +StreamRange +ManagedKafkaClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr ManagedKafkaClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace managedkafka_v1 } // namespace cloud diff --git a/google/cloud/managedkafka/v1/managed_kafka_client.h b/google/cloud/managedkafka/v1/managed_kafka_client.h index 65ed7f88b54e6..aad8149f6c0c8 100644 --- a/google/cloud/managedkafka/v1/managed_kafka_client.h +++ b/google/cloud/managedkafka/v1/managed_kafka_client.h @@ -1137,6 +1137,76 @@ class ManagedKafkaClient { request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/managedkafka/v1/managed_kafka_connection.cc b/google/cloud/managedkafka/v1/managed_kafka_connection.cc index 811da96e81af8..34684d5fcd0b9 100644 --- a/google/cloud/managedkafka/v1/managed_kafka_connection.cc +++ b/google/cloud/managedkafka/v1/managed_kafka_connection.cc @@ -171,6 +171,19 @@ Status ManagedKafkaConnection::DeleteConsumerGroup( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +ManagedKafkaConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr ManagedKafkaConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeManagedKafkaConnection( Options options) { internal::CheckExpectedOptions #include #include #include @@ -256,6 +257,12 @@ class ManagedKafkaConnection { virtual Status DeleteConsumerGroup( google::cloud::managedkafka::v1::DeleteConsumerGroupRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/managedkafka/v1/managed_kafka_connection_idempotency_policy.cc b/google/cloud/managedkafka/v1/managed_kafka_connection_idempotency_policy.cc index b2db4424694c4..6f93c452108d6 100644 --- a/google/cloud/managedkafka/v1/managed_kafka_connection_idempotency_policy.cc +++ b/google/cloud/managedkafka/v1/managed_kafka_connection_idempotency_policy.cc @@ -104,6 +104,16 @@ Idempotency ManagedKafkaConnectionIdempotencyPolicy::DeleteConsumerGroup( return Idempotency::kNonIdempotent; } +Idempotency ManagedKafkaConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ManagedKafkaConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultManagedKafkaConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/managedkafka/v1/managed_kafka_connection_idempotency_policy.h b/google/cloud/managedkafka/v1/managed_kafka_connection_idempotency_policy.h index eee0e1a2336a7..eec6dab340b98 100644 --- a/google/cloud/managedkafka/v1/managed_kafka_connection_idempotency_policy.h +++ b/google/cloud/managedkafka/v1/managed_kafka_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -80,6 +81,12 @@ class ManagedKafkaConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteConsumerGroup( google::cloud::managedkafka::v1::DeleteConsumerGroupRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/managedkafka/v1/mocks/mock_managed_kafka_connection.h b/google/cloud/managedkafka/v1/mocks/mock_managed_kafka_connection.h index f6245087c42df..82318c6d32a48 100644 --- a/google/cloud/managedkafka/v1/mocks/mock_managed_kafka_connection.h +++ b/google/cloud/managedkafka/v1/mocks/mock_managed_kafka_connection.h @@ -220,6 +220,14 @@ class MockManagedKafkaConnection (google::cloud::managedkafka::v1::DeleteConsumerGroupRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/memcache/BUILD.bazel b/google/cloud/memcache/BUILD.bazel index de82ac26cddf5..d5c937f7f2630 100644 --- a/google/cloud/memcache/BUILD.bazel +++ b/google/cloud/memcache/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/memcache/v1:memcache_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/memcache/v1/cloud_memcache_client.cc b/google/cloud/memcache/v1/cloud_memcache_client.cc index b65ad6c2401c4..dd092773441d1 100644 --- a/google/cloud/memcache/v1/cloud_memcache_client.cc +++ b/google/cloud/memcache/v1/cloud_memcache_client.cc @@ -341,6 +341,19 @@ CloudMemcacheClient::RescheduleMaintenance( return connection_->RescheduleMaintenance(operation); } +StreamRange +CloudMemcacheClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr CloudMemcacheClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace memcache_v1 } // namespace cloud diff --git a/google/cloud/memcache/v1/cloud_memcache_client.h b/google/cloud/memcache/v1/cloud_memcache_client.h index 1fa2831596d4f..d009168d9225c 100644 --- a/google/cloud/memcache/v1/cloud_memcache_client.h +++ b/google/cloud/memcache/v1/cloud_memcache_client.h @@ -973,6 +973,76 @@ class CloudMemcacheClient { future> RescheduleMaintenance( google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/memcache/v1/cloud_memcache_connection.cc b/google/cloud/memcache/v1/cloud_memcache_connection.cc index 47b3856644a13..a8fbeb8a3f23b 100644 --- a/google/cloud/memcache/v1/cloud_memcache_connection.cc +++ b/google/cloud/memcache/v1/cloud_memcache_connection.cc @@ -188,6 +188,20 @@ CloudMemcacheConnection::RescheduleMaintenance( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +CloudMemcacheConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +CloudMemcacheConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCloudMemcacheConnection( Options options) { internal::CheckExpectedOptions #include #include #include @@ -257,6 +258,12 @@ class CloudMemcacheConnection { virtual future> RescheduleMaintenance(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/memcache/v1/cloud_memcache_connection_idempotency_policy.cc b/google/cloud/memcache/v1/cloud_memcache_connection_idempotency_policy.cc index 654e230d20d61..12ef27ccced4d 100644 --- a/google/cloud/memcache/v1/cloud_memcache_connection_idempotency_policy.cc +++ b/google/cloud/memcache/v1/cloud_memcache_connection_idempotency_policy.cc @@ -74,6 +74,16 @@ Idempotency CloudMemcacheConnectionIdempotencyPolicy::RescheduleMaintenance( return Idempotency::kNonIdempotent; } +Idempotency CloudMemcacheConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CloudMemcacheConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultCloudMemcacheConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/memcache/v1/cloud_memcache_connection_idempotency_policy.h b/google/cloud/memcache/v1/cloud_memcache_connection_idempotency_policy.h index 84f00bd8dff81..bf5c407646bd3 100644 --- a/google/cloud/memcache/v1/cloud_memcache_connection_idempotency_policy.h +++ b/google/cloud/memcache/v1/cloud_memcache_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -60,6 +61,12 @@ class CloudMemcacheConnectionIdempotencyPolicy { virtual google::cloud::Idempotency RescheduleMaintenance( google::cloud::memcache::v1::RescheduleMaintenanceRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/memcache/v1/internal/cloud_memcache_auth_decorator.cc b/google/cloud/memcache/v1/internal/cloud_memcache_auth_decorator.cc index b315ee108b8b4..930691a5a2d11 100644 --- a/google/cloud/memcache/v1/internal/cloud_memcache_auth_decorator.cc +++ b/google/cloud/memcache/v1/internal/cloud_memcache_auth_decorator.cc @@ -217,6 +217,23 @@ CloudMemcacheAuth::RescheduleMaintenance( return child_->RescheduleMaintenance(context, options, request); } +StatusOr +CloudMemcacheAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr CloudMemcacheAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> CloudMemcacheAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/memcache/v1/internal/cloud_memcache_auth_decorator.h b/google/cloud/memcache/v1/internal/cloud_memcache_auth_decorator.h index fad68d110ad8a..0a7f1a1c8bac1 100644 --- a/google/cloud/memcache/v1/internal/cloud_memcache_auth_decorator.h +++ b/google/cloud/memcache/v1/internal/cloud_memcache_auth_decorator.h @@ -120,6 +120,14 @@ class CloudMemcacheAuth : public CloudMemcacheStub { google::cloud::memcache::v1::RescheduleMaintenanceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/memcache/v1/internal/cloud_memcache_connection_impl.cc b/google/cloud/memcache/v1/internal/cloud_memcache_connection_impl.cc index 9a85c2c623be1..a443f2d0c4ac4 100644 --- a/google/cloud/memcache/v1/internal/cloud_memcache_connection_impl.cc +++ b/google/cloud/memcache/v1/internal/cloud_memcache_connection_impl.cc @@ -660,6 +660,54 @@ CloudMemcacheConnectionImpl::RescheduleMaintenance( polling_policy(*current), __func__); } +StreamRange +CloudMemcacheConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +CloudMemcacheConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace memcache_v1_internal } // namespace cloud diff --git a/google/cloud/memcache/v1/internal/cloud_memcache_connection_impl.h b/google/cloud/memcache/v1/internal/cloud_memcache_connection_impl.h index cb5ee386b327a..18b6d8c4e82fe 100644 --- a/google/cloud/memcache/v1/internal/cloud_memcache_connection_impl.h +++ b/google/cloud/memcache/v1/internal/cloud_memcache_connection_impl.h @@ -130,6 +130,12 @@ class CloudMemcacheConnectionImpl future> RescheduleMaintenance( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/memcache/v1/internal/cloud_memcache_logging_decorator.cc b/google/cloud/memcache/v1/internal/cloud_memcache_logging_decorator.cc index 22e9f1a62a20e..b3bb18d540dbb 100644 --- a/google/cloud/memcache/v1/internal/cloud_memcache_logging_decorator.cc +++ b/google/cloud/memcache/v1/internal/cloud_memcache_logging_decorator.cc @@ -246,6 +246,29 @@ CloudMemcacheLogging::RescheduleMaintenance( context, options, request, __func__, tracing_options_); } +StatusOr +CloudMemcacheLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr CloudMemcacheLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> CloudMemcacheLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/memcache/v1/internal/cloud_memcache_logging_decorator.h b/google/cloud/memcache/v1/internal/cloud_memcache_logging_decorator.h index 5ad098f35de99..4625a4096ba1f 100644 --- a/google/cloud/memcache/v1/internal/cloud_memcache_logging_decorator.h +++ b/google/cloud/memcache/v1/internal/cloud_memcache_logging_decorator.h @@ -120,6 +120,14 @@ class CloudMemcacheLogging : public CloudMemcacheStub { google::cloud::memcache::v1::RescheduleMaintenanceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/memcache/v1/internal/cloud_memcache_metadata_decorator.cc b/google/cloud/memcache/v1/internal/cloud_memcache_metadata_decorator.cc index b5130560486f1..23d270a604a5a 100644 --- a/google/cloud/memcache/v1/internal/cloud_memcache_metadata_decorator.cc +++ b/google/cloud/memcache/v1/internal/cloud_memcache_metadata_decorator.cc @@ -188,6 +188,23 @@ CloudMemcacheMetadata::RescheduleMaintenance( return child_->RescheduleMaintenance(context, options, request); } +StatusOr +CloudMemcacheMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr CloudMemcacheMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> CloudMemcacheMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/memcache/v1/internal/cloud_memcache_metadata_decorator.h b/google/cloud/memcache/v1/internal/cloud_memcache_metadata_decorator.h index e9a740eedcb19..52902d24e470f 100644 --- a/google/cloud/memcache/v1/internal/cloud_memcache_metadata_decorator.h +++ b/google/cloud/memcache/v1/internal/cloud_memcache_metadata_decorator.h @@ -120,6 +120,14 @@ class CloudMemcacheMetadata : public CloudMemcacheStub { google::cloud::memcache::v1::RescheduleMaintenanceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/memcache/v1/internal/cloud_memcache_stub.cc b/google/cloud/memcache/v1/internal/cloud_memcache_stub.cc index c456756ba32b7..2f0d3ed2005e3 100644 --- a/google/cloud/memcache/v1/internal/cloud_memcache_stub.cc +++ b/google/cloud/memcache/v1/internal/cloud_memcache_stub.cc @@ -237,6 +237,30 @@ DefaultCloudMemcacheStub::RescheduleMaintenance( return response; } +StatusOr +DefaultCloudMemcacheStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultCloudMemcacheStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultCloudMemcacheStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/memcache/v1/internal/cloud_memcache_stub.h b/google/cloud/memcache/v1/internal/cloud_memcache_stub.h index ec76f40ae1818..4ccaf26a015ab 100644 --- a/google/cloud/memcache/v1/internal/cloud_memcache_stub.h +++ b/google/cloud/memcache/v1/internal/cloud_memcache_stub.h @@ -24,6 +24,8 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include #include @@ -111,6 +113,15 @@ class CloudMemcacheStub { google::cloud::memcache::v1::RescheduleMaintenanceRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -129,9 +140,13 @@ class DefaultCloudMemcacheStub : public CloudMemcacheStub { DefaultCloudMemcacheStub( std::unique_ptr grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListInstances( grpc::ClientContext& context, Options const& options, @@ -214,6 +229,14 @@ class DefaultCloudMemcacheStub : public CloudMemcacheStub { google::cloud::memcache::v1::RescheduleMaintenanceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -229,6 +252,8 @@ class DefaultCloudMemcacheStub : public CloudMemcacheStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/memcache/v1/internal/cloud_memcache_stub_factory.cc b/google/cloud/memcache/v1/internal/cloud_memcache_stub_factory.cc index d5293c475d827..9a2860ef17a77 100644 --- a/google/cloud/memcache/v1/internal/cloud_memcache_stub_factory.cc +++ b/google/cloud/memcache/v1/internal/cloud_memcache_stub_factory.cc @@ -28,6 +28,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultCloudMemcacheStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::memcache::v1::CloudMemcache::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/memcache/v1/internal/cloud_memcache_tracing_connection.cc b/google/cloud/memcache/v1/internal/cloud_memcache_tracing_connection.cc index 0ea0a14d00664..65f2ffe4f7452 100644 --- a/google/cloud/memcache/v1/internal/cloud_memcache_tracing_connection.cc +++ b/google/cloud/memcache/v1/internal/cloud_memcache_tracing_connection.cc @@ -230,6 +230,26 @@ CloudMemcacheTracingConnection::RescheduleMaintenance( child_->RescheduleMaintenance(operation)); } +StreamRange +CloudMemcacheTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("memcache_v1::CloudMemcacheConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CloudMemcacheTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("memcache_v1::CloudMemcacheConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/memcache/v1/internal/cloud_memcache_tracing_connection.h b/google/cloud/memcache/v1/internal/cloud_memcache_tracing_connection.h index 265e177786551..c52648ea6e22a 100644 --- a/google/cloud/memcache/v1/internal/cloud_memcache_tracing_connection.h +++ b/google/cloud/memcache/v1/internal/cloud_memcache_tracing_connection.h @@ -118,6 +118,12 @@ class CloudMemcacheTracingConnection future> RescheduleMaintenance( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/memcache/v1/internal/cloud_memcache_tracing_stub.cc b/google/cloud/memcache/v1/internal/cloud_memcache_tracing_stub.cc index ee67cdfdc31da..db9bf39e0ca2b 100644 --- a/google/cloud/memcache/v1/internal/cloud_memcache_tracing_stub.cc +++ b/google/cloud/memcache/v1/internal/cloud_memcache_tracing_stub.cc @@ -218,6 +218,30 @@ CloudMemcacheTracingStub::RescheduleMaintenance( context, *span, child_->RescheduleMaintenance(context, options, request)); } +StatusOr +CloudMemcacheTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.memcache.v1.CloudMemcache", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +CloudMemcacheTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.memcache.v1.CloudMemcache", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> CloudMemcacheTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/memcache/v1/internal/cloud_memcache_tracing_stub.h b/google/cloud/memcache/v1/internal/cloud_memcache_tracing_stub.h index 8bf03f5604ccd..a6ab10a54c333 100644 --- a/google/cloud/memcache/v1/internal/cloud_memcache_tracing_stub.h +++ b/google/cloud/memcache/v1/internal/cloud_memcache_tracing_stub.h @@ -119,6 +119,14 @@ class CloudMemcacheTracingStub : public CloudMemcacheStub { google::cloud::memcache::v1::RescheduleMaintenanceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/memcache/v1/mocks/mock_cloud_memcache_connection.h b/google/cloud/memcache/v1/mocks/mock_cloud_memcache_connection.h index 64da16af52482..a91b60f0654d1 100644 --- a/google/cloud/memcache/v1/mocks/mock_cloud_memcache_connection.h +++ b/google/cloud/memcache/v1/mocks/mock_cloud_memcache_connection.h @@ -285,6 +285,14 @@ class MockCloudMemcacheConnection MOCK_METHOD(future>, RescheduleMaintenance, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/metastore/BUILD.bazel b/google/cloud/metastore/BUILD.bazel index a6dd7643bb1a4..eb4555d008db6 100644 --- a/google/cloud/metastore/BUILD.bazel +++ b/google/cloud/metastore/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/metastore/v1:metastore_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/metastore/v1/dataproc_metastore_client.cc b/google/cloud/metastore/v1/dataproc_metastore_client.cc index 25afd4c4c19ae..8615c286c19e9 100644 --- a/google/cloud/metastore/v1/dataproc_metastore_client.cc +++ b/google/cloud/metastore/v1/dataproc_metastore_client.cc @@ -588,6 +588,39 @@ DataprocMetastoreClient::AlterMetadataResourceLocation( return connection_->AlterMetadataResourceLocation(operation); } +StreamRange +DataprocMetastoreClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +DataprocMetastoreClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr DataprocMetastoreClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr DataprocMetastoreClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +DataprocMetastoreClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace metastore_v1 } // namespace cloud diff --git a/google/cloud/metastore/v1/dataproc_metastore_client.h b/google/cloud/metastore/v1/dataproc_metastore_client.h index 116b4a60d8291..11d721d52fd83 100644 --- a/google/cloud/metastore/v1/dataproc_metastore_client.h +++ b/google/cloud/metastore/v1/dataproc_metastore_client.h @@ -1781,6 +1781,178 @@ class DataprocMetastoreClient { AlterMetadataResourceLocation(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/metastore/v1/dataproc_metastore_connection.cc b/google/cloud/metastore/v1/dataproc_metastore_connection.cc index 69d6c4361167b..b4b77f25b4724 100644 --- a/google/cloud/metastore/v1/dataproc_metastore_connection.cc +++ b/google/cloud/metastore/v1/dataproc_metastore_connection.cc @@ -362,6 +362,36 @@ DataprocMetastoreConnection::AlterMetadataResourceLocation( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +DataprocMetastoreConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DataprocMetastoreConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr DataprocMetastoreConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr DataprocMetastoreConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +DataprocMetastoreConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDataprocMetastoreConnection( Options options) { internal::CheckExpectedOptions #include +#include #include #include @@ -343,6 +345,21 @@ class DataprocMetastoreConnection { google::cloud::metastore::v1::AlterMetadataResourceLocationResponse>> AlterMetadataResourceLocation( google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/metastore/v1/dataproc_metastore_connection_idempotency_policy.cc b/google/cloud/metastore/v1/dataproc_metastore_connection_idempotency_policy.cc index c09f83f4943d1..d0c53fc0a3269 100644 --- a/google/cloud/metastore/v1/dataproc_metastore_connection_idempotency_policy.cc +++ b/google/cloud/metastore/v1/dataproc_metastore_connection_idempotency_policy.cc @@ -125,6 +125,32 @@ DataprocMetastoreConnectionIdempotencyPolicy::AlterMetadataResourceLocation( return Idempotency::kNonIdempotent; } +Idempotency DataprocMetastoreConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DataprocMetastoreConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DataprocMetastoreConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency DataprocMetastoreConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DataprocMetastoreConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultDataprocMetastoreConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/metastore/v1/dataproc_metastore_connection_idempotency_policy.h b/google/cloud/metastore/v1/dataproc_metastore_connection_idempotency_policy.h index ee577d27fa371..42ca8376b2ac9 100644 --- a/google/cloud/metastore/v1/dataproc_metastore_connection_idempotency_policy.h +++ b/google/cloud/metastore/v1/dataproc_metastore_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -91,6 +93,21 @@ class DataprocMetastoreConnectionIdempotencyPolicy { virtual google::cloud::Idempotency AlterMetadataResourceLocation( google::cloud::metastore::v1::AlterMetadataResourceLocationRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/metastore/v1/dataproc_metastore_federation_client.cc b/google/cloud/metastore/v1/dataproc_metastore_federation_client.cc index de2973c8822d0..68fbf45301892 100644 --- a/google/cloud/metastore/v1/dataproc_metastore_federation_client.cc +++ b/google/cloud/metastore/v1/dataproc_metastore_federation_client.cc @@ -207,6 +207,41 @@ DataprocMetastoreFederationClient::DeleteFederation( return connection_->DeleteFederation(operation); } +StreamRange +DataprocMetastoreFederationClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +DataprocMetastoreFederationClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr +DataprocMetastoreFederationClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr +DataprocMetastoreFederationClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +DataprocMetastoreFederationClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace metastore_v1 } // namespace cloud diff --git a/google/cloud/metastore/v1/dataproc_metastore_federation_client.h b/google/cloud/metastore/v1/dataproc_metastore_federation_client.h index 81d99b4ca3281..81d61a8775bdb 100644 --- a/google/cloud/metastore/v1/dataproc_metastore_federation_client.h +++ b/google/cloud/metastore/v1/dataproc_metastore_federation_client.h @@ -607,6 +607,178 @@ class DataprocMetastoreFederationClient { DeleteFederation(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/metastore/v1/dataproc_metastore_federation_connection.cc b/google/cloud/metastore/v1/dataproc_metastore_federation_connection.cc index 9bedd24ec2a61..1d8c8aa8de894 100644 --- a/google/cloud/metastore/v1/dataproc_metastore_federation_connection.cc +++ b/google/cloud/metastore/v1/dataproc_metastore_federation_connection.cc @@ -122,6 +122,38 @@ DataprocMetastoreFederationConnection::DeleteFederation( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +DataprocMetastoreFederationConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +DataprocMetastoreFederationConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +DataprocMetastoreFederationConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +DataprocMetastoreFederationConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +DataprocMetastoreFederationConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDataprocMetastoreFederationConnection(Options options) { internal::CheckExpectedOptions #include +#include #include #include @@ -241,6 +243,21 @@ class DataprocMetastoreFederationConnection { virtual future> DeleteFederation(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/metastore/v1/dataproc_metastore_federation_connection_idempotency_policy.cc b/google/cloud/metastore/v1/dataproc_metastore_federation_connection_idempotency_policy.cc index 0fc3bf870c8dd..fc18549935428 100644 --- a/google/cloud/metastore/v1/dataproc_metastore_federation_connection_idempotency_policy.cc +++ b/google/cloud/metastore/v1/dataproc_metastore_federation_connection_idempotency_policy.cc @@ -65,6 +65,36 @@ DataprocMetastoreFederationConnectionIdempotencyPolicy::DeleteFederation( return Idempotency::kNonIdempotent; } +Idempotency +DataprocMetastoreFederationConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DataprocMetastoreFederationConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +DataprocMetastoreFederationConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency +DataprocMetastoreFederationConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +DataprocMetastoreFederationConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultDataprocMetastoreFederationConnectionIdempotencyPolicy() { return std::make_unique< diff --git a/google/cloud/metastore/v1/dataproc_metastore_federation_connection_idempotency_policy.h b/google/cloud/metastore/v1/dataproc_metastore_federation_connection_idempotency_policy.h index 43e3a24bb9168..9e6e7aa77c14b 100644 --- a/google/cloud/metastore/v1/dataproc_metastore_federation_connection_idempotency_policy.h +++ b/google/cloud/metastore/v1/dataproc_metastore_federation_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -52,6 +54,21 @@ class DataprocMetastoreFederationConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteFederation( google::cloud::metastore::v1::DeleteFederationRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_auth_decorator.cc b/google/cloud/metastore/v1/internal/dataproc_metastore_auth_decorator.cc index 350b3edaeedad..aefdedf4e34a9 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_auth_decorator.cc +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_auth_decorator.cc @@ -426,6 +426,48 @@ DataprocMetastoreAuth::AlterMetadataResourceLocation( return child_->AlterMetadataResourceLocation(context, options, request); } +StatusOr +DataprocMetastoreAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr DataprocMetastoreAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr DataprocMetastoreAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr DataprocMetastoreAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +DataprocMetastoreAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> DataprocMetastoreAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_auth_decorator.h b/google/cloud/metastore/v1/internal/dataproc_metastore_auth_decorator.h index 5328e522fd484..f826aef9d3dac 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_auth_decorator.h +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_auth_decorator.h @@ -212,6 +212,26 @@ class DataprocMetastoreAuth : public DataprocMetastoreStub { google::cloud::metastore::v1::AlterMetadataResourceLocationRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_connection_impl.cc b/google/cloud/metastore/v1/internal/dataproc_metastore_connection_impl.cc index 9b060b80e44df..bd7ea9e61ed0c 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_connection_impl.cc +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_connection_impl.cc @@ -1318,6 +1318,94 @@ DataprocMetastoreConnectionImpl::AlterMetadataResourceLocation( polling_policy(*current), __func__); } +StreamRange +DataprocMetastoreConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DataprocMetastoreConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr DataprocMetastoreConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr DataprocMetastoreConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +DataprocMetastoreConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace metastore_v1_internal } // namespace cloud diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_connection_impl.h b/google/cloud/metastore/v1/internal/dataproc_metastore_connection_impl.h index d1514e46a5817..a25abce03e9da 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_connection_impl.h +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_connection_impl.h @@ -225,6 +225,21 @@ class DataprocMetastoreConnectionImpl AlterMetadataResourceLocation( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_auth_decorator.cc b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_auth_decorator.cc index fde6c1823c848..0e4d11141f299 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_auth_decorator.cc +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_auth_decorator.cc @@ -136,6 +136,49 @@ DataprocMetastoreFederationAuth::DeleteFederation( return child_->DeleteFederation(context, options, request); } +StatusOr +DataprocMetastoreFederationAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +DataprocMetastoreFederationAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr DataprocMetastoreFederationAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr DataprocMetastoreFederationAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +DataprocMetastoreFederationAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> DataprocMetastoreFederationAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_auth_decorator.h b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_auth_decorator.h index fb6b31c966858..d08feff18eaca 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_auth_decorator.h +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_auth_decorator.h @@ -85,6 +85,26 @@ class DataprocMetastoreFederationAuth : public DataprocMetastoreFederationStub { google::cloud::metastore::v1::DeleteFederationRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_connection_impl.cc b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_connection_impl.cc index ec1515034f75a..f87709d3f48dc 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_connection_impl.cc +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_connection_impl.cc @@ -404,6 +404,97 @@ DataprocMetastoreFederationConnectionImpl::DeleteFederation( polling_policy(*current), __func__); } +StreamRange +DataprocMetastoreFederationConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr< + metastore_v1::DataprocMetastoreFederationRetryPolicy>( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DataprocMetastoreFederationConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +DataprocMetastoreFederationConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +DataprocMetastoreFederationConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +DataprocMetastoreFederationConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace metastore_v1_internal } // namespace cloud diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_connection_impl.h b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_connection_impl.h index afb87f7451318..366c0bd3a1e92 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_connection_impl.h +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_connection_impl.h @@ -96,6 +96,21 @@ class DataprocMetastoreFederationConnectionImpl future> DeleteFederation(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_logging_decorator.cc b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_logging_decorator.cc index 4d13fdb8c8369..3ea0fa75036d6 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_logging_decorator.cc +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_logging_decorator.cc @@ -157,6 +157,66 @@ DataprocMetastoreFederationLogging::DeleteFederation( context, options, request, __func__, tracing_options_); } +StatusOr +DataprocMetastoreFederationLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataprocMetastoreFederationLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataprocMetastoreFederationLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataprocMetastoreFederationLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataprocMetastoreFederationLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> DataprocMetastoreFederationLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_logging_decorator.h b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_logging_decorator.h index 242b25f655452..98fc030d6c076 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_logging_decorator.h +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_logging_decorator.h @@ -86,6 +86,26 @@ class DataprocMetastoreFederationLogging google::cloud::metastore::v1::DeleteFederationRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_metadata_decorator.cc b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_metadata_decorator.cc index e5d9049c36f17..229b072601628 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_metadata_decorator.cc +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_metadata_decorator.cc @@ -127,6 +127,54 @@ DataprocMetastoreFederationMetadata::DeleteFederation( return child_->DeleteFederation(context, options, request); } +StatusOr +DataprocMetastoreFederationMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +DataprocMetastoreFederationMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr +DataprocMetastoreFederationMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr +DataprocMetastoreFederationMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +DataprocMetastoreFederationMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> DataprocMetastoreFederationMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_metadata_decorator.h b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_metadata_decorator.h index 5a8a1d787a999..483c89f44c289 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_metadata_decorator.h +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_metadata_decorator.h @@ -87,6 +87,26 @@ class DataprocMetastoreFederationMetadata google::cloud::metastore::v1::DeleteFederationRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_stub.cc b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_stub.cc index 58fd92850c961..03a8788e967b1 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_stub.cc +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_stub.cc @@ -148,6 +148,67 @@ DefaultDataprocMetastoreFederationStub::DeleteFederation( return response; } +StatusOr +DefaultDataprocMetastoreFederationStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataprocMetastoreFederationStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataprocMetastoreFederationStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataprocMetastoreFederationStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataprocMetastoreFederationStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultDataprocMetastoreFederationStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_stub.h b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_stub.h index 2eaf53e657c93..81af1b46aad18 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_stub.h +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_stub.h @@ -24,7 +24,11 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include +#include +#include #include #include #include @@ -80,6 +84,28 @@ class DataprocMetastoreFederationStub { grpc::ClientContext& context, Options options, google::cloud::metastore::v1::DeleteFederationRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -100,9 +126,15 @@ class DefaultDataprocMetastoreFederationStub std::unique_ptr grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListFederations(grpc::ClientContext& context, Options const& options, @@ -150,6 +182,26 @@ class DefaultDataprocMetastoreFederationStub google::cloud::metastore::v1::DeleteFederationRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -166,6 +218,9 @@ class DefaultDataprocMetastoreFederationStub std::unique_ptr< google::cloud::metastore::v1::DataprocMetastoreFederation::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_stub_factory.cc b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_stub_factory.cc index 3a8210980a014..632efcb75a7bc 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_stub_factory.cc +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_stub_factory.cc @@ -28,7 +28,9 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include #include #include @@ -46,9 +48,13 @@ CreateDefaultDataprocMetastoreFederationStub( auto service_grpc_stub = google::cloud::metastore::v1::DataprocMetastoreFederation::NewStub( channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_tracing_connection.cc b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_tracing_connection.cc index cd734d67a665e..8c041b078b6fd 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_tracing_connection.cc +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_tracing_connection.cc @@ -145,6 +145,54 @@ DataprocMetastoreFederationTracingConnection::DeleteFederation( child_->DeleteFederation(operation)); } +StreamRange +DataprocMetastoreFederationTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "metastore_v1::DataprocMetastoreFederationConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DataprocMetastoreFederationTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "metastore_v1::DataprocMetastoreFederationConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +DataprocMetastoreFederationTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "metastore_v1::DataprocMetastoreFederationConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +DataprocMetastoreFederationTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "metastore_v1::DataprocMetastoreFederationConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +DataprocMetastoreFederationTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "metastore_v1::DataprocMetastoreFederationConnection::" + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_tracing_connection.h b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_tracing_connection.h index bb2d97d973c3d..cb6ee8202a757 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_tracing_connection.h +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_tracing_connection.h @@ -84,6 +84,21 @@ class DataprocMetastoreFederationTracingConnection future> DeleteFederation(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_tracing_stub.cc b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_tracing_stub.cc index 138442c6f4c41..ac21c338f219e 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_tracing_stub.cc +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_tracing_stub.cc @@ -144,6 +144,67 @@ DataprocMetastoreFederationTracingStub::DeleteFederation( child_->DeleteFederation(context, options, request)); } +StatusOr +DataprocMetastoreFederationTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.metastore.v1.DataprocMetastoreFederation", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +DataprocMetastoreFederationTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.metastore.v1.DataprocMetastoreFederation", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr +DataprocMetastoreFederationTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.metastore.v1.DataprocMetastoreFederation", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr +DataprocMetastoreFederationTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.metastore.v1.DataprocMetastoreFederation", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +DataprocMetastoreFederationTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.metastore.v1.DataprocMetastoreFederation", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> DataprocMetastoreFederationTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_tracing_stub.h b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_tracing_stub.h index a94455687a9f3..50c11a68fb5cd 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_federation_tracing_stub.h +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_federation_tracing_stub.h @@ -86,6 +86,26 @@ class DataprocMetastoreFederationTracingStub google::cloud::metastore::v1::DeleteFederationRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_logging_decorator.cc b/google/cloud/metastore/v1/internal/dataproc_metastore_logging_decorator.cc index d525ce892588c..2827f2b587789 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_logging_decorator.cc +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_logging_decorator.cc @@ -489,6 +489,64 @@ DataprocMetastoreLogging::AlterMetadataResourceLocation( context, options, request, __func__, tracing_options_); } +StatusOr +DataprocMetastoreLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataprocMetastoreLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DataprocMetastoreLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DataprocMetastoreLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DataprocMetastoreLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> DataprocMetastoreLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_logging_decorator.h b/google/cloud/metastore/v1/internal/dataproc_metastore_logging_decorator.h index 444644c845f0c..d83ebde2c3120 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_logging_decorator.h +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_logging_decorator.h @@ -212,6 +212,26 @@ class DataprocMetastoreLogging : public DataprocMetastoreStub { google::cloud::metastore::v1::AlterMetadataResourceLocationRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_metadata_decorator.cc b/google/cloud/metastore/v1/internal/dataproc_metastore_metadata_decorator.cc index 146ea250309ee..f2bebe563a59e 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_metadata_decorator.cc +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_metadata_decorator.cc @@ -358,6 +358,52 @@ DataprocMetastoreMetadata::AlterMetadataResourceLocation( return child_->AlterMetadataResourceLocation(context, options, request); } +StatusOr +DataprocMetastoreMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +DataprocMetastoreMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr DataprocMetastoreMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr DataprocMetastoreMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +DataprocMetastoreMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> DataprocMetastoreMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_metadata_decorator.h b/google/cloud/metastore/v1/internal/dataproc_metastore_metadata_decorator.h index f10397c33a727..656b12a322f6e 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_metadata_decorator.h +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_metadata_decorator.h @@ -213,6 +213,26 @@ class DataprocMetastoreMetadata : public DataprocMetastoreStub { google::cloud::metastore::v1::AlterMetadataResourceLocationRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_stub.cc b/google/cloud/metastore/v1/internal/dataproc_metastore_stub.cc index 6aa25cbb6383b..533fd2dd1c551 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_stub.cc +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_stub.cc @@ -471,6 +471,65 @@ DefaultDataprocMetastoreStub::AlterMetadataResourceLocation( return response; } +StatusOr +DefaultDataprocMetastoreStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataprocMetastoreStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultDataprocMetastoreStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultDataprocMetastoreStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDataprocMetastoreStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultDataprocMetastoreStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_stub.h b/google/cloud/metastore/v1/internal/dataproc_metastore_stub.h index 5e66be5585bb0..edf7062b41a4b 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_stub.h +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_stub.h @@ -24,7 +24,11 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include +#include +#include #include #include #include @@ -201,6 +205,28 @@ class DataprocMetastoreStub { google::cloud::metastore::v1::AlterMetadataResourceLocationRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -220,9 +246,15 @@ class DefaultDataprocMetastoreStub : public DataprocMetastoreStub { std::unique_ptr< google::cloud::metastore::v1::DataprocMetastore::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListServices( grpc::ClientContext& context, Options const& options, @@ -397,6 +429,26 @@ class DefaultDataprocMetastoreStub : public DataprocMetastoreStub { google::cloud::metastore::v1::AlterMetadataResourceLocationRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -413,6 +465,9 @@ class DefaultDataprocMetastoreStub : public DataprocMetastoreStub { std::unique_ptr< google::cloud::metastore::v1::DataprocMetastore::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_stub_factory.cc b/google/cloud/metastore/v1/internal/dataproc_metastore_stub_factory.cc index cd45122484034..1f5e0a3294dcc 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_stub_factory.cc +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_stub_factory.cc @@ -28,7 +28,9 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultDataprocMetastoreStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::metastore::v1::DataprocMetastore::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_tracing_connection.cc b/google/cloud/metastore/v1/internal/dataproc_metastore_tracing_connection.cc index e1fbee2c69d24..0087411b6a424 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_tracing_connection.cc +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_tracing_connection.cc @@ -451,6 +451,53 @@ DataprocMetastoreTracingConnection::AlterMetadataResourceLocation( child_->AlterMetadataResourceLocation(operation)); } +StreamRange +DataprocMetastoreTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "metastore_v1::DataprocMetastoreConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DataprocMetastoreTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "metastore_v1::DataprocMetastoreConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +DataprocMetastoreTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "metastore_v1::DataprocMetastoreConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +DataprocMetastoreTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "metastore_v1::DataprocMetastoreConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +DataprocMetastoreTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "metastore_v1::DataprocMetastoreConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_tracing_connection.h b/google/cloud/metastore/v1/internal/dataproc_metastore_tracing_connection.h index b576c4d502d7e..4b81e42d767c1 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_tracing_connection.h +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_tracing_connection.h @@ -213,6 +213,21 @@ class DataprocMetastoreTracingConnection AlterMetadataResourceLocation( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_tracing_stub.cc b/google/cloud/metastore/v1/internal/dataproc_metastore_tracing_stub.cc index 8e0624b9d3de6..21f3541ef5cbe 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_tracing_stub.cc +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_tracing_stub.cc @@ -427,6 +427,64 @@ DataprocMetastoreTracingStub::AlterMetadataResourceLocation( child_->AlterMetadataResourceLocation(context, options, request)); } +StatusOr +DataprocMetastoreTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.metastore.v1.DataprocMetastore", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +DataprocMetastoreTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.metastore.v1.DataprocMetastore", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr DataprocMetastoreTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.metastore.v1.DataprocMetastore", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr DataprocMetastoreTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.metastore.v1.DataprocMetastore", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +DataprocMetastoreTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.metastore.v1.DataprocMetastore", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> DataprocMetastoreTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/metastore/v1/internal/dataproc_metastore_tracing_stub.h b/google/cloud/metastore/v1/internal/dataproc_metastore_tracing_stub.h index 279f1684a0c4b..d2455953812bc 100644 --- a/google/cloud/metastore/v1/internal/dataproc_metastore_tracing_stub.h +++ b/google/cloud/metastore/v1/internal/dataproc_metastore_tracing_stub.h @@ -212,6 +212,26 @@ class DataprocMetastoreTracingStub : public DataprocMetastoreStub { google::cloud::metastore::v1::AlterMetadataResourceLocationRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/metastore/v1/mocks/mock_dataproc_metastore_connection.h b/google/cloud/metastore/v1/mocks/mock_dataproc_metastore_connection.h index 347fa58a63b9e..331bd78c39c0d 100644 --- a/google/cloud/metastore/v1/mocks/mock_dataproc_metastore_connection.h +++ b/google/cloud/metastore/v1/mocks/mock_dataproc_metastore_connection.h @@ -548,6 +548,27 @@ class MockDataprocMetastoreConnection google::cloud::metastore::v1::AlterMetadataResourceLocationResponse>>, AlterMetadataResourceLocation, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/metastore/v1/mocks/mock_dataproc_metastore_federation_connection.h b/google/cloud/metastore/v1/mocks/mock_dataproc_metastore_federation_connection.h index 6c8a0e440e928..426a262637686 100644 --- a/google/cloud/metastore/v1/mocks/mock_dataproc_metastore_federation_connection.h +++ b/google/cloud/metastore/v1/mocks/mock_dataproc_metastore_federation_connection.h @@ -173,6 +173,27 @@ class MockDataprocMetastoreFederationConnection MOCK_METHOD(future>, DeleteFederation, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/migrationcenter/BUILD.bazel b/google/cloud/migrationcenter/BUILD.bazel index ad51f70663581..4555a48eb1191 100644 --- a/google/cloud/migrationcenter/BUILD.bazel +++ b/google/cloud/migrationcenter/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/migrationcenter/v1:migrationcenter_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/migrationcenter/v1/internal/migration_center_auth_decorator.cc b/google/cloud/migrationcenter/v1/internal/migration_center_auth_decorator.cc index 7028d3bc692bf..971214629a9d7 100644 --- a/google/cloud/migrationcenter/v1/internal/migration_center_auth_decorator.cc +++ b/google/cloud/migrationcenter/v1/internal/migration_center_auth_decorator.cc @@ -935,6 +935,23 @@ StatusOr MigrationCenterAuth::DeleteReport( return child_->DeleteReport(context, options, request); } +StatusOr +MigrationCenterAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr MigrationCenterAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> MigrationCenterAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/migrationcenter/v1/internal/migration_center_auth_decorator.h b/google/cloud/migrationcenter/v1/internal/migration_center_auth_decorator.h index bfda49a72e990..e5677083248fc 100644 --- a/google/cloud/migrationcenter/v1/internal/migration_center_auth_decorator.h +++ b/google/cloud/migrationcenter/v1/internal/migration_center_auth_decorator.h @@ -449,6 +449,14 @@ class MigrationCenterAuth : public MigrationCenterStub { google::cloud::migrationcenter::v1::DeleteReportRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/migrationcenter/v1/internal/migration_center_connection_impl.cc b/google/cloud/migrationcenter/v1/internal/migration_center_connection_impl.cc index 8d5724ed5d8dd..b9d6532518882 100644 --- a/google/cloud/migrationcenter/v1/internal/migration_center_connection_impl.cc +++ b/google/cloud/migrationcenter/v1/internal/migration_center_connection_impl.cc @@ -2810,6 +2810,54 @@ MigrationCenterConnectionImpl::DeleteReport( polling_policy(*current), __func__); } +StreamRange +MigrationCenterConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +MigrationCenterConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace migrationcenter_v1_internal } // namespace cloud diff --git a/google/cloud/migrationcenter/v1/internal/migration_center_connection_impl.h b/google/cloud/migrationcenter/v1/internal/migration_center_connection_impl.h index dc4f17b2a7c12..d25921992eb5a 100644 --- a/google/cloud/migrationcenter/v1/internal/migration_center_connection_impl.h +++ b/google/cloud/migrationcenter/v1/internal/migration_center_connection_impl.h @@ -445,6 +445,12 @@ class MigrationCenterConnectionImpl future> DeleteReport(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/migrationcenter/v1/internal/migration_center_logging_decorator.cc b/google/cloud/migrationcenter/v1/internal/migration_center_logging_decorator.cc index 907051c5b4c14..f35b4df76a6ab 100644 --- a/google/cloud/migrationcenter/v1/internal/migration_center_logging_decorator.cc +++ b/google/cloud/migrationcenter/v1/internal/migration_center_logging_decorator.cc @@ -1129,6 +1129,29 @@ StatusOr MigrationCenterLogging::DeleteReport( context, options, request, __func__, tracing_options_); } +StatusOr +MigrationCenterLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr MigrationCenterLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> MigrationCenterLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/migrationcenter/v1/internal/migration_center_logging_decorator.h b/google/cloud/migrationcenter/v1/internal/migration_center_logging_decorator.h index d82184df89fb0..28b7d551ba34c 100644 --- a/google/cloud/migrationcenter/v1/internal/migration_center_logging_decorator.h +++ b/google/cloud/migrationcenter/v1/internal/migration_center_logging_decorator.h @@ -449,6 +449,14 @@ class MigrationCenterLogging : public MigrationCenterStub { google::cloud::migrationcenter::v1::DeleteReportRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/migrationcenter/v1/internal/migration_center_metadata_decorator.cc b/google/cloud/migrationcenter/v1/internal/migration_center_metadata_decorator.cc index df67e117a4ed9..1f3b61dbeba0d 100644 --- a/google/cloud/migrationcenter/v1/internal/migration_center_metadata_decorator.cc +++ b/google/cloud/migrationcenter/v1/internal/migration_center_metadata_decorator.cc @@ -783,6 +783,24 @@ StatusOr MigrationCenterMetadata::DeleteReport( return child_->DeleteReport(context, options, request); } +StatusOr +MigrationCenterMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +MigrationCenterMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> MigrationCenterMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/migrationcenter/v1/internal/migration_center_metadata_decorator.h b/google/cloud/migrationcenter/v1/internal/migration_center_metadata_decorator.h index 98c0ea31d4e01..0bda5ec5d96a7 100644 --- a/google/cloud/migrationcenter/v1/internal/migration_center_metadata_decorator.h +++ b/google/cloud/migrationcenter/v1/internal/migration_center_metadata_decorator.h @@ -450,6 +450,14 @@ class MigrationCenterMetadata : public MigrationCenterStub { google::cloud::migrationcenter::v1::DeleteReportRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/migrationcenter/v1/internal/migration_center_stub.cc b/google/cloud/migrationcenter/v1/internal/migration_center_stub.cc index 93df85c89bcb0..986b01d27d4b2 100644 --- a/google/cloud/migrationcenter/v1/internal/migration_center_stub.cc +++ b/google/cloud/migrationcenter/v1/internal/migration_center_stub.cc @@ -1078,6 +1078,30 @@ DefaultMigrationCenterStub::DeleteReport( return response; } +StatusOr +DefaultMigrationCenterStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultMigrationCenterStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultMigrationCenterStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/migrationcenter/v1/internal/migration_center_stub.h b/google/cloud/migrationcenter/v1/internal/migration_center_stub.h index f408b5a9c6877..7569e47feaf99 100644 --- a/google/cloud/migrationcenter/v1/internal/migration_center_stub.h +++ b/google/cloud/migrationcenter/v1/internal/migration_center_stub.h @@ -24,6 +24,8 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include #include @@ -462,6 +464,15 @@ class MigrationCenterStub { google::cloud::migrationcenter::v1::DeleteReportRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -481,9 +492,13 @@ class DefaultMigrationCenterStub : public MigrationCenterStub { std::unique_ptr< google::cloud::migrationcenter::v1::MigrationCenter::StubInterface> grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListAssets( grpc::ClientContext& context, Options const& options, @@ -895,6 +910,14 @@ class DefaultMigrationCenterStub : public MigrationCenterStub { google::cloud::migrationcenter::v1::DeleteReportRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -911,6 +934,8 @@ class DefaultMigrationCenterStub : public MigrationCenterStub { std::unique_ptr< google::cloud::migrationcenter::v1::MigrationCenter::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/migrationcenter/v1/internal/migration_center_stub_factory.cc b/google/cloud/migrationcenter/v1/internal/migration_center_stub_factory.cc index fac8e6148b330..c6e7fb063248c 100644 --- a/google/cloud/migrationcenter/v1/internal/migration_center_stub_factory.cc +++ b/google/cloud/migrationcenter/v1/internal/migration_center_stub_factory.cc @@ -28,6 +28,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultMigrationCenterStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::migrationcenter::v1::MigrationCenter::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/migrationcenter/v1/internal/migration_center_tracing_connection.cc b/google/cloud/migrationcenter/v1/internal/migration_center_tracing_connection.cc index 62fdbd45ac02e..8c1074559ab7b 100644 --- a/google/cloud/migrationcenter/v1/internal/migration_center_tracing_connection.cc +++ b/google/cloud/migrationcenter/v1/internal/migration_center_tracing_connection.cc @@ -985,6 +985,26 @@ MigrationCenterTracingConnection::DeleteReport( return internal::EndSpan(std::move(span), child_->DeleteReport(operation)); } +StreamRange +MigrationCenterTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "migrationcenter_v1::MigrationCenterConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +MigrationCenterTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "migrationcenter_v1::MigrationCenterConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/migrationcenter/v1/internal/migration_center_tracing_connection.h b/google/cloud/migrationcenter/v1/internal/migration_center_tracing_connection.h index 508d72fa71c8b..a814fc61e0c62 100644 --- a/google/cloud/migrationcenter/v1/internal/migration_center_tracing_connection.h +++ b/google/cloud/migrationcenter/v1/internal/migration_center_tracing_connection.h @@ -433,6 +433,12 @@ class MigrationCenterTracingConnection future> DeleteReport(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/migrationcenter/v1/internal/migration_center_tracing_stub.cc b/google/cloud/migrationcenter/v1/internal/migration_center_tracing_stub.cc index eff12109d3562..79b512fb1a5a5 100644 --- a/google/cloud/migrationcenter/v1/internal/migration_center_tracing_stub.cc +++ b/google/cloud/migrationcenter/v1/internal/migration_center_tracing_stub.cc @@ -978,6 +978,30 @@ MigrationCenterTracingStub::DeleteReport( child_->DeleteReport(context, options, request)); } +StatusOr +MigrationCenterTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.migrationcenter.v1.MigrationCenter", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +MigrationCenterTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.migrationcenter.v1.MigrationCenter", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> MigrationCenterTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/migrationcenter/v1/internal/migration_center_tracing_stub.h b/google/cloud/migrationcenter/v1/internal/migration_center_tracing_stub.h index 1ad3d1f4e6c09..b9348be4eb88b 100644 --- a/google/cloud/migrationcenter/v1/internal/migration_center_tracing_stub.h +++ b/google/cloud/migrationcenter/v1/internal/migration_center_tracing_stub.h @@ -449,6 +449,14 @@ class MigrationCenterTracingStub : public MigrationCenterStub { google::cloud::migrationcenter::v1::DeleteReportRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/migrationcenter/v1/migration_center_client.cc b/google/cloud/migrationcenter/v1/migration_center_client.cc index 83db6bdd1df95..696ee42e932b7 100644 --- a/google/cloud/migrationcenter/v1/migration_center_client.cc +++ b/google/cloud/migrationcenter/v1/migration_center_client.cc @@ -1459,6 +1459,19 @@ MigrationCenterClient::DeleteReport( return connection_->DeleteReport(operation); } +StreamRange +MigrationCenterClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr MigrationCenterClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace migrationcenter_v1 } // namespace cloud diff --git a/google/cloud/migrationcenter/v1/migration_center_client.h b/google/cloud/migrationcenter/v1/migration_center_client.h index 25824de2d1b3e..0a6da5f5be633 100644 --- a/google/cloud/migrationcenter/v1/migration_center_client.h +++ b/google/cloud/migrationcenter/v1/migration_center_client.h @@ -4363,6 +4363,76 @@ class MigrationCenterClient { DeleteReport(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/migrationcenter/v1/migration_center_connection.cc b/google/cloud/migrationcenter/v1/migration_center_connection.cc index 0368b54bb5915..da84f04cf8390 100644 --- a/google/cloud/migrationcenter/v1/migration_center_connection.cc +++ b/google/cloud/migrationcenter/v1/migration_center_connection.cc @@ -741,6 +741,20 @@ MigrationCenterConnection::DeleteReport(google::longrunning::Operation const&) { Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +MigrationCenterConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +MigrationCenterConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeMigrationCenterConnection( Options options) { internal::CheckExpectedOptions #include #include #include @@ -580,6 +581,12 @@ class MigrationCenterConnection { virtual future< StatusOr> DeleteReport(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/migrationcenter/v1/migration_center_connection_idempotency_policy.cc b/google/cloud/migrationcenter/v1/migration_center_connection_idempotency_policy.cc index 29d7385659714..5c37e0298bf2b 100644 --- a/google/cloud/migrationcenter/v1/migration_center_connection_idempotency_policy.cc +++ b/google/cloud/migrationcenter/v1/migration_center_connection_idempotency_policy.cc @@ -274,6 +274,16 @@ Idempotency MigrationCenterConnectionIdempotencyPolicy::DeleteReport( return Idempotency::kNonIdempotent; } +Idempotency MigrationCenterConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency MigrationCenterConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultMigrationCenterConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/migrationcenter/v1/migration_center_connection_idempotency_policy.h b/google/cloud/migrationcenter/v1/migration_center_connection_idempotency_policy.h index b3f68f8284600..aa77190bed652 100644 --- a/google/cloud/migrationcenter/v1/migration_center_connection_idempotency_policy.h +++ b/google/cloud/migrationcenter/v1/migration_center_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -200,6 +201,12 @@ class MigrationCenterConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteReport( google::cloud::migrationcenter::v1::DeleteReportRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/migrationcenter/v1/mocks/mock_migration_center_connection.h b/google/cloud/migrationcenter/v1/mocks/mock_migration_center_connection.h index 51b4140abed47..a30c8922489a4 100644 --- a/google/cloud/migrationcenter/v1/mocks/mock_migration_center_connection.h +++ b/google/cloud/migrationcenter/v1/mocks/mock_migration_center_connection.h @@ -1118,6 +1118,14 @@ class MockMigrationCenterConnection future>, DeleteReport, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/netapp/BUILD.bazel b/google/cloud/netapp/BUILD.bazel index a56322706ac90..654466578d1ab 100644 --- a/google/cloud/netapp/BUILD.bazel +++ b/google/cloud/netapp/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/netapp/v1:netapp_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/netapp/v1/internal/net_app_auth_decorator.cc b/google/cloud/netapp/v1/internal/net_app_auth_decorator.cc index 88218932a0862..c506a0a415aba 100644 --- a/google/cloud/netapp/v1/internal/net_app_auth_decorator.cc +++ b/google/cloud/netapp/v1/internal/net_app_auth_decorator.cc @@ -1086,6 +1086,23 @@ StatusOr NetAppAuth::DeleteBackupPolicy( return child_->DeleteBackupPolicy(context, options, request); } +StatusOr +NetAppAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr NetAppAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> NetAppAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/netapp/v1/internal/net_app_auth_decorator.h b/google/cloud/netapp/v1/internal/net_app_auth_decorator.h index 8cc0204044634..f78e60ab88430 100644 --- a/google/cloud/netapp/v1/internal/net_app_auth_decorator.h +++ b/google/cloud/netapp/v1/internal/net_app_auth_decorator.h @@ -487,6 +487,14 @@ class NetAppAuth : public NetAppStub { google::cloud::netapp::v1::DeleteBackupPolicyRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/netapp/v1/internal/net_app_connection_impl.cc b/google/cloud/netapp/v1/internal/net_app_connection_impl.cc index 2a92ac3ed1cf6..b1423082140de 100644 --- a/google/cloud/netapp/v1/internal/net_app_connection_impl.cc +++ b/google/cloud/netapp/v1/internal/net_app_connection_impl.cc @@ -3401,6 +3401,53 @@ NetAppConnectionImpl::DeleteBackupPolicy( polling_policy(*current), __func__); } +StreamRange +NetAppConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr NetAppConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace netapp_v1_internal } // namespace cloud diff --git a/google/cloud/netapp/v1/internal/net_app_connection_impl.h b/google/cloud/netapp/v1/internal/net_app_connection_impl.h index 31b4960e3f7fd..8770360b9a66a 100644 --- a/google/cloud/netapp/v1/internal/net_app_connection_impl.h +++ b/google/cloud/netapp/v1/internal/net_app_connection_impl.h @@ -480,6 +480,12 @@ class NetAppConnectionImpl : public netapp_v1::NetAppConnection { future> DeleteBackupPolicy(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/netapp/v1/internal/net_app_logging_decorator.cc b/google/cloud/netapp/v1/internal/net_app_logging_decorator.cc index 79d2c3fc7fb55..322cb4248f9fd 100644 --- a/google/cloud/netapp/v1/internal/net_app_logging_decorator.cc +++ b/google/cloud/netapp/v1/internal/net_app_logging_decorator.cc @@ -1229,6 +1229,29 @@ StatusOr NetAppLogging::DeleteBackupPolicy( context, options, request, __func__, tracing_options_); } +StatusOr +NetAppLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr NetAppLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> NetAppLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/netapp/v1/internal/net_app_logging_decorator.h b/google/cloud/netapp/v1/internal/net_app_logging_decorator.h index 81f842c41a28f..fbb908ce1d249 100644 --- a/google/cloud/netapp/v1/internal/net_app_logging_decorator.h +++ b/google/cloud/netapp/v1/internal/net_app_logging_decorator.h @@ -487,6 +487,14 @@ class NetAppLogging : public NetAppStub { google::cloud::netapp::v1::DeleteBackupPolicyRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/netapp/v1/internal/net_app_metadata_decorator.cc b/google/cloud/netapp/v1/internal/net_app_metadata_decorator.cc index c758d21902580..892a013a73230 100644 --- a/google/cloud/netapp/v1/internal/net_app_metadata_decorator.cc +++ b/google/cloud/netapp/v1/internal/net_app_metadata_decorator.cc @@ -873,6 +873,23 @@ StatusOr NetAppMetadata::DeleteBackupPolicy( return child_->DeleteBackupPolicy(context, options, request); } +StatusOr +NetAppMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr NetAppMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> NetAppMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/netapp/v1/internal/net_app_metadata_decorator.h b/google/cloud/netapp/v1/internal/net_app_metadata_decorator.h index 0647692939a01..72291df8e7f7b 100644 --- a/google/cloud/netapp/v1/internal/net_app_metadata_decorator.h +++ b/google/cloud/netapp/v1/internal/net_app_metadata_decorator.h @@ -487,6 +487,14 @@ class NetAppMetadata : public NetAppStub { google::cloud::netapp::v1::DeleteBackupPolicyRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/netapp/v1/internal/net_app_stub.cc b/google/cloud/netapp/v1/internal/net_app_stub.cc index 86e2eb6c3bd9c..cb9900db3b9d7 100644 --- a/google/cloud/netapp/v1/internal/net_app_stub.cc +++ b/google/cloud/netapp/v1/internal/net_app_stub.cc @@ -1199,6 +1199,29 @@ StatusOr DefaultNetAppStub::DeleteBackupPolicy( return response; } +StatusOr +DefaultNetAppStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultNetAppStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultNetAppStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/netapp/v1/internal/net_app_stub.h b/google/cloud/netapp/v1/internal/net_app_stub.h index 73884a6f994dc..496fad2a4e994 100644 --- a/google/cloud/netapp/v1/internal/net_app_stub.h +++ b/google/cloud/netapp/v1/internal/net_app_stub.h @@ -24,6 +24,8 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include #include @@ -469,6 +471,15 @@ class NetAppStub { grpc::ClientContext& context, Options options, google::cloud::netapp::v1::DeleteBackupPolicyRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -487,9 +498,13 @@ class DefaultNetAppStub : public NetAppStub { DefaultNetAppStub( std::unique_ptr grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListStoragePools(grpc::ClientContext& context, Options const& options, @@ -939,6 +954,14 @@ class DefaultNetAppStub : public NetAppStub { google::cloud::netapp::v1::DeleteBackupPolicyRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -953,6 +976,8 @@ class DefaultNetAppStub : public NetAppStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/netapp/v1/internal/net_app_stub_factory.cc b/google/cloud/netapp/v1/internal/net_app_stub_factory.cc index a92f9edbd3651..133c0cd40c57c 100644 --- a/google/cloud/netapp/v1/internal/net_app_stub_factory.cc +++ b/google/cloud/netapp/v1/internal/net_app_stub_factory.cc @@ -28,6 +28,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -43,8 +44,10 @@ std::shared_ptr CreateDefaultNetAppStub( auto channel = auth->CreateChannel(options.get(), internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::netapp::v1::NetApp::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/netapp/v1/internal/net_app_tracing_connection.cc b/google/cloud/netapp/v1/internal/net_app_tracing_connection.cc index 64e10f1c14310..29d7c0fe1bab2 100644 --- a/google/cloud/netapp/v1/internal/net_app_tracing_connection.cc +++ b/google/cloud/netapp/v1/internal/net_app_tracing_connection.cc @@ -1110,6 +1110,24 @@ NetAppTracingConnection::DeleteBackupPolicy( child_->DeleteBackupPolicy(operation)); } +StreamRange +NetAppTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan("netapp_v1::NetAppConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +NetAppTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan("netapp_v1::NetAppConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeNetAppTracingConnection( diff --git a/google/cloud/netapp/v1/internal/net_app_tracing_connection.h b/google/cloud/netapp/v1/internal/net_app_tracing_connection.h index 618eee0822d6b..612fe8e8a73bd 100644 --- a/google/cloud/netapp/v1/internal/net_app_tracing_connection.h +++ b/google/cloud/netapp/v1/internal/net_app_tracing_connection.h @@ -469,6 +469,12 @@ class NetAppTracingConnection : public netapp_v1::NetAppConnection { future> DeleteBackupPolicy(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/netapp/v1/internal/net_app_tracing_stub.cc b/google/cloud/netapp/v1/internal/net_app_tracing_stub.cc index 1e548745374b6..542f5dce55164 100644 --- a/google/cloud/netapp/v1/internal/net_app_tracing_stub.cc +++ b/google/cloud/netapp/v1/internal/net_app_tracing_stub.cc @@ -1087,6 +1087,29 @@ StatusOr NetAppTracingStub::DeleteBackupPolicy( context, *span, child_->DeleteBackupPolicy(context, options, request)); } +StatusOr +NetAppTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.netapp.v1.NetApp", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr NetAppTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.netapp.v1.NetApp", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> NetAppTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/netapp/v1/internal/net_app_tracing_stub.h b/google/cloud/netapp/v1/internal/net_app_tracing_stub.h index 40c47316f87d9..14b7a6a5b91f8 100644 --- a/google/cloud/netapp/v1/internal/net_app_tracing_stub.h +++ b/google/cloud/netapp/v1/internal/net_app_tracing_stub.h @@ -486,6 +486,14 @@ class NetAppTracingStub : public NetAppStub { google::cloud::netapp::v1::DeleteBackupPolicyRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/netapp/v1/mocks/mock_net_app_connection.h b/google/cloud/netapp/v1/mocks/mock_net_app_connection.h index f93896f3e765c..599d198fa7efd 100644 --- a/google/cloud/netapp/v1/mocks/mock_net_app_connection.h +++ b/google/cloud/netapp/v1/mocks/mock_net_app_connection.h @@ -1347,6 +1347,14 @@ class MockNetAppConnection : public netapp_v1::NetAppConnection { MOCK_METHOD(future>, DeleteBackupPolicy, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/netapp/v1/net_app_client.cc b/google/cloud/netapp/v1/net_app_client.cc index 5be9fb9d17058..53cb227f341e0 100644 --- a/google/cloud/netapp/v1/net_app_client.cc +++ b/google/cloud/netapp/v1/net_app_client.cc @@ -1578,6 +1578,18 @@ NetAppClient::DeleteBackupPolicy( return connection_->DeleteBackupPolicy(operation); } +StreamRange NetAppClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr NetAppClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace netapp_v1 } // namespace cloud diff --git a/google/cloud/netapp/v1/net_app_client.h b/google/cloud/netapp/v1/net_app_client.h index 2fda9118a0c78..89317f7ac5549 100644 --- a/google/cloud/netapp/v1/net_app_client.h +++ b/google/cloud/netapp/v1/net_app_client.h @@ -4839,6 +4839,76 @@ class NetAppClient { DeleteBackupPolicy(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/netapp/v1/net_app_connection.cc b/google/cloud/netapp/v1/net_app_connection.cc index 591575ddac762..83512f2aa1cca 100644 --- a/google/cloud/netapp/v1/net_app_connection.cc +++ b/google/cloud/netapp/v1/net_app_connection.cc @@ -845,6 +845,18 @@ NetAppConnection::DeleteBackupPolicy(google::longrunning::Operation const&) { Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange NetAppConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr NetAppConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeNetAppConnection(Options options) { internal::CheckExpectedOptions #include #include #include @@ -586,6 +587,12 @@ class NetAppConnection { virtual future> DeleteBackupPolicy(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/netapp/v1/net_app_connection_idempotency_policy.cc b/google/cloud/netapp/v1/net_app_connection_idempotency_policy.cc index 7c26c29f11a82..99c101f082648 100644 --- a/google/cloud/netapp/v1/net_app_connection_idempotency_policy.cc +++ b/google/cloud/netapp/v1/net_app_connection_idempotency_policy.cc @@ -289,6 +289,16 @@ Idempotency NetAppConnectionIdempotencyPolicy::DeleteBackupPolicy( return Idempotency::kNonIdempotent; } +Idempotency NetAppConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency NetAppConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultNetAppConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/netapp/v1/net_app_connection_idempotency_policy.h b/google/cloud/netapp/v1/net_app_connection_idempotency_policy.h index f357b3e7442d1..ad4d64c7290bb 100644 --- a/google/cloud/netapp/v1/net_app_connection_idempotency_policy.h +++ b/google/cloud/netapp/v1/net_app_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -189,6 +190,12 @@ class NetAppConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteBackupPolicy( google::cloud::netapp::v1::DeleteBackupPolicyRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/networkconnectivity/BUILD.bazel b/google/cloud/networkconnectivity/BUILD.bazel index b00c4d9762a5d..16fcf08290dc0 100644 --- a/google/cloud/networkconnectivity/BUILD.bazel +++ b/google/cloud/networkconnectivity/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/networkconnectivity/v1:networkconnectivity_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/networkconnectivity/v1/hub_client.cc b/google/cloud/networkconnectivity/v1/hub_client.cc index 531a2985acf89..5e17242f3b63a 100644 --- a/google/cloud/networkconnectivity/v1/hub_client.cc +++ b/google/cloud/networkconnectivity/v1/hub_client.cc @@ -559,6 +559,37 @@ HubServiceClient::ListGroups( return connection_->ListGroups(std::move(request)); } +StreamRange HubServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr HubServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr HubServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr HubServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +HubServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace networkconnectivity_v1 } // namespace cloud diff --git a/google/cloud/networkconnectivity/v1/hub_client.h b/google/cloud/networkconnectivity/v1/hub_client.h index cbecf2f80d71e..3f7274f40e63d 100644 --- a/google/cloud/networkconnectivity/v1/hub_client.h +++ b/google/cloud/networkconnectivity/v1/hub_client.h @@ -1777,6 +1777,178 @@ class HubServiceClient { google::cloud::networkconnectivity::v1::ListGroupsRequest request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/networkconnectivity/v1/hub_connection.cc b/google/cloud/networkconnectivity/v1/hub_connection.cc index 4cca5ccda8e88..df99028cc39dd 100644 --- a/google/cloud/networkconnectivity/v1/hub_connection.cc +++ b/google/cloud/networkconnectivity/v1/hub_connection.cc @@ -292,6 +292,35 @@ HubServiceConnection::ListGroups( StreamRange>(); } +StreamRange +HubServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr HubServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr HubServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr HubServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +HubServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeHubServiceConnection( Options options) { internal::CheckExpectedOptions #include #include +#include #include #include @@ -325,6 +327,21 @@ class HubServiceConnection { virtual StreamRange ListGroups( google::cloud::networkconnectivity::v1::ListGroupsRequest request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/networkconnectivity/v1/hub_connection_idempotency_policy.cc b/google/cloud/networkconnectivity/v1/hub_connection_idempotency_policy.cc index ef638ba7e0945..0331331eccbb8 100644 --- a/google/cloud/networkconnectivity/v1/hub_connection_idempotency_policy.cc +++ b/google/cloud/networkconnectivity/v1/hub_connection_idempotency_policy.cc @@ -129,6 +129,32 @@ Idempotency HubServiceConnectionIdempotencyPolicy::ListGroups( return Idempotency::kIdempotent; } +Idempotency HubServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency HubServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency HubServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency HubServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency HubServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultHubServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/networkconnectivity/v1/hub_connection_idempotency_policy.h b/google/cloud/networkconnectivity/v1/hub_connection_idempotency_policy.h index 7f021a80016b0..054688f3050ac 100644 --- a/google/cloud/networkconnectivity/v1/hub_connection_idempotency_policy.h +++ b/google/cloud/networkconnectivity/v1/hub_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -98,6 +100,21 @@ class HubServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ListGroups( google::cloud::networkconnectivity::v1::ListGroupsRequest request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/networkconnectivity/v1/internal/hub_auth_decorator.cc b/google/cloud/networkconnectivity/v1/internal/hub_auth_decorator.cc index 350c5a661484c..8ce64c89f1441 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_auth_decorator.cc +++ b/google/cloud/networkconnectivity/v1/internal/hub_auth_decorator.cc @@ -357,6 +357,48 @@ HubServiceAuth::ListGroups( return child_->ListGroups(context, options, request); } +StatusOr +HubServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr HubServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr HubServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr HubServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +HubServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> HubServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networkconnectivity/v1/internal/hub_auth_decorator.h b/google/cloud/networkconnectivity/v1/internal/hub_auth_decorator.h index 38766c955d483..ac772c9b5a94a 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_auth_decorator.h +++ b/google/cloud/networkconnectivity/v1/internal/hub_auth_decorator.h @@ -192,6 +192,26 @@ class HubServiceAuth : public HubServiceStub { google::cloud::networkconnectivity::v1::ListGroupsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/networkconnectivity/v1/internal/hub_connection_impl.cc b/google/cloud/networkconnectivity/v1/internal/hub_connection_impl.cc index ff9232647612c..67700c3881610 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_connection_impl.cc +++ b/google/cloud/networkconnectivity/v1/internal/hub_connection_impl.cc @@ -1101,6 +1101,94 @@ HubServiceConnectionImpl::ListGroups( }); } +StreamRange +HubServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +HubServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr HubServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr HubServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +HubServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace networkconnectivity_v1_internal } // namespace cloud diff --git a/google/cloud/networkconnectivity/v1/internal/hub_connection_impl.h b/google/cloud/networkconnectivity/v1/internal/hub_connection_impl.h index 2889de9ca5300..c74d7966deb34 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_connection_impl.h +++ b/google/cloud/networkconnectivity/v1/internal/hub_connection_impl.h @@ -197,6 +197,21 @@ class HubServiceConnectionImpl google::cloud::networkconnectivity::v1::ListGroupsRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/networkconnectivity/v1/internal/hub_logging_decorator.cc b/google/cloud/networkconnectivity/v1/internal/hub_logging_decorator.cc index e696e7ac63671..2d35d2392e665 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_logging_decorator.cc +++ b/google/cloud/networkconnectivity/v1/internal/hub_logging_decorator.cc @@ -435,6 +435,63 @@ HubServiceLogging::ListGroups( context, options, request, __func__, tracing_options_); } +StatusOr +HubServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr HubServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr HubServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr HubServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +HubServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> HubServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networkconnectivity/v1/internal/hub_logging_decorator.h b/google/cloud/networkconnectivity/v1/internal/hub_logging_decorator.h index 7ce63d20d6b76..cd0717c4a6bf6 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_logging_decorator.h +++ b/google/cloud/networkconnectivity/v1/internal/hub_logging_decorator.h @@ -192,6 +192,26 @@ class HubServiceLogging : public HubServiceStub { google::cloud::networkconnectivity::v1::ListGroupsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/networkconnectivity/v1/internal/hub_metadata_decorator.cc b/google/cloud/networkconnectivity/v1/internal/hub_metadata_decorator.cc index a7b5c84d5baf9..d4d894086997b 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_metadata_decorator.cc +++ b/google/cloud/networkconnectivity/v1/internal/hub_metadata_decorator.cc @@ -314,6 +314,51 @@ HubServiceMetadata::ListGroups( return child_->ListGroups(context, options, request); } +StatusOr +HubServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr HubServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr HubServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr HubServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +HubServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> HubServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networkconnectivity/v1/internal/hub_metadata_decorator.h b/google/cloud/networkconnectivity/v1/internal/hub_metadata_decorator.h index cd595d4311190..8263518f1e72a 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_metadata_decorator.h +++ b/google/cloud/networkconnectivity/v1/internal/hub_metadata_decorator.h @@ -192,6 +192,26 @@ class HubServiceMetadata : public HubServiceStub { google::cloud::networkconnectivity::v1::ListGroupsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/networkconnectivity/v1/internal/hub_stub.cc b/google/cloud/networkconnectivity/v1/internal/hub_stub.cc index 3c49c38bd099c..fc667ab8eac3e 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_stub.cc +++ b/google/cloud/networkconnectivity/v1/internal/hub_stub.cc @@ -412,6 +412,64 @@ DefaultHubServiceStub::ListGroups( return response; } +StatusOr +DefaultHubServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultHubServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultHubServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultHubServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultHubServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultHubServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networkconnectivity/v1/internal/hub_stub.h b/google/cloud/networkconnectivity/v1/internal/hub_stub.h index 2baf1670479fe..266896c59f763 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_stub.h +++ b/google/cloud/networkconnectivity/v1/internal/hub_stub.h @@ -24,8 +24,12 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include +#include +#include #include #include #include @@ -194,6 +198,28 @@ class HubServiceStub { google::cloud::networkconnectivity::v1::ListGroupsRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -213,9 +239,15 @@ class DefaultHubServiceStub : public HubServiceStub { std::unique_ptr< google::cloud::networkconnectivity::v1::HubService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListHubs( grpc::ClientContext& context, Options const& options, @@ -370,6 +402,26 @@ class DefaultHubServiceStub : public HubServiceStub { google::cloud::networkconnectivity::v1::ListGroupsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -386,6 +438,9 @@ class DefaultHubServiceStub : public HubServiceStub { std::unique_ptr< google::cloud::networkconnectivity::v1::HubService::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/networkconnectivity/v1/internal/hub_stub_factory.cc b/google/cloud/networkconnectivity/v1/internal/hub_stub_factory.cc index c41be79558189..8dd017ad52e94 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_stub_factory.cc +++ b/google/cloud/networkconnectivity/v1/internal/hub_stub_factory.cc @@ -28,7 +28,9 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultHubServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::networkconnectivity::v1::HubService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/networkconnectivity/v1/internal/hub_tracing_connection.cc b/google/cloud/networkconnectivity/v1/internal/hub_tracing_connection.cc index 382d0d42218c2..06b8b4048f29f 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_tracing_connection.cc +++ b/google/cloud/networkconnectivity/v1/internal/hub_tracing_connection.cc @@ -378,6 +378,51 @@ HubServiceTracingConnection::ListGroups( std::move(sr)); } +StreamRange +HubServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "networkconnectivity_v1::HubServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +HubServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "networkconnectivity_v1::HubServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr HubServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "networkconnectivity_v1::HubServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr HubServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "networkconnectivity_v1::HubServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +HubServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "networkconnectivity_v1::HubServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/networkconnectivity/v1/internal/hub_tracing_connection.h b/google/cloud/networkconnectivity/v1/internal/hub_tracing_connection.h index 1c4bdad91d03d..f138067e54918 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_tracing_connection.h +++ b/google/cloud/networkconnectivity/v1/internal/hub_tracing_connection.h @@ -185,6 +185,21 @@ class HubServiceTracingConnection google::cloud::networkconnectivity::v1::ListGroupsRequest request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/networkconnectivity/v1/internal/hub_tracing_stub.cc b/google/cloud/networkconnectivity/v1/internal/hub_tracing_stub.cc index 008dd3f63530a..bac0af1bd1c0d 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_tracing_stub.cc +++ b/google/cloud/networkconnectivity/v1/internal/hub_tracing_stub.cc @@ -373,6 +373,63 @@ HubServiceTracingStub::ListGroups( child_->ListGroups(context, options, request)); } +StatusOr +HubServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkconnectivity.v1.HubService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr HubServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkconnectivity.v1.HubService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr HubServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkconnectivity.v1.HubService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr HubServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkconnectivity.v1.HubService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +HubServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkconnectivity.v1.HubService", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> HubServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networkconnectivity/v1/internal/hub_tracing_stub.h b/google/cloud/networkconnectivity/v1/internal/hub_tracing_stub.h index c2935b178c3d7..54ba4cf7b1a59 100644 --- a/google/cloud/networkconnectivity/v1/internal/hub_tracing_stub.h +++ b/google/cloud/networkconnectivity/v1/internal/hub_tracing_stub.h @@ -191,6 +191,26 @@ class HubServiceTracingStub : public HubServiceStub { google::cloud::networkconnectivity::v1::ListGroupsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_auth_decorator.cc b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_auth_decorator.cc index cf3833858e253..73d69962c9341 100644 --- a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_auth_decorator.cc +++ b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_auth_decorator.cc @@ -113,6 +113,49 @@ PolicyBasedRoutingServiceAuth::DeletePolicyBasedRoute( return child_->DeletePolicyBasedRoute(context, options, request); } +StatusOr +PolicyBasedRoutingServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +PolicyBasedRoutingServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr PolicyBasedRoutingServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr PolicyBasedRoutingServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +PolicyBasedRoutingServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> PolicyBasedRoutingServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_auth_decorator.h b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_auth_decorator.h index 85b168bc9a5a9..11599e89177da 100644 --- a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_auth_decorator.h +++ b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_auth_decorator.h @@ -76,6 +76,26 @@ class PolicyBasedRoutingServiceAuth : public PolicyBasedRoutingServiceStub { google::cloud::networkconnectivity::v1:: DeletePolicyBasedRouteRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_connection_impl.cc b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_connection_impl.cc index eef659be72f41..bb26e2adab1b9 100644 --- a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_connection_impl.cc +++ b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_connection_impl.cc @@ -322,6 +322,97 @@ PolicyBasedRoutingServiceConnectionImpl::DeletePolicyBasedRoute( polling_policy(*current), __func__); } +StreamRange +PolicyBasedRoutingServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr< + networkconnectivity_v1::PolicyBasedRoutingServiceRetryPolicy>( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +PolicyBasedRoutingServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +PolicyBasedRoutingServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +PolicyBasedRoutingServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +PolicyBasedRoutingServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace networkconnectivity_v1_internal } // namespace cloud diff --git a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_connection_impl.h b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_connection_impl.h index 4a85363cefa5a..5103bbdbc8641 100644 --- a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_connection_impl.h +++ b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_connection_impl.h @@ -90,6 +90,21 @@ class PolicyBasedRoutingServiceConnectionImpl DeletePolicyBasedRoute( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr< diff --git a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_logging_decorator.cc b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_logging_decorator.cc index 43218e46819e3..23342d995123c 100644 --- a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_logging_decorator.cc +++ b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_logging_decorator.cc @@ -131,6 +131,66 @@ PolicyBasedRoutingServiceLogging::DeletePolicyBasedRoute( context, options, request, __func__, tracing_options_); } +StatusOr +PolicyBasedRoutingServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PolicyBasedRoutingServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PolicyBasedRoutingServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PolicyBasedRoutingServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PolicyBasedRoutingServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> PolicyBasedRoutingServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_logging_decorator.h b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_logging_decorator.h index 2a8cf10f2120f..09df6418200c8 100644 --- a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_logging_decorator.h +++ b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_logging_decorator.h @@ -76,6 +76,26 @@ class PolicyBasedRoutingServiceLogging : public PolicyBasedRoutingServiceStub { google::cloud::networkconnectivity::v1:: DeletePolicyBasedRouteRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_metadata_decorator.cc b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_metadata_decorator.cc index 931117e42f674..6475ea152bc0e 100644 --- a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_metadata_decorator.cc +++ b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_metadata_decorator.cc @@ -110,6 +110,54 @@ PolicyBasedRoutingServiceMetadata::DeletePolicyBasedRoute( return child_->DeletePolicyBasedRoute(context, options, request); } +StatusOr +PolicyBasedRoutingServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +PolicyBasedRoutingServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr +PolicyBasedRoutingServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr +PolicyBasedRoutingServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +PolicyBasedRoutingServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> PolicyBasedRoutingServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_metadata_decorator.h b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_metadata_decorator.h index d9728f2c5a1e3..3afd865ea4122 100644 --- a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_metadata_decorator.h +++ b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_metadata_decorator.h @@ -77,6 +77,26 @@ class PolicyBasedRoutingServiceMetadata : public PolicyBasedRoutingServiceStub { google::cloud::networkconnectivity::v1:: DeletePolicyBasedRouteRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_stub.cc b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_stub.cc index 63f744c4e8428..2c79ed0cacc38 100644 --- a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_stub.cc +++ b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_stub.cc @@ -126,6 +126,67 @@ DefaultPolicyBasedRoutingServiceStub::DeletePolicyBasedRoute( return response; } +StatusOr +DefaultPolicyBasedRoutingServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPolicyBasedRoutingServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPolicyBasedRoutingServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPolicyBasedRoutingServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPolicyBasedRoutingServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultPolicyBasedRoutingServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_stub.h b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_stub.h index 96f8be74e6db5..ca46695c896ab 100644 --- a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_stub.h +++ b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_stub.h @@ -24,7 +24,11 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include +#include +#include #include #include #include @@ -76,6 +80,28 @@ class PolicyBasedRoutingServiceStub { google::cloud::networkconnectivity::v1:: DeletePolicyBasedRouteRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -96,9 +122,15 @@ class DefaultPolicyBasedRoutingServiceStub std::unique_ptr grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr< google::cloud::networkconnectivity::v1::ListPolicyBasedRoutesResponse> @@ -137,6 +169,26 @@ class DefaultPolicyBasedRoutingServiceStub google::cloud::networkconnectivity::v1:: DeletePolicyBasedRouteRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -153,6 +205,9 @@ class DefaultPolicyBasedRoutingServiceStub std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_stub_factory.cc b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_stub_factory.cc index 124c9b598b53c..d267fdb1846ee 100644 --- a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_stub_factory.cc +++ b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_stub_factory.cc @@ -28,7 +28,9 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include #include #include @@ -45,9 +47,13 @@ CreateDefaultPolicyBasedRoutingServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::networkconnectivity::v1:: PolicyBasedRoutingService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_tracing_connection.cc b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_tracing_connection.cc index ebd2324eeac2a..9867530aa3ad5 100644 --- a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_tracing_connection.cc +++ b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_tracing_connection.cc @@ -133,6 +133,58 @@ PolicyBasedRoutingServiceTracingConnection::DeletePolicyBasedRoute( child_->DeletePolicyBasedRoute(operation)); } +StreamRange +PolicyBasedRoutingServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "networkconnectivity_v1::PolicyBasedRoutingServiceConnection::" + "ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +PolicyBasedRoutingServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "networkconnectivity_v1::PolicyBasedRoutingServiceConnection::" + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +PolicyBasedRoutingServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "networkconnectivity_v1::PolicyBasedRoutingServiceConnection::" + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +PolicyBasedRoutingServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "networkconnectivity_v1::PolicyBasedRoutingServiceConnection::" + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +PolicyBasedRoutingServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "networkconnectivity_v1::PolicyBasedRoutingServiceConnection::" + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_tracing_connection.h b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_tracing_connection.h index 46cfaa828b558..9c0a18f127d0b 100644 --- a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_tracing_connection.h +++ b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_tracing_connection.h @@ -78,6 +78,21 @@ class PolicyBasedRoutingServiceTracingConnection DeletePolicyBasedRoute( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; diff --git a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_tracing_stub.cc b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_tracing_stub.cc index 765465afeb927..85f58628cf799 100644 --- a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_tracing_stub.cc +++ b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_tracing_stub.cc @@ -124,6 +124,71 @@ PolicyBasedRoutingServiceTracingStub::DeletePolicyBasedRoute( child_->DeletePolicyBasedRoute(context, options, request)); } +StatusOr +PolicyBasedRoutingServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkconnectivity.v1.PolicyBasedRoutingService", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +PolicyBasedRoutingServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkconnectivity.v1.PolicyBasedRoutingService", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr +PolicyBasedRoutingServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkconnectivity.v1.PolicyBasedRoutingService", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr +PolicyBasedRoutingServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkconnectivity.v1.PolicyBasedRoutingService", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +PolicyBasedRoutingServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkconnectivity.v1.PolicyBasedRoutingService", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> PolicyBasedRoutingServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_tracing_stub.h b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_tracing_stub.h index fb0dc4aea2f3c..8fb428253037d 100644 --- a/google/cloud/networkconnectivity/v1/internal/policy_based_routing_tracing_stub.h +++ b/google/cloud/networkconnectivity/v1/internal/policy_based_routing_tracing_stub.h @@ -77,6 +77,26 @@ class PolicyBasedRoutingServiceTracingStub google::cloud::networkconnectivity::v1:: DeletePolicyBasedRouteRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/networkconnectivity/v1/mocks/mock_hub_connection.h b/google/cloud/networkconnectivity/v1/mocks/mock_hub_connection.h index cbee419d6e030..0f108ab8c27e3 100644 --- a/google/cloud/networkconnectivity/v1/mocks/mock_hub_connection.h +++ b/google/cloud/networkconnectivity/v1/mocks/mock_hub_connection.h @@ -431,6 +431,27 @@ class MockHubServiceConnection (StreamRange), ListGroups, (google::cloud::networkconnectivity::v1::ListGroupsRequest request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/networkconnectivity/v1/mocks/mock_policy_based_routing_connection.h b/google/cloud/networkconnectivity/v1/mocks/mock_policy_based_routing_connection.h index 102067bf6b732..c9c2b477b5594 100644 --- a/google/cloud/networkconnectivity/v1/mocks/mock_policy_based_routing_connection.h +++ b/google/cloud/networkconnectivity/v1/mocks/mock_policy_based_routing_connection.h @@ -144,6 +144,27 @@ class MockPolicyBasedRoutingServiceConnection StatusOr>, DeletePolicyBasedRoute, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/networkconnectivity/v1/policy_based_routing_client.cc b/google/cloud/networkconnectivity/v1/policy_based_routing_client.cc index 4302e322bec06..782690cf6380b 100644 --- a/google/cloud/networkconnectivity/v1/policy_based_routing_client.cc +++ b/google/cloud/networkconnectivity/v1/policy_based_routing_client.cc @@ -168,6 +168,39 @@ PolicyBasedRoutingServiceClient::DeletePolicyBasedRoute( return connection_->DeletePolicyBasedRoute(operation); } +StreamRange +PolicyBasedRoutingServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +PolicyBasedRoutingServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr PolicyBasedRoutingServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr PolicyBasedRoutingServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +PolicyBasedRoutingServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace networkconnectivity_v1 } // namespace cloud diff --git a/google/cloud/networkconnectivity/v1/policy_based_routing_client.h b/google/cloud/networkconnectivity/v1/policy_based_routing_client.h index 4de686183e6fd..3fab5995ee0d8 100644 --- a/google/cloud/networkconnectivity/v1/policy_based_routing_client.h +++ b/google/cloud/networkconnectivity/v1/policy_based_routing_client.h @@ -466,6 +466,178 @@ class PolicyBasedRoutingServiceClient { DeletePolicyBasedRoute(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/networkconnectivity/v1/policy_based_routing_connection.cc b/google/cloud/networkconnectivity/v1/policy_based_routing_connection.cc index e4567a6e0c183..9ec8836bef882 100644 --- a/google/cloud/networkconnectivity/v1/policy_based_routing_connection.cc +++ b/google/cloud/networkconnectivity/v1/policy_based_routing_connection.cc @@ -103,6 +103,38 @@ PolicyBasedRoutingServiceConnection::DeletePolicyBasedRoute( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +PolicyBasedRoutingServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +PolicyBasedRoutingServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +PolicyBasedRoutingServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +PolicyBasedRoutingServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +PolicyBasedRoutingServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakePolicyBasedRoutingServiceConnection(Options options) { internal::CheckExpectedOptions #include +#include #include #include @@ -235,6 +237,21 @@ class PolicyBasedRoutingServiceConnection { virtual future< StatusOr> DeletePolicyBasedRoute(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/networkconnectivity/v1/policy_based_routing_connection_idempotency_policy.cc b/google/cloud/networkconnectivity/v1/policy_based_routing_connection_idempotency_policy.cc index e62759488d056..3e8050d6abbb0 100644 --- a/google/cloud/networkconnectivity/v1/policy_based_routing_connection_idempotency_policy.cc +++ b/google/cloud/networkconnectivity/v1/policy_based_routing_connection_idempotency_policy.cc @@ -62,6 +62,33 @@ PolicyBasedRoutingServiceConnectionIdempotencyPolicy::DeletePolicyBasedRoute( return Idempotency::kNonIdempotent; } +Idempotency PolicyBasedRoutingServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency PolicyBasedRoutingServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency PolicyBasedRoutingServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency PolicyBasedRoutingServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +PolicyBasedRoutingServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultPolicyBasedRoutingServiceConnectionIdempotencyPolicy() { return std::make_unique< diff --git a/google/cloud/networkconnectivity/v1/policy_based_routing_connection_idempotency_policy.h b/google/cloud/networkconnectivity/v1/policy_based_routing_connection_idempotency_policy.h index 6c2367bc4c678..5169dd9b185cf 100644 --- a/google/cloud/networkconnectivity/v1/policy_based_routing_connection_idempotency_policy.h +++ b/google/cloud/networkconnectivity/v1/policy_based_routing_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -52,6 +54,21 @@ class PolicyBasedRoutingServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeletePolicyBasedRoute( google::cloud::networkconnectivity::v1:: DeletePolicyBasedRouteRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/networkmanagement/BUILD.bazel b/google/cloud/networkmanagement/BUILD.bazel index 7b8790a4bc567..08c75fffbcd11 100644 --- a/google/cloud/networkmanagement/BUILD.bazel +++ b/google/cloud/networkmanagement/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/networkmanagement/v1:networkmanagement_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/networkmanagement/v1/internal/reachability_auth_decorator.cc b/google/cloud/networkmanagement/v1/internal/reachability_auth_decorator.cc index e28a4f1a03d4a..60795d661c00d 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_auth_decorator.cc +++ b/google/cloud/networkmanagement/v1/internal/reachability_auth_decorator.cc @@ -175,6 +175,49 @@ ReachabilityServiceAuth::DeleteConnectivityTest( return child_->DeleteConnectivityTest(context, options, request); } +StatusOr +ReachabilityServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +ReachabilityServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr ReachabilityServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr ReachabilityServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +ReachabilityServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> ReachabilityServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networkmanagement/v1/internal/reachability_auth_decorator.h b/google/cloud/networkmanagement/v1/internal/reachability_auth_decorator.h index 835fe5e85f0bd..f140de964cb69 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_auth_decorator.h +++ b/google/cloud/networkmanagement/v1/internal/reachability_auth_decorator.h @@ -99,6 +99,26 @@ class ReachabilityServiceAuth : public ReachabilityServiceStub { google::cloud::networkmanagement::v1::DeleteConnectivityTestRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/networkmanagement/v1/internal/reachability_connection_impl.cc b/google/cloud/networkmanagement/v1/internal/reachability_connection_impl.cc index 46b5a754819a0..77e40e934359f 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_connection_impl.cc +++ b/google/cloud/networkmanagement/v1/internal/reachability_connection_impl.cc @@ -507,6 +507,97 @@ ReachabilityServiceConnectionImpl::DeleteConnectivityTest( polling_policy(*current), __func__); } +StreamRange +ReachabilityServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr< + networkmanagement_v1::ReachabilityServiceRetryPolicy>( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ReachabilityServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +ReachabilityServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +ReachabilityServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +ReachabilityServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace networkmanagement_v1_internal } // namespace cloud diff --git a/google/cloud/networkmanagement/v1/internal/reachability_connection_impl.h b/google/cloud/networkmanagement/v1/internal/reachability_connection_impl.h index 2bd298e37880d..a0b876c2d2c24 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_connection_impl.h +++ b/google/cloud/networkmanagement/v1/internal/reachability_connection_impl.h @@ -119,6 +119,21 @@ class ReachabilityServiceConnectionImpl DeleteConnectivityTest( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/networkmanagement/v1/internal/reachability_logging_decorator.cc b/google/cloud/networkmanagement/v1/internal/reachability_logging_decorator.cc index fa8d8be6d8642..3aac4fc66e281 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_logging_decorator.cc +++ b/google/cloud/networkmanagement/v1/internal/reachability_logging_decorator.cc @@ -199,6 +199,64 @@ ReachabilityServiceLogging::DeleteConnectivityTest( context, options, request, __func__, tracing_options_); } +StatusOr +ReachabilityServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ReachabilityServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ReachabilityServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ReachabilityServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ReachabilityServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ReachabilityServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networkmanagement/v1/internal/reachability_logging_decorator.h b/google/cloud/networkmanagement/v1/internal/reachability_logging_decorator.h index c62d75fa28316..13e68ada4ae1c 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_logging_decorator.h +++ b/google/cloud/networkmanagement/v1/internal/reachability_logging_decorator.h @@ -99,6 +99,26 @@ class ReachabilityServiceLogging : public ReachabilityServiceStub { google::cloud::networkmanagement::v1::DeleteConnectivityTestRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/networkmanagement/v1/internal/reachability_metadata_decorator.cc b/google/cloud/networkmanagement/v1/internal/reachability_metadata_decorator.cc index aedbd3181580a..31429d2ac862a 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_metadata_decorator.cc +++ b/google/cloud/networkmanagement/v1/internal/reachability_metadata_decorator.cc @@ -158,6 +158,52 @@ ReachabilityServiceMetadata::DeleteConnectivityTest( return child_->DeleteConnectivityTest(context, options, request); } +StatusOr +ReachabilityServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +ReachabilityServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr ReachabilityServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr ReachabilityServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +ReachabilityServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> ReachabilityServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networkmanagement/v1/internal/reachability_metadata_decorator.h b/google/cloud/networkmanagement/v1/internal/reachability_metadata_decorator.h index 28c03ec665ae2..95582a2bff356 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_metadata_decorator.h +++ b/google/cloud/networkmanagement/v1/internal/reachability_metadata_decorator.h @@ -100,6 +100,26 @@ class ReachabilityServiceMetadata : public ReachabilityServiceStub { google::cloud::networkmanagement::v1::DeleteConnectivityTestRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/networkmanagement/v1/internal/reachability_stub.cc b/google/cloud/networkmanagement/v1/internal/reachability_stub.cc index 0b7fd4f8a559c..1c4db1eb19bb2 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_stub.cc +++ b/google/cloud/networkmanagement/v1/internal/reachability_stub.cc @@ -192,6 +192,65 @@ DefaultReachabilityServiceStub::DeleteConnectivityTest( return response; } +StatusOr +DefaultReachabilityServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultReachabilityServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultReachabilityServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultReachabilityServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultReachabilityServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultReachabilityServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networkmanagement/v1/internal/reachability_stub.h b/google/cloud/networkmanagement/v1/internal/reachability_stub.h index ba78f28c54b40..8aa796f89bc4f 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_stub.h +++ b/google/cloud/networkmanagement/v1/internal/reachability_stub.h @@ -24,7 +24,11 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include +#include +#include #include #include #include @@ -103,6 +107,28 @@ class ReachabilityServiceStub { google::cloud::networkmanagement::v1::DeleteConnectivityTestRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -122,9 +148,15 @@ class DefaultReachabilityServiceStub : public ReachabilityServiceStub { std::unique_ptr grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListConnectivityTests( @@ -186,6 +218,26 @@ class DefaultReachabilityServiceStub : public ReachabilityServiceStub { google::cloud::networkmanagement::v1::DeleteConnectivityTestRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -202,6 +254,9 @@ class DefaultReachabilityServiceStub : public ReachabilityServiceStub { std::unique_ptr< google::cloud::networkmanagement::v1::ReachabilityService::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/networkmanagement/v1/internal/reachability_stub_factory.cc b/google/cloud/networkmanagement/v1/internal/reachability_stub_factory.cc index f27ca9e7ef2e0..bda97765ee11e 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_stub_factory.cc +++ b/google/cloud/networkmanagement/v1/internal/reachability_stub_factory.cc @@ -28,7 +28,9 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include #include #include @@ -45,9 +47,13 @@ std::shared_ptr CreateDefaultReachabilityServiceStub( auto service_grpc_stub = google::cloud::networkmanagement::v1::ReachabilityService::NewStub( channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/networkmanagement/v1/internal/reachability_tracing_connection.cc b/google/cloud/networkmanagement/v1/internal/reachability_tracing_connection.cc index 180f6c019676b..28260d8aa4a01 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_tracing_connection.cc +++ b/google/cloud/networkmanagement/v1/internal/reachability_tracing_connection.cc @@ -202,6 +202,54 @@ ReachabilityServiceTracingConnection::DeleteConnectivityTest( child_->DeleteConnectivityTest(operation)); } +StreamRange +ReachabilityServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "networkmanagement_v1::ReachabilityServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ReachabilityServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "networkmanagement_v1::ReachabilityServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +ReachabilityServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "networkmanagement_v1::ReachabilityServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +ReachabilityServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "networkmanagement_v1::ReachabilityServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +ReachabilityServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "networkmanagement_v1::ReachabilityServiceConnection::" + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/networkmanagement/v1/internal/reachability_tracing_connection.h b/google/cloud/networkmanagement/v1/internal/reachability_tracing_connection.h index 4135c11bb93f6..ae365bb13ae7b 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_tracing_connection.h +++ b/google/cloud/networkmanagement/v1/internal/reachability_tracing_connection.h @@ -107,6 +107,21 @@ class ReachabilityServiceTracingConnection DeleteConnectivityTest( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/networkmanagement/v1/internal/reachability_tracing_stub.cc b/google/cloud/networkmanagement/v1/internal/reachability_tracing_stub.cc index 1d1ab661d710f..088863c9074b1 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_tracing_stub.cc +++ b/google/cloud/networkmanagement/v1/internal/reachability_tracing_stub.cc @@ -187,6 +187,65 @@ ReachabilityServiceTracingStub::DeleteConnectivityTest( child_->DeleteConnectivityTest(context, options, request)); } +StatusOr +ReachabilityServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkmanagement.v1.ReachabilityService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +ReachabilityServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkmanagement.v1.ReachabilityService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr ReachabilityServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkmanagement.v1.ReachabilityService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr ReachabilityServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkmanagement.v1.ReachabilityService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +ReachabilityServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkmanagement.v1.ReachabilityService", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> ReachabilityServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networkmanagement/v1/internal/reachability_tracing_stub.h b/google/cloud/networkmanagement/v1/internal/reachability_tracing_stub.h index 82e4173eddf9d..c541177498121 100644 --- a/google/cloud/networkmanagement/v1/internal/reachability_tracing_stub.h +++ b/google/cloud/networkmanagement/v1/internal/reachability_tracing_stub.h @@ -99,6 +99,26 @@ class ReachabilityServiceTracingStub : public ReachabilityServiceStub { google::cloud::networkmanagement::v1::DeleteConnectivityTestRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/networkmanagement/v1/mocks/mock_reachability_connection.h b/google/cloud/networkmanagement/v1/mocks/mock_reachability_connection.h index 71752c9815aa4..7208d7c380bb4 100644 --- a/google/cloud/networkmanagement/v1/mocks/mock_reachability_connection.h +++ b/google/cloud/networkmanagement/v1/mocks/mock_reachability_connection.h @@ -222,6 +222,27 @@ class MockReachabilityServiceConnection future>, DeleteConnectivityTest, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/networkmanagement/v1/reachability_client.cc b/google/cloud/networkmanagement/v1/reachability_client.cc index 9aa6b25473709..ca7702242fb57 100644 --- a/google/cloud/networkmanagement/v1/reachability_client.cc +++ b/google/cloud/networkmanagement/v1/reachability_client.cc @@ -240,6 +240,39 @@ ReachabilityServiceClient::DeleteConnectivityTest( return connection_->DeleteConnectivityTest(operation); } +StreamRange +ReachabilityServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +ReachabilityServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr ReachabilityServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr ReachabilityServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +ReachabilityServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace networkmanagement_v1 } // namespace cloud diff --git a/google/cloud/networkmanagement/v1/reachability_client.h b/google/cloud/networkmanagement/v1/reachability_client.h index ce2c1d4bcd722..4d202b310033a 100644 --- a/google/cloud/networkmanagement/v1/reachability_client.h +++ b/google/cloud/networkmanagement/v1/reachability_client.h @@ -735,6 +735,178 @@ class ReachabilityServiceClient { DeleteConnectivityTest(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/networkmanagement/v1/reachability_connection.cc b/google/cloud/networkmanagement/v1/reachability_connection.cc index 0d3767946256a..124a9ab8214d8 100644 --- a/google/cloud/networkmanagement/v1/reachability_connection.cc +++ b/google/cloud/networkmanagement/v1/reachability_connection.cc @@ -151,6 +151,36 @@ ReachabilityServiceConnection::DeleteConnectivityTest( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +ReachabilityServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +ReachabilityServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr ReachabilityServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr ReachabilityServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +ReachabilityServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeReachabilityServiceConnection(Options options) { internal::CheckExpectedOptions #include +#include #include #include @@ -259,6 +261,21 @@ class ReachabilityServiceConnection { virtual future< StatusOr> DeleteConnectivityTest(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/networkmanagement/v1/reachability_connection_idempotency_policy.cc b/google/cloud/networkmanagement/v1/reachability_connection_idempotency_policy.cc index 883d84f5a84ee..bb349fdf6d2e5 100644 --- a/google/cloud/networkmanagement/v1/reachability_connection_idempotency_policy.cc +++ b/google/cloud/networkmanagement/v1/reachability_connection_idempotency_policy.cc @@ -74,6 +74,32 @@ ReachabilityServiceConnectionIdempotencyPolicy::DeleteConnectivityTest( return Idempotency::kNonIdempotent; } +Idempotency ReachabilityServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ReachabilityServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ReachabilityServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency ReachabilityServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ReachabilityServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultReachabilityServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/networkmanagement/v1/reachability_connection_idempotency_policy.h b/google/cloud/networkmanagement/v1/reachability_connection_idempotency_policy.h index eb13e3abda985..7b26d1fe32a76 100644 --- a/google/cloud/networkmanagement/v1/reachability_connection_idempotency_policy.h +++ b/google/cloud/networkmanagement/v1/reachability_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -60,6 +62,21 @@ class ReachabilityServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteConnectivityTest( google::cloud::networkmanagement::v1::DeleteConnectivityTestRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/networksecurity/BUILD.bazel b/google/cloud/networksecurity/BUILD.bazel index a77fe0a8536f6..f2d7272c8bba8 100644 --- a/google/cloud/networksecurity/BUILD.bazel +++ b/google/cloud/networksecurity/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/networksecurity/v1:networksecurity_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/networksecurity/v1/internal/network_security_auth_decorator.cc b/google/cloud/networksecurity/v1/internal/network_security_auth_decorator.cc index 4f856b4031c07..193cb5ad99ea6 100644 --- a/google/cloud/networksecurity/v1/internal/network_security_auth_decorator.cc +++ b/google/cloud/networksecurity/v1/internal/network_security_auth_decorator.cc @@ -370,6 +370,48 @@ NetworkSecurityAuth::DeleteClientTlsPolicy( return child_->DeleteClientTlsPolicy(context, options, request); } +StatusOr +NetworkSecurityAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr NetworkSecurityAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr NetworkSecurityAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr NetworkSecurityAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +NetworkSecurityAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> NetworkSecurityAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networksecurity/v1/internal/network_security_auth_decorator.h b/google/cloud/networksecurity/v1/internal/network_security_auth_decorator.h index fe4a5a817cd99..3d28e4ee91a3a 100644 --- a/google/cloud/networksecurity/v1/internal/network_security_auth_decorator.h +++ b/google/cloud/networksecurity/v1/internal/network_security_auth_decorator.h @@ -187,6 +187,26 @@ class NetworkSecurityAuth : public NetworkSecurityStub { google::cloud::networksecurity::v1::DeleteClientTlsPolicyRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/networksecurity/v1/internal/network_security_connection_impl.cc b/google/cloud/networksecurity/v1/internal/network_security_connection_impl.cc index 5b58bc66c9f25..adaecb53ad40f 100644 --- a/google/cloud/networksecurity/v1/internal/network_security_connection_impl.cc +++ b/google/cloud/networksecurity/v1/internal/network_security_connection_impl.cc @@ -1081,6 +1081,94 @@ NetworkSecurityConnectionImpl::DeleteClientTlsPolicy( polling_policy(*current), __func__); } +StreamRange +NetworkSecurityConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +NetworkSecurityConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr NetworkSecurityConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr NetworkSecurityConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +NetworkSecurityConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace networksecurity_v1_internal } // namespace cloud diff --git a/google/cloud/networksecurity/v1/internal/network_security_connection_impl.h b/google/cloud/networksecurity/v1/internal/network_security_connection_impl.h index 89f1d83f12cc8..89979f585fcd0 100644 --- a/google/cloud/networksecurity/v1/internal/network_security_connection_impl.h +++ b/google/cloud/networksecurity/v1/internal/network_security_connection_impl.h @@ -205,6 +205,21 @@ class NetworkSecurityConnectionImpl DeleteClientTlsPolicy( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/networksecurity/v1/internal/network_security_logging_decorator.cc b/google/cloud/networksecurity/v1/internal/network_security_logging_decorator.cc index a5b82eab2cf22..73deaf1649cdb 100644 --- a/google/cloud/networksecurity/v1/internal/network_security_logging_decorator.cc +++ b/google/cloud/networksecurity/v1/internal/network_security_logging_decorator.cc @@ -427,6 +427,63 @@ NetworkSecurityLogging::DeleteClientTlsPolicy( context, options, request, __func__, tracing_options_); } +StatusOr +NetworkSecurityLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr NetworkSecurityLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr NetworkSecurityLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr NetworkSecurityLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +NetworkSecurityLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> NetworkSecurityLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networksecurity/v1/internal/network_security_logging_decorator.h b/google/cloud/networksecurity/v1/internal/network_security_logging_decorator.h index 32861d8eb755e..ecb1f3acec643 100644 --- a/google/cloud/networksecurity/v1/internal/network_security_logging_decorator.h +++ b/google/cloud/networksecurity/v1/internal/network_security_logging_decorator.h @@ -187,6 +187,26 @@ class NetworkSecurityLogging : public NetworkSecurityStub { google::cloud::networksecurity::v1::DeleteClientTlsPolicyRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/networksecurity/v1/internal/network_security_metadata_decorator.cc b/google/cloud/networksecurity/v1/internal/network_security_metadata_decorator.cc index a9b5a7e271e6c..bb288e15856bd 100644 --- a/google/cloud/networksecurity/v1/internal/network_security_metadata_decorator.cc +++ b/google/cloud/networksecurity/v1/internal/network_security_metadata_decorator.cc @@ -323,6 +323,52 @@ NetworkSecurityMetadata::DeleteClientTlsPolicy( return child_->DeleteClientTlsPolicy(context, options, request); } +StatusOr +NetworkSecurityMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +NetworkSecurityMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr NetworkSecurityMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr NetworkSecurityMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +NetworkSecurityMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> NetworkSecurityMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networksecurity/v1/internal/network_security_metadata_decorator.h b/google/cloud/networksecurity/v1/internal/network_security_metadata_decorator.h index 686cb9e08d97f..e3e848d523438 100644 --- a/google/cloud/networksecurity/v1/internal/network_security_metadata_decorator.h +++ b/google/cloud/networksecurity/v1/internal/network_security_metadata_decorator.h @@ -188,6 +188,26 @@ class NetworkSecurityMetadata : public NetworkSecurityStub { google::cloud::networksecurity::v1::DeleteClientTlsPolicyRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/networksecurity/v1/internal/network_security_stub.cc b/google/cloud/networksecurity/v1/internal/network_security_stub.cc index a4ef47d4ae74e..27b7fbd1dd65e 100644 --- a/google/cloud/networksecurity/v1/internal/network_security_stub.cc +++ b/google/cloud/networksecurity/v1/internal/network_security_stub.cc @@ -412,6 +412,65 @@ DefaultNetworkSecurityStub::DeleteClientTlsPolicy( return response; } +StatusOr +DefaultNetworkSecurityStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultNetworkSecurityStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultNetworkSecurityStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultNetworkSecurityStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultNetworkSecurityStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultNetworkSecurityStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networksecurity/v1/internal/network_security_stub.h b/google/cloud/networksecurity/v1/internal/network_security_stub.h index cb2cb6d9a721c..e6007ad5106d0 100644 --- a/google/cloud/networksecurity/v1/internal/network_security_stub.h +++ b/google/cloud/networksecurity/v1/internal/network_security_stub.h @@ -24,8 +24,12 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include +#include +#include #include #include #include @@ -195,6 +199,28 @@ class NetworkSecurityStub { google::cloud::networksecurity::v1::DeleteClientTlsPolicyRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -214,9 +240,15 @@ class DefaultNetworkSecurityStub : public NetworkSecurityStub { std::unique_ptr< google::cloud::networksecurity::v1::NetworkSecurity::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr< google::cloud::networksecurity::v1::ListAuthorizationPoliciesResponse> @@ -366,6 +398,26 @@ class DefaultNetworkSecurityStub : public NetworkSecurityStub { google::cloud::networksecurity::v1::DeleteClientTlsPolicyRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -382,6 +434,9 @@ class DefaultNetworkSecurityStub : public NetworkSecurityStub { std::unique_ptr< google::cloud::networksecurity::v1::NetworkSecurity::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/networksecurity/v1/internal/network_security_stub_factory.cc b/google/cloud/networksecurity/v1/internal/network_security_stub_factory.cc index 9abde09cf1d3c..77abc7234e866 100644 --- a/google/cloud/networksecurity/v1/internal/network_security_stub_factory.cc +++ b/google/cloud/networksecurity/v1/internal/network_security_stub_factory.cc @@ -28,7 +28,9 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultNetworkSecurityStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::networksecurity::v1::NetworkSecurity::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/networksecurity/v1/internal/network_security_tracing_connection.cc b/google/cloud/networksecurity/v1/internal/network_security_tracing_connection.cc index 0166e120c71a6..0f1bfe586cae8 100644 --- a/google/cloud/networksecurity/v1/internal/network_security_tracing_connection.cc +++ b/google/cloud/networksecurity/v1/internal/network_security_tracing_connection.cc @@ -407,6 +407,53 @@ NetworkSecurityTracingConnection::DeleteClientTlsPolicy( child_->DeleteClientTlsPolicy(operation)); } +StreamRange +NetworkSecurityTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "networksecurity_v1::NetworkSecurityConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +NetworkSecurityTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "networksecurity_v1::NetworkSecurityConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +NetworkSecurityTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "networksecurity_v1::NetworkSecurityConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +NetworkSecurityTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "networksecurity_v1::NetworkSecurityConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +NetworkSecurityTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "networksecurity_v1::NetworkSecurityConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/networksecurity/v1/internal/network_security_tracing_connection.h b/google/cloud/networksecurity/v1/internal/network_security_tracing_connection.h index 6746f5159112f..26f8495e5830c 100644 --- a/google/cloud/networksecurity/v1/internal/network_security_tracing_connection.h +++ b/google/cloud/networksecurity/v1/internal/network_security_tracing_connection.h @@ -193,6 +193,21 @@ class NetworkSecurityTracingConnection DeleteClientTlsPolicy( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/networksecurity/v1/internal/network_security_tracing_stub.cc b/google/cloud/networksecurity/v1/internal/network_security_tracing_stub.cc index 8e75ea38dd206..72647f8445fc1 100644 --- a/google/cloud/networksecurity/v1/internal/network_security_tracing_stub.cc +++ b/google/cloud/networksecurity/v1/internal/network_security_tracing_stub.cc @@ -398,6 +398,64 @@ NetworkSecurityTracingStub::DeleteClientTlsPolicy( context, *span, child_->DeleteClientTlsPolicy(context, options, request)); } +StatusOr +NetworkSecurityTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networksecurity.v1.NetworkSecurity", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +NetworkSecurityTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networksecurity.v1.NetworkSecurity", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr NetworkSecurityTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networksecurity.v1.NetworkSecurity", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr NetworkSecurityTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networksecurity.v1.NetworkSecurity", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +NetworkSecurityTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networksecurity.v1.NetworkSecurity", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> NetworkSecurityTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networksecurity/v1/internal/network_security_tracing_stub.h b/google/cloud/networksecurity/v1/internal/network_security_tracing_stub.h index c6725b317fcf7..8b7f498411e45 100644 --- a/google/cloud/networksecurity/v1/internal/network_security_tracing_stub.h +++ b/google/cloud/networksecurity/v1/internal/network_security_tracing_stub.h @@ -187,6 +187,26 @@ class NetworkSecurityTracingStub : public NetworkSecurityStub { google::cloud::networksecurity::v1::DeleteClientTlsPolicyRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/networksecurity/v1/mocks/mock_network_security_connection.h b/google/cloud/networksecurity/v1/mocks/mock_network_security_connection.h index 7e0f9c0b9b8e2..b9f5d9913e4e6 100644 --- a/google/cloud/networksecurity/v1/mocks/mock_network_security_connection.h +++ b/google/cloud/networksecurity/v1/mocks/mock_network_security_connection.h @@ -466,6 +466,27 @@ class MockNetworkSecurityConnection future>, DeleteClientTlsPolicy, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/networksecurity/v1/network_security_client.cc b/google/cloud/networksecurity/v1/network_security_client.cc index 61603f1294564..562ff123f9829 100644 --- a/google/cloud/networksecurity/v1/network_security_client.cc +++ b/google/cloud/networksecurity/v1/network_security_client.cc @@ -588,6 +588,38 @@ NetworkSecurityClient::DeleteClientTlsPolicy( return connection_->DeleteClientTlsPolicy(operation); } +StreamRange +NetworkSecurityClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr NetworkSecurityClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr NetworkSecurityClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr NetworkSecurityClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +NetworkSecurityClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace networksecurity_v1 } // namespace cloud diff --git a/google/cloud/networksecurity/v1/network_security_client.h b/google/cloud/networksecurity/v1/network_security_client.h index c501fa7d6f8b6..5b8cb593c5f7c 100644 --- a/google/cloud/networksecurity/v1/network_security_client.h +++ b/google/cloud/networksecurity/v1/network_security_client.h @@ -1613,6 +1613,178 @@ class NetworkSecurityClient { DeleteClientTlsPolicy(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/networksecurity/v1/network_security_connection.cc b/google/cloud/networksecurity/v1/network_security_connection.cc index 982f28cf84c1a..703359ea6b1c6 100644 --- a/google/cloud/networksecurity/v1/network_security_connection.cc +++ b/google/cloud/networksecurity/v1/network_security_connection.cc @@ -299,6 +299,36 @@ NetworkSecurityConnection::DeleteClientTlsPolicy( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +NetworkSecurityConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +NetworkSecurityConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr NetworkSecurityConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr NetworkSecurityConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +NetworkSecurityConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeNetworkSecurityConnection( Options options) { internal::CheckExpectedOptions #include #include +#include #include #include @@ -339,6 +341,21 @@ class NetworkSecurityConnection { virtual future< StatusOr> DeleteClientTlsPolicy(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/networksecurity/v1/network_security_connection_idempotency_policy.cc b/google/cloud/networksecurity/v1/network_security_connection_idempotency_policy.cc index a7017bffd047a..141b270713ff7 100644 --- a/google/cloud/networksecurity/v1/network_security_connection_idempotency_policy.cc +++ b/google/cloud/networksecurity/v1/network_security_connection_idempotency_policy.cc @@ -119,6 +119,32 @@ Idempotency NetworkSecurityConnectionIdempotencyPolicy::DeleteClientTlsPolicy( return Idempotency::kNonIdempotent; } +Idempotency NetworkSecurityConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency NetworkSecurityConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency NetworkSecurityConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency NetworkSecurityConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency NetworkSecurityConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultNetworkSecurityConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/networksecurity/v1/network_security_connection_idempotency_policy.h b/google/cloud/networksecurity/v1/network_security_connection_idempotency_policy.h index bdbf83ca62321..0647408149eef 100644 --- a/google/cloud/networksecurity/v1/network_security_connection_idempotency_policy.h +++ b/google/cloud/networksecurity/v1/network_security_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -94,6 +96,21 @@ class NetworkSecurityConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteClientTlsPolicy( google::cloud::networksecurity::v1::DeleteClientTlsPolicyRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/networkservices/BUILD.bazel b/google/cloud/networkservices/BUILD.bazel index 1f4c5e7f1660b..511b94d08e147 100644 --- a/google/cloud/networkservices/BUILD.bazel +++ b/google/cloud/networkservices/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/networkservices/v1:networkservices_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/networkservices/v1/dep_client.cc b/google/cloud/networkservices/v1/dep_client.cc index 83178f5cc12ea..ca38212c559d5 100644 --- a/google/cloud/networkservices/v1/dep_client.cc +++ b/google/cloud/networkservices/v1/dep_client.cc @@ -398,6 +398,37 @@ DepServiceClient::DeleteLbRouteExtension( return connection_->DeleteLbRouteExtension(operation); } +StreamRange DepServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr DepServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr DepServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr DepServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +DepServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace networkservices_v1 } // namespace cloud diff --git a/google/cloud/networkservices/v1/dep_client.h b/google/cloud/networkservices/v1/dep_client.h index 68ff9680a0467..48207192358b4 100644 --- a/google/cloud/networkservices/v1/dep_client.h +++ b/google/cloud/networkservices/v1/dep_client.h @@ -1107,6 +1107,178 @@ class DepServiceClient { DeleteLbRouteExtension(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/networkservices/v1/dep_connection.cc b/google/cloud/networkservices/v1/dep_connection.cc index df2c30127c1b7..c61d5590c8de5 100644 --- a/google/cloud/networkservices/v1/dep_connection.cc +++ b/google/cloud/networkservices/v1/dep_connection.cc @@ -213,6 +213,35 @@ DepServiceConnection::DeleteLbRouteExtension( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +DepServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr DepServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr DepServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr DepServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +DepServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeDepServiceConnection( Options options) { internal::CheckExpectedOptions #include +#include #include #include @@ -289,6 +291,21 @@ class DepServiceConnection { virtual future< StatusOr> DeleteLbRouteExtension(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/networkservices/v1/dep_connection_idempotency_policy.cc b/google/cloud/networkservices/v1/dep_connection_idempotency_policy.cc index 75af2aa7b69f5..775e71b43b539 100644 --- a/google/cloud/networkservices/v1/dep_connection_idempotency_policy.cc +++ b/google/cloud/networkservices/v1/dep_connection_idempotency_policy.cc @@ -89,6 +89,32 @@ Idempotency DepServiceConnectionIdempotencyPolicy::DeleteLbRouteExtension( return Idempotency::kNonIdempotent; } +Idempotency DepServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency DepServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DepServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency DepServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency DepServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultDepServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/networkservices/v1/dep_connection_idempotency_policy.h b/google/cloud/networkservices/v1/dep_connection_idempotency_policy.h index 14735be204cf3..6b07a3ba85127 100644 --- a/google/cloud/networkservices/v1/dep_connection_idempotency_policy.h +++ b/google/cloud/networkservices/v1/dep_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -74,6 +76,21 @@ class DepServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteLbRouteExtension( google::cloud::networkservices::v1::DeleteLbRouteExtensionRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/networkservices/v1/internal/dep_auth_decorator.cc b/google/cloud/networkservices/v1/internal/dep_auth_decorator.cc index 50d4801b24bb4..45ab96628be61 100644 --- a/google/cloud/networkservices/v1/internal/dep_auth_decorator.cc +++ b/google/cloud/networkservices/v1/internal/dep_auth_decorator.cc @@ -254,6 +254,48 @@ StatusOr DepServiceAuth::DeleteLbRouteExtension( return child_->DeleteLbRouteExtension(context, options, request); } +StatusOr +DepServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr DepServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr DepServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr DepServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +DepServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> DepServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networkservices/v1/internal/dep_auth_decorator.h b/google/cloud/networkservices/v1/internal/dep_auth_decorator.h index c60adff95e0fb..c362708280f97 100644 --- a/google/cloud/networkservices/v1/internal/dep_auth_decorator.h +++ b/google/cloud/networkservices/v1/internal/dep_auth_decorator.h @@ -138,6 +138,26 @@ class DepServiceAuth : public DepServiceStub { google::cloud::networkservices::v1::DeleteLbRouteExtensionRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/networkservices/v1/internal/dep_connection_impl.cc b/google/cloud/networkservices/v1/internal/dep_connection_impl.cc index 9715465c4fb51..83b06e91e7670 100644 --- a/google/cloud/networkservices/v1/internal/dep_connection_impl.cc +++ b/google/cloud/networkservices/v1/internal/dep_connection_impl.cc @@ -742,6 +742,94 @@ DepServiceConnectionImpl::DeleteLbRouteExtension( polling_policy(*current), __func__); } +StreamRange +DepServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +DepServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr DepServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr DepServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +DepServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace networkservices_v1_internal } // namespace cloud diff --git a/google/cloud/networkservices/v1/internal/dep_connection_impl.h b/google/cloud/networkservices/v1/internal/dep_connection_impl.h index 04a269f636e25..cbb9a2c606518 100644 --- a/google/cloud/networkservices/v1/internal/dep_connection_impl.h +++ b/google/cloud/networkservices/v1/internal/dep_connection_impl.h @@ -156,6 +156,21 @@ class DepServiceConnectionImpl DeleteLbRouteExtension( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/networkservices/v1/internal/dep_logging_decorator.cc b/google/cloud/networkservices/v1/internal/dep_logging_decorator.cc index 3536f17552b11..8d77df006d0b5 100644 --- a/google/cloud/networkservices/v1/internal/dep_logging_decorator.cc +++ b/google/cloud/networkservices/v1/internal/dep_logging_decorator.cc @@ -296,6 +296,63 @@ DepServiceLogging::DeleteLbRouteExtension( context, options, request, __func__, tracing_options_); } +StatusOr +DepServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DepServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DepServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr DepServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +DepServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> DepServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networkservices/v1/internal/dep_logging_decorator.h b/google/cloud/networkservices/v1/internal/dep_logging_decorator.h index 1afb12ada5b4a..e42c353c4b0f8 100644 --- a/google/cloud/networkservices/v1/internal/dep_logging_decorator.h +++ b/google/cloud/networkservices/v1/internal/dep_logging_decorator.h @@ -138,6 +138,26 @@ class DepServiceLogging : public DepServiceStub { google::cloud::networkservices::v1::DeleteLbRouteExtensionRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/networkservices/v1/internal/dep_metadata_decorator.cc b/google/cloud/networkservices/v1/internal/dep_metadata_decorator.cc index b83fcfa74149b..fc56da3e576a3 100644 --- a/google/cloud/networkservices/v1/internal/dep_metadata_decorator.cc +++ b/google/cloud/networkservices/v1/internal/dep_metadata_decorator.cc @@ -230,6 +230,51 @@ DepServiceMetadata::DeleteLbRouteExtension( return child_->DeleteLbRouteExtension(context, options, request); } +StatusOr +DepServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr DepServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr DepServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr DepServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +DepServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> DepServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networkservices/v1/internal/dep_metadata_decorator.h b/google/cloud/networkservices/v1/internal/dep_metadata_decorator.h index 89f0f03b3ca61..8b4194f9907aa 100644 --- a/google/cloud/networkservices/v1/internal/dep_metadata_decorator.h +++ b/google/cloud/networkservices/v1/internal/dep_metadata_decorator.h @@ -138,6 +138,26 @@ class DepServiceMetadata : public DepServiceStub { google::cloud::networkservices::v1::DeleteLbRouteExtensionRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/networkservices/v1/internal/dep_stub.cc b/google/cloud/networkservices/v1/internal/dep_stub.cc index 00eaa3f2bf99b..a075327a92a58 100644 --- a/google/cloud/networkservices/v1/internal/dep_stub.cc +++ b/google/cloud/networkservices/v1/internal/dep_stub.cc @@ -288,6 +288,64 @@ DefaultDepServiceStub::DeleteLbRouteExtension( return response; } +StatusOr +DefaultDepServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultDepServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultDepServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultDepServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultDepServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultDepServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networkservices/v1/internal/dep_stub.h b/google/cloud/networkservices/v1/internal/dep_stub.h index ca622555a7809..88ff6e96865bc 100644 --- a/google/cloud/networkservices/v1/internal/dep_stub.h +++ b/google/cloud/networkservices/v1/internal/dep_stub.h @@ -24,7 +24,11 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include +#include +#include #include #include #include @@ -142,6 +146,28 @@ class DepServiceStub { google::cloud::networkservices::v1::DeleteLbRouteExtensionRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -161,9 +187,15 @@ class DefaultDepServiceStub : public DepServiceStub { std::unique_ptr< google::cloud::networkservices::v1::DepService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListLbTrafficExtensions( @@ -264,6 +296,26 @@ class DefaultDepServiceStub : public DepServiceStub { google::cloud::networkservices::v1::DeleteLbRouteExtensionRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -279,6 +331,9 @@ class DefaultDepServiceStub : public DepServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/networkservices/v1/internal/dep_stub_factory.cc b/google/cloud/networkservices/v1/internal/dep_stub_factory.cc index aa80cddabdee1..c6a2d5c8b5fb2 100644 --- a/google/cloud/networkservices/v1/internal/dep_stub_factory.cc +++ b/google/cloud/networkservices/v1/internal/dep_stub_factory.cc @@ -28,7 +28,9 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultDepServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::networkservices::v1::DepService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/networkservices/v1/internal/dep_tracing_connection.cc b/google/cloud/networkservices/v1/internal/dep_tracing_connection.cc index c35f9152cf0c5..99f017236a52f 100644 --- a/google/cloud/networkservices/v1/internal/dep_tracing_connection.cc +++ b/google/cloud/networkservices/v1/internal/dep_tracing_connection.cc @@ -276,6 +276,51 @@ DepServiceTracingConnection::DeleteLbRouteExtension( child_->DeleteLbRouteExtension(operation)); } +StreamRange +DepServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "networkservices_v1::DepServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +DepServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "networkservices_v1::DepServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr DepServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "networkservices_v1::DepServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr DepServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "networkservices_v1::DepServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +DepServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "networkservices_v1::DepServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/networkservices/v1/internal/dep_tracing_connection.h b/google/cloud/networkservices/v1/internal/dep_tracing_connection.h index 847c410bed324..0fe7903577d97 100644 --- a/google/cloud/networkservices/v1/internal/dep_tracing_connection.h +++ b/google/cloud/networkservices/v1/internal/dep_tracing_connection.h @@ -144,6 +144,21 @@ class DepServiceTracingConnection DeleteLbRouteExtension( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/networkservices/v1/internal/dep_tracing_stub.cc b/google/cloud/networkservices/v1/internal/dep_tracing_stub.cc index 4b80b385b3324..31360d1487043 100644 --- a/google/cloud/networkservices/v1/internal/dep_tracing_stub.cc +++ b/google/cloud/networkservices/v1/internal/dep_tracing_stub.cc @@ -265,6 +265,63 @@ DepServiceTracingStub::DeleteLbRouteExtension( child_->DeleteLbRouteExtension(context, options, request)); } +StatusOr +DepServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkservices.v1.DepService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr DepServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkservices.v1.DepService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr DepServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkservices.v1.DepService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr DepServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkservices.v1.DepService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +DepServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkservices.v1.DepService", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> DepServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networkservices/v1/internal/dep_tracing_stub.h b/google/cloud/networkservices/v1/internal/dep_tracing_stub.h index 3464f1457778d..9d3cfccedb589 100644 --- a/google/cloud/networkservices/v1/internal/dep_tracing_stub.h +++ b/google/cloud/networkservices/v1/internal/dep_tracing_stub.h @@ -137,6 +137,26 @@ class DepServiceTracingStub : public DepServiceStub { google::cloud::networkservices::v1::DeleteLbRouteExtensionRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/networkservices/v1/internal/network_services_auth_decorator.cc b/google/cloud/networkservices/v1/internal/network_services_auth_decorator.cc index d0bfe4096753b..485e1b22f66cf 100644 --- a/google/cloud/networkservices/v1/internal/network_services_auth_decorator.cc +++ b/google/cloud/networkservices/v1/internal/network_services_auth_decorator.cc @@ -837,6 +837,48 @@ StatusOr NetworkServicesAuth::DeleteMesh( return child_->DeleteMesh(context, options, request); } +StatusOr +NetworkServicesAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr NetworkServicesAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr NetworkServicesAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr NetworkServicesAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +NetworkServicesAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> NetworkServicesAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networkservices/v1/internal/network_services_auth_decorator.h b/google/cloud/networkservices/v1/internal/network_services_auth_decorator.h index d7dd558bd8892..e4ec6330672ec 100644 --- a/google/cloud/networkservices/v1/internal/network_services_auth_decorator.h +++ b/google/cloud/networkservices/v1/internal/network_services_auth_decorator.h @@ -401,6 +401,26 @@ class NetworkServicesAuth : public NetworkServicesStub { google::cloud::networkservices::v1::DeleteMeshRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/networkservices/v1/internal/network_services_connection_impl.cc b/google/cloud/networkservices/v1/internal/network_services_connection_impl.cc index c31cd915f1c08..ddd20e5ea7e51 100644 --- a/google/cloud/networkservices/v1/internal/network_services_connection_impl.cc +++ b/google/cloud/networkservices/v1/internal/network_services_connection_impl.cc @@ -2647,6 +2647,94 @@ NetworkServicesConnectionImpl::DeleteMesh( polling_policy(*current), __func__); } +StreamRange +NetworkServicesConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +NetworkServicesConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr NetworkServicesConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr NetworkServicesConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +NetworkServicesConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace networkservices_v1_internal } // namespace cloud diff --git a/google/cloud/networkservices/v1/internal/network_services_connection_impl.h b/google/cloud/networkservices/v1/internal/network_services_connection_impl.h index f5189afa303e3..98476d735edb7 100644 --- a/google/cloud/networkservices/v1/internal/network_services_connection_impl.h +++ b/google/cloud/networkservices/v1/internal/network_services_connection_impl.h @@ -412,6 +412,21 @@ class NetworkServicesConnectionImpl future> DeleteMesh(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/networkservices/v1/internal/network_services_logging_decorator.cc b/google/cloud/networkservices/v1/internal/network_services_logging_decorator.cc index 12f93c5738a6e..5116ad97a68c8 100644 --- a/google/cloud/networkservices/v1/internal/network_services_logging_decorator.cc +++ b/google/cloud/networkservices/v1/internal/network_services_logging_decorator.cc @@ -993,6 +993,63 @@ StatusOr NetworkServicesLogging::DeleteMesh( context, options, request, __func__, tracing_options_); } +StatusOr +NetworkServicesLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr NetworkServicesLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr NetworkServicesLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr NetworkServicesLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +NetworkServicesLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> NetworkServicesLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networkservices/v1/internal/network_services_logging_decorator.h b/google/cloud/networkservices/v1/internal/network_services_logging_decorator.h index 1b2ea03b916aa..cc04fe5ed92ff 100644 --- a/google/cloud/networkservices/v1/internal/network_services_logging_decorator.h +++ b/google/cloud/networkservices/v1/internal/network_services_logging_decorator.h @@ -401,6 +401,26 @@ class NetworkServicesLogging : public NetworkServicesStub { google::cloud::networkservices::v1::DeleteMeshRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/networkservices/v1/internal/network_services_metadata_decorator.cc b/google/cloud/networkservices/v1/internal/network_services_metadata_decorator.cc index 8810709e3bf6b..f4932e19427d9 100644 --- a/google/cloud/networkservices/v1/internal/network_services_metadata_decorator.cc +++ b/google/cloud/networkservices/v1/internal/network_services_metadata_decorator.cc @@ -695,6 +695,52 @@ StatusOr NetworkServicesMetadata::DeleteMesh( return child_->DeleteMesh(context, options, request); } +StatusOr +NetworkServicesMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +NetworkServicesMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr NetworkServicesMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr NetworkServicesMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +NetworkServicesMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> NetworkServicesMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networkservices/v1/internal/network_services_metadata_decorator.h b/google/cloud/networkservices/v1/internal/network_services_metadata_decorator.h index 63c36e9884617..56462ca4af0b7 100644 --- a/google/cloud/networkservices/v1/internal/network_services_metadata_decorator.h +++ b/google/cloud/networkservices/v1/internal/network_services_metadata_decorator.h @@ -402,6 +402,26 @@ class NetworkServicesMetadata : public NetworkServicesStub { google::cloud::networkservices::v1::DeleteMeshRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/networkservices/v1/internal/network_services_stub.cc b/google/cloud/networkservices/v1/internal/network_services_stub.cc index ed3390f6e30c8..7b8628ea18ba5 100644 --- a/google/cloud/networkservices/v1/internal/network_services_stub.cc +++ b/google/cloud/networkservices/v1/internal/network_services_stub.cc @@ -952,6 +952,65 @@ StatusOr DefaultNetworkServicesStub::DeleteMesh( return response; } +StatusOr +DefaultNetworkServicesStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultNetworkServicesStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultNetworkServicesStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultNetworkServicesStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultNetworkServicesStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultNetworkServicesStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networkservices/v1/internal/network_services_stub.h b/google/cloud/networkservices/v1/internal/network_services_stub.h index 5d6e2a36b9c9d..3b6f4a82abdaf 100644 --- a/google/cloud/networkservices/v1/internal/network_services_stub.h +++ b/google/cloud/networkservices/v1/internal/network_services_stub.h @@ -24,7 +24,11 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include +#include +#include #include #include #include @@ -399,6 +403,28 @@ class NetworkServicesStub { grpc::ClientContext& context, Options options, google::cloud::networkservices::v1::DeleteMeshRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -418,9 +444,15 @@ class DefaultNetworkServicesStub : public NetworkServicesStub { std::unique_ptr< google::cloud::networkservices::v1::NetworkServices::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListEndpointPolicies( @@ -784,6 +816,26 @@ class DefaultNetworkServicesStub : public NetworkServicesStub { google::cloud::networkservices::v1::DeleteMeshRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -800,6 +852,9 @@ class DefaultNetworkServicesStub : public NetworkServicesStub { std::unique_ptr< google::cloud::networkservices::v1::NetworkServices::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/networkservices/v1/internal/network_services_stub_factory.cc b/google/cloud/networkservices/v1/internal/network_services_stub_factory.cc index 6cb13c44a9116..eed7c5330333d 100644 --- a/google/cloud/networkservices/v1/internal/network_services_stub_factory.cc +++ b/google/cloud/networkservices/v1/internal/network_services_stub_factory.cc @@ -28,7 +28,9 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultNetworkServicesStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::networkservices::v1::NetworkServices::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/networkservices/v1/internal/network_services_tracing_connection.cc b/google/cloud/networkservices/v1/internal/network_services_tracing_connection.cc index 0314faedba991..3d943c6875210 100644 --- a/google/cloud/networkservices/v1/internal/network_services_tracing_connection.cc +++ b/google/cloud/networkservices/v1/internal/network_services_tracing_connection.cc @@ -883,6 +883,53 @@ NetworkServicesTracingConnection::DeleteMesh( return internal::EndSpan(std::move(span), child_->DeleteMesh(operation)); } +StreamRange +NetworkServicesTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "networkservices_v1::NetworkServicesConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +NetworkServicesTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "networkservices_v1::NetworkServicesConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +NetworkServicesTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "networkservices_v1::NetworkServicesConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +NetworkServicesTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "networkservices_v1::NetworkServicesConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +NetworkServicesTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "networkservices_v1::NetworkServicesConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/networkservices/v1/internal/network_services_tracing_connection.h b/google/cloud/networkservices/v1/internal/network_services_tracing_connection.h index 0f0839dd23d8b..10cc897fa787d 100644 --- a/google/cloud/networkservices/v1/internal/network_services_tracing_connection.h +++ b/google/cloud/networkservices/v1/internal/network_services_tracing_connection.h @@ -400,6 +400,21 @@ class NetworkServicesTracingConnection future> DeleteMesh(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/networkservices/v1/internal/network_services_tracing_stub.cc b/google/cloud/networkservices/v1/internal/network_services_tracing_stub.cc index e4b9405ae2b88..77d2da47f576d 100644 --- a/google/cloud/networkservices/v1/internal/network_services_tracing_stub.cc +++ b/google/cloud/networkservices/v1/internal/network_services_tracing_stub.cc @@ -861,6 +861,64 @@ StatusOr NetworkServicesTracingStub::DeleteMesh( child_->DeleteMesh(context, options, request)); } +StatusOr +NetworkServicesTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkservices.v1.NetworkServices", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +NetworkServicesTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkservices.v1.NetworkServices", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr NetworkServicesTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkservices.v1.NetworkServices", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr NetworkServicesTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkservices.v1.NetworkServices", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +NetworkServicesTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.networkservices.v1.NetworkServices", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> NetworkServicesTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/networkservices/v1/internal/network_services_tracing_stub.h b/google/cloud/networkservices/v1/internal/network_services_tracing_stub.h index fc38b40608af2..7580fc3412e1a 100644 --- a/google/cloud/networkservices/v1/internal/network_services_tracing_stub.h +++ b/google/cloud/networkservices/v1/internal/network_services_tracing_stub.h @@ -401,6 +401,26 @@ class NetworkServicesTracingStub : public NetworkServicesStub { google::cloud::networkservices::v1::DeleteMeshRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/networkservices/v1/mocks/mock_dep_connection.h b/google/cloud/networkservices/v1/mocks/mock_dep_connection.h index 8ae0fc92e2ac0..04e984d94e573 100644 --- a/google/cloud/networkservices/v1/mocks/mock_dep_connection.h +++ b/google/cloud/networkservices/v1/mocks/mock_dep_connection.h @@ -326,6 +326,27 @@ class MockDepServiceConnection future>, DeleteLbRouteExtension, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/networkservices/v1/mocks/mock_network_services_connection.h b/google/cloud/networkservices/v1/mocks/mock_network_services_connection.h index 3098833883baa..f4962c85da3b1 100644 --- a/google/cloud/networkservices/v1/mocks/mock_network_services_connection.h +++ b/google/cloud/networkservices/v1/mocks/mock_network_services_connection.h @@ -1056,6 +1056,27 @@ class MockNetworkServicesConnection future>, DeleteMesh, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/networkservices/v1/network_services_client.cc b/google/cloud/networkservices/v1/network_services_client.cc index 61930c80c933a..fd67671dc6b65 100644 --- a/google/cloud/networkservices/v1/network_services_client.cc +++ b/google/cloud/networkservices/v1/network_services_client.cc @@ -1319,6 +1319,38 @@ NetworkServicesClient::DeleteMesh( return connection_->DeleteMesh(operation); } +StreamRange +NetworkServicesClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr NetworkServicesClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr NetworkServicesClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr NetworkServicesClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +NetworkServicesClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace networkservices_v1 } // namespace cloud diff --git a/google/cloud/networkservices/v1/network_services_client.h b/google/cloud/networkservices/v1/network_services_client.h index a0e59cb708fbe..d8b2800605258 100644 --- a/google/cloud/networkservices/v1/network_services_client.h +++ b/google/cloud/networkservices/v1/network_services_client.h @@ -3891,6 +3891,178 @@ class NetworkServicesClient { DeleteMesh(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/networkservices/v1/network_services_connection.cc b/google/cloud/networkservices/v1/network_services_connection.cc index 76d4274fb8735..c2cbeb4d9349c 100644 --- a/google/cloud/networkservices/v1/network_services_connection.cc +++ b/google/cloud/networkservices/v1/network_services_connection.cc @@ -693,6 +693,36 @@ NetworkServicesConnection::DeleteMesh(google::longrunning::Operation const&) { Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +NetworkServicesConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +NetworkServicesConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr NetworkServicesConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr NetworkServicesConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +NetworkServicesConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeNetworkServicesConnection( Options options) { internal::CheckExpectedOptions #include +#include #include #include @@ -533,6 +535,21 @@ class NetworkServicesConnection { virtual future< StatusOr> DeleteMesh(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/networkservices/v1/network_services_connection_idempotency_policy.cc b/google/cloud/networkservices/v1/network_services_connection_idempotency_policy.cc index 19f28796735cd..6238fdbc989a3 100644 --- a/google/cloud/networkservices/v1/network_services_connection_idempotency_policy.cc +++ b/google/cloud/networkservices/v1/network_services_connection_idempotency_policy.cc @@ -230,6 +230,32 @@ Idempotency NetworkServicesConnectionIdempotencyPolicy::DeleteMesh( return Idempotency::kNonIdempotent; } +Idempotency NetworkServicesConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency NetworkServicesConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency NetworkServicesConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency NetworkServicesConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency NetworkServicesConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultNetworkServicesConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/networkservices/v1/network_services_connection_idempotency_policy.h b/google/cloud/networkservices/v1/network_services_connection_idempotency_policy.h index 0ff44ff9a6714..943a22baf00b5 100644 --- a/google/cloud/networkservices/v1/network_services_connection_idempotency_policy.h +++ b/google/cloud/networkservices/v1/network_services_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -166,6 +168,21 @@ class NetworkServicesConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteMesh( google::cloud::networkservices::v1::DeleteMeshRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/notebooks/BUILD.bazel b/google/cloud/notebooks/BUILD.bazel index a7ca423cce1f4..400a88263b5e2 100644 --- a/google/cloud/notebooks/BUILD.bazel +++ b/google/cloud/notebooks/BUILD.bazel @@ -27,6 +27,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/notebooks/v1:notebooks_cc_grpc", "@com_google_googleapis//google/cloud/notebooks/v2:notebooks_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/notebooks/v1/internal/managed_notebook_auth_decorator.cc b/google/cloud/notebooks/v1/internal/managed_notebook_auth_decorator.cc index a952bcbbb6f05..b6051b38238f0 100644 --- a/google/cloud/notebooks/v1/internal/managed_notebook_auth_decorator.cc +++ b/google/cloud/notebooks/v1/internal/managed_notebook_auth_decorator.cc @@ -349,6 +349,49 @@ ManagedNotebookServiceAuth::DiagnoseRuntime( return child_->DiagnoseRuntime(context, options, request); } +StatusOr +ManagedNotebookServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +ManagedNotebookServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr ManagedNotebookServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr ManagedNotebookServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +ManagedNotebookServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> ManagedNotebookServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/notebooks/v1/internal/managed_notebook_auth_decorator.h b/google/cloud/notebooks/v1/internal/managed_notebook_auth_decorator.h index 0cf2498cb4837..92fa6e8339396 100644 --- a/google/cloud/notebooks/v1/internal/managed_notebook_auth_decorator.h +++ b/google/cloud/notebooks/v1/internal/managed_notebook_auth_decorator.h @@ -172,6 +172,26 @@ class ManagedNotebookServiceAuth : public ManagedNotebookServiceStub { google::cloud::notebooks::v1::DiagnoseRuntimeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/notebooks/v1/internal/managed_notebook_connection_impl.cc b/google/cloud/notebooks/v1/internal/managed_notebook_connection_impl.cc index 231e5c5861542..5da02e132a28d 100644 --- a/google/cloud/notebooks/v1/internal/managed_notebook_connection_impl.cc +++ b/google/cloud/notebooks/v1/internal/managed_notebook_connection_impl.cc @@ -1041,6 +1041,96 @@ ManagedNotebookServiceConnectionImpl::DiagnoseRuntime( polling_policy(*current), __func__); } +StreamRange +ManagedNotebookServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ManagedNotebookServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +ManagedNotebookServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +ManagedNotebookServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +ManagedNotebookServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace notebooks_v1_internal } // namespace cloud diff --git a/google/cloud/notebooks/v1/internal/managed_notebook_connection_impl.h b/google/cloud/notebooks/v1/internal/managed_notebook_connection_impl.h index a3c4bb785e93d..bfdfc3d2027a2 100644 --- a/google/cloud/notebooks/v1/internal/managed_notebook_connection_impl.h +++ b/google/cloud/notebooks/v1/internal/managed_notebook_connection_impl.h @@ -181,6 +181,21 @@ class ManagedNotebookServiceConnectionImpl future> DiagnoseRuntime( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/notebooks/v1/internal/managed_notebook_logging_decorator.cc b/google/cloud/notebooks/v1/internal/managed_notebook_logging_decorator.cc index 7438367eceb92..c52e40136a972 100644 --- a/google/cloud/notebooks/v1/internal/managed_notebook_logging_decorator.cc +++ b/google/cloud/notebooks/v1/internal/managed_notebook_logging_decorator.cc @@ -387,6 +387,64 @@ ManagedNotebookServiceLogging::DiagnoseRuntime( context, options, request, __func__, tracing_options_); } +StatusOr +ManagedNotebookServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ManagedNotebookServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ManagedNotebookServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ManagedNotebookServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ManagedNotebookServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ManagedNotebookServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/notebooks/v1/internal/managed_notebook_logging_decorator.h b/google/cloud/notebooks/v1/internal/managed_notebook_logging_decorator.h index 9b47758f90239..66b2f15828540 100644 --- a/google/cloud/notebooks/v1/internal/managed_notebook_logging_decorator.h +++ b/google/cloud/notebooks/v1/internal/managed_notebook_logging_decorator.h @@ -172,6 +172,26 @@ class ManagedNotebookServiceLogging : public ManagedNotebookServiceStub { google::cloud::notebooks::v1::DiagnoseRuntimeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/notebooks/v1/internal/managed_notebook_metadata_decorator.cc b/google/cloud/notebooks/v1/internal/managed_notebook_metadata_decorator.cc index 632679f1dbc89..d12fae77c282b 100644 --- a/google/cloud/notebooks/v1/internal/managed_notebook_metadata_decorator.cc +++ b/google/cloud/notebooks/v1/internal/managed_notebook_metadata_decorator.cc @@ -284,6 +284,52 @@ ManagedNotebookServiceMetadata::DiagnoseRuntime( return child_->DiagnoseRuntime(context, options, request); } +StatusOr +ManagedNotebookServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +ManagedNotebookServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr ManagedNotebookServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr ManagedNotebookServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +ManagedNotebookServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> ManagedNotebookServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/notebooks/v1/internal/managed_notebook_metadata_decorator.h b/google/cloud/notebooks/v1/internal/managed_notebook_metadata_decorator.h index f3708d1358715..d4893b66aea37 100644 --- a/google/cloud/notebooks/v1/internal/managed_notebook_metadata_decorator.h +++ b/google/cloud/notebooks/v1/internal/managed_notebook_metadata_decorator.h @@ -173,6 +173,26 @@ class ManagedNotebookServiceMetadata : public ManagedNotebookServiceStub { google::cloud::notebooks::v1::DiagnoseRuntimeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/notebooks/v1/internal/managed_notebook_stub.cc b/google/cloud/notebooks/v1/internal/managed_notebook_stub.cc index 9a444927082ed..77c95695ee3ac 100644 --- a/google/cloud/notebooks/v1/internal/managed_notebook_stub.cc +++ b/google/cloud/notebooks/v1/internal/managed_notebook_stub.cc @@ -371,6 +371,67 @@ DefaultManagedNotebookServiceStub::DiagnoseRuntime( return response; } +StatusOr +DefaultManagedNotebookServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultManagedNotebookServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultManagedNotebookServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultManagedNotebookServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultManagedNotebookServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultManagedNotebookServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/notebooks/v1/internal/managed_notebook_stub.h b/google/cloud/notebooks/v1/internal/managed_notebook_stub.h index 37c1538f23c7a..ab061b7ee6bc1 100644 --- a/google/cloud/notebooks/v1/internal/managed_notebook_stub.h +++ b/google/cloud/notebooks/v1/internal/managed_notebook_stub.h @@ -24,8 +24,12 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include +#include +#include #include #include #include @@ -158,6 +162,28 @@ class ManagedNotebookServiceStub { grpc::ClientContext& context, Options options, google::cloud::notebooks::v1::DiagnoseRuntimeRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -177,9 +203,15 @@ class DefaultManagedNotebookServiceStub : public ManagedNotebookServiceStub { std::unique_ptr< google::cloud::notebooks::v1::ManagedNotebookService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListRuntimes( grpc::ClientContext& context, Options const& options, @@ -314,6 +346,26 @@ class DefaultManagedNotebookServiceStub : public ManagedNotebookServiceStub { google::cloud::notebooks::v1::DiagnoseRuntimeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -330,6 +382,9 @@ class DefaultManagedNotebookServiceStub : public ManagedNotebookServiceStub { std::unique_ptr< google::cloud::notebooks::v1::ManagedNotebookService::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/notebooks/v1/internal/managed_notebook_stub_factory.cc b/google/cloud/notebooks/v1/internal/managed_notebook_stub_factory.cc index 9223b43e9debc..9c9bca5d28d6d 100644 --- a/google/cloud/notebooks/v1/internal/managed_notebook_stub_factory.cc +++ b/google/cloud/notebooks/v1/internal/managed_notebook_stub_factory.cc @@ -28,7 +28,9 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include #include #include @@ -45,9 +47,13 @@ CreateDefaultManagedNotebookServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::notebooks::v1::ManagedNotebookService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/notebooks/v1/internal/managed_notebook_tracing_connection.cc b/google/cloud/notebooks/v1/internal/managed_notebook_tracing_connection.cc index 2e646de568938..2541e8a13b446 100644 --- a/google/cloud/notebooks/v1/internal/managed_notebook_tracing_connection.cc +++ b/google/cloud/notebooks/v1/internal/managed_notebook_tracing_connection.cc @@ -350,6 +350,53 @@ ManagedNotebookServiceTracingConnection::DiagnoseRuntime( return internal::EndSpan(std::move(span), child_->DiagnoseRuntime(operation)); } +StreamRange +ManagedNotebookServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "notebooks_v1::ManagedNotebookServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ManagedNotebookServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "notebooks_v1::ManagedNotebookServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +ManagedNotebookServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "notebooks_v1::ManagedNotebookServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +ManagedNotebookServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "notebooks_v1::ManagedNotebookServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +ManagedNotebookServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "notebooks_v1::ManagedNotebookServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/notebooks/v1/internal/managed_notebook_tracing_connection.h b/google/cloud/notebooks/v1/internal/managed_notebook_tracing_connection.h index 2e941824b230b..7e8cb6365857a 100644 --- a/google/cloud/notebooks/v1/internal/managed_notebook_tracing_connection.h +++ b/google/cloud/notebooks/v1/internal/managed_notebook_tracing_connection.h @@ -169,6 +169,21 @@ class ManagedNotebookServiceTracingConnection future> DiagnoseRuntime( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/notebooks/v1/internal/managed_notebook_tracing_stub.cc b/google/cloud/notebooks/v1/internal/managed_notebook_tracing_stub.cc index 511841efd855a..5311ea0d6452d 100644 --- a/google/cloud/notebooks/v1/internal/managed_notebook_tracing_stub.cc +++ b/google/cloud/notebooks/v1/internal/managed_notebook_tracing_stub.cc @@ -334,6 +334,66 @@ ManagedNotebookServiceTracingStub::DiagnoseRuntime( child_->DiagnoseRuntime(context, options, request)); } +StatusOr +ManagedNotebookServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v1.ManagedNotebookService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +ManagedNotebookServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v1.ManagedNotebookService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr +ManagedNotebookServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v1.ManagedNotebookService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr +ManagedNotebookServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v1.ManagedNotebookService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +ManagedNotebookServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v1.ManagedNotebookService", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> ManagedNotebookServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/notebooks/v1/internal/managed_notebook_tracing_stub.h b/google/cloud/notebooks/v1/internal/managed_notebook_tracing_stub.h index 86cbc4caadd87..b1fc8ae716e07 100644 --- a/google/cloud/notebooks/v1/internal/managed_notebook_tracing_stub.h +++ b/google/cloud/notebooks/v1/internal/managed_notebook_tracing_stub.h @@ -172,6 +172,26 @@ class ManagedNotebookServiceTracingStub : public ManagedNotebookServiceStub { google::cloud::notebooks::v1::DiagnoseRuntimeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/notebooks/v1/internal/notebook_auth_decorator.cc b/google/cloud/notebooks/v1/internal/notebook_auth_decorator.cc index ae0efae7109fe..bcb5a13013479 100644 --- a/google/cloud/notebooks/v1/internal/notebook_auth_decorator.cc +++ b/google/cloud/notebooks/v1/internal/notebook_auth_decorator.cc @@ -789,6 +789,48 @@ StatusOr NotebookServiceAuth::CreateExecution( return child_->CreateExecution(context, options, request); } +StatusOr +NotebookServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr NotebookServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr NotebookServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr NotebookServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +NotebookServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> NotebookServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/notebooks/v1/internal/notebook_auth_decorator.h b/google/cloud/notebooks/v1/internal/notebook_auth_decorator.h index 0922a95719c33..d2c0480032e49 100644 --- a/google/cloud/notebooks/v1/internal/notebook_auth_decorator.h +++ b/google/cloud/notebooks/v1/internal/notebook_auth_decorator.h @@ -372,6 +372,26 @@ class NotebookServiceAuth : public NotebookServiceStub { google::cloud::notebooks::v1::CreateExecutionRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/notebooks/v1/internal/notebook_connection_impl.cc b/google/cloud/notebooks/v1/internal/notebook_connection_impl.cc index d246d99f9f44e..3f335138af678 100644 --- a/google/cloud/notebooks/v1/internal/notebook_connection_impl.cc +++ b/google/cloud/notebooks/v1/internal/notebook_connection_impl.cc @@ -2421,6 +2421,94 @@ NotebookServiceConnectionImpl::CreateExecution( polling_policy(*current), __func__); } +StreamRange +NotebookServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +NotebookServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr NotebookServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr NotebookServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +NotebookServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace notebooks_v1_internal } // namespace cloud diff --git a/google/cloud/notebooks/v1/internal/notebook_connection_impl.h b/google/cloud/notebooks/v1/internal/notebook_connection_impl.h index 56d6b982e5d1d..cc2859a77cd1f 100644 --- a/google/cloud/notebooks/v1/internal/notebook_connection_impl.h +++ b/google/cloud/notebooks/v1/internal/notebook_connection_impl.h @@ -378,6 +378,21 @@ class NotebookServiceConnectionImpl future> CreateExecution( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/notebooks/v1/internal/notebook_logging_decorator.cc b/google/cloud/notebooks/v1/internal/notebook_logging_decorator.cc index d8ec3d00fb4c0..5cbdf0e473de0 100644 --- a/google/cloud/notebooks/v1/internal/notebook_logging_decorator.cc +++ b/google/cloud/notebooks/v1/internal/notebook_logging_decorator.cc @@ -911,6 +911,63 @@ NotebookServiceLogging::CreateExecution( context, options, request, __func__, tracing_options_); } +StatusOr +NotebookServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr NotebookServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr NotebookServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr NotebookServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +NotebookServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> NotebookServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/notebooks/v1/internal/notebook_logging_decorator.h b/google/cloud/notebooks/v1/internal/notebook_logging_decorator.h index db9e201ab3c61..d220a2acea0e3 100644 --- a/google/cloud/notebooks/v1/internal/notebook_logging_decorator.h +++ b/google/cloud/notebooks/v1/internal/notebook_logging_decorator.h @@ -372,6 +372,26 @@ class NotebookServiceLogging : public NotebookServiceStub { google::cloud::notebooks::v1::CreateExecutionRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/notebooks/v1/internal/notebook_metadata_decorator.cc b/google/cloud/notebooks/v1/internal/notebook_metadata_decorator.cc index 453ba1aae81d8..2c973eb72ba58 100644 --- a/google/cloud/notebooks/v1/internal/notebook_metadata_decorator.cc +++ b/google/cloud/notebooks/v1/internal/notebook_metadata_decorator.cc @@ -633,6 +633,52 @@ NotebookServiceMetadata::CreateExecution( return child_->CreateExecution(context, options, request); } +StatusOr +NotebookServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +NotebookServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr NotebookServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr NotebookServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +NotebookServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> NotebookServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/notebooks/v1/internal/notebook_metadata_decorator.h b/google/cloud/notebooks/v1/internal/notebook_metadata_decorator.h index ccf7316c8b8f1..3fd69d256fc75 100644 --- a/google/cloud/notebooks/v1/internal/notebook_metadata_decorator.h +++ b/google/cloud/notebooks/v1/internal/notebook_metadata_decorator.h @@ -373,6 +373,26 @@ class NotebookServiceMetadata : public NotebookServiceStub { google::cloud::notebooks::v1::CreateExecutionRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/notebooks/v1/internal/notebook_stub.cc b/google/cloud/notebooks/v1/internal/notebook_stub.cc index 520dd72b734f0..e069994bdda6e 100644 --- a/google/cloud/notebooks/v1/internal/notebook_stub.cc +++ b/google/cloud/notebooks/v1/internal/notebook_stub.cc @@ -884,6 +884,65 @@ DefaultNotebookServiceStub::CreateExecution( return response; } +StatusOr +DefaultNotebookServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultNotebookServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultNotebookServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultNotebookServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultNotebookServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultNotebookServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/notebooks/v1/internal/notebook_stub.h b/google/cloud/notebooks/v1/internal/notebook_stub.h index 118f508800fe4..34652ecdcc7cf 100644 --- a/google/cloud/notebooks/v1/internal/notebook_stub.h +++ b/google/cloud/notebooks/v1/internal/notebook_stub.h @@ -24,8 +24,12 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include +#include +#include #include #include #include @@ -354,6 +358,28 @@ class NotebookServiceStub { grpc::ClientContext& context, Options options, google::cloud::notebooks::v1::CreateExecutionRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -373,9 +399,15 @@ class DefaultNotebookServiceStub : public NotebookServiceStub { std::unique_ptr< google::cloud::notebooks::v1::NotebookService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListInstances( grpc::ClientContext& context, Options const& options, @@ -710,6 +742,26 @@ class DefaultNotebookServiceStub : public NotebookServiceStub { google::cloud::notebooks::v1::CreateExecutionRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -725,6 +777,9 @@ class DefaultNotebookServiceStub : public NotebookServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/notebooks/v1/internal/notebook_stub_factory.cc b/google/cloud/notebooks/v1/internal/notebook_stub_factory.cc index 2b80c44303718..4599f589d0148 100644 --- a/google/cloud/notebooks/v1/internal/notebook_stub_factory.cc +++ b/google/cloud/notebooks/v1/internal/notebook_stub_factory.cc @@ -28,7 +28,9 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultNotebookServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::notebooks::v1::NotebookService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/notebooks/v1/internal/notebook_tracing_connection.cc b/google/cloud/notebooks/v1/internal/notebook_tracing_connection.cc index d7c6a4e97dec5..8e0ef32937f00 100644 --- a/google/cloud/notebooks/v1/internal/notebook_tracing_connection.cc +++ b/google/cloud/notebooks/v1/internal/notebook_tracing_connection.cc @@ -832,6 +832,53 @@ NotebookServiceTracingConnection::CreateExecution( return internal::EndSpan(std::move(span), child_->CreateExecution(operation)); } +StreamRange +NotebookServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "notebooks_v1::NotebookServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +NotebookServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "notebooks_v1::NotebookServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +NotebookServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "notebooks_v1::NotebookServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +NotebookServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "notebooks_v1::NotebookServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +NotebookServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "notebooks_v1::NotebookServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/notebooks/v1/internal/notebook_tracing_connection.h b/google/cloud/notebooks/v1/internal/notebook_tracing_connection.h index f2b3ed7f131ce..719a7ef58d058 100644 --- a/google/cloud/notebooks/v1/internal/notebook_tracing_connection.h +++ b/google/cloud/notebooks/v1/internal/notebook_tracing_connection.h @@ -366,6 +366,21 @@ class NotebookServiceTracingConnection future> CreateExecution( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/notebooks/v1/internal/notebook_tracing_stub.cc b/google/cloud/notebooks/v1/internal/notebook_tracing_stub.cc index 31ba3e5b7872b..e3f6ed0a2ed85 100644 --- a/google/cloud/notebooks/v1/internal/notebook_tracing_stub.cc +++ b/google/cloud/notebooks/v1/internal/notebook_tracing_stub.cc @@ -799,6 +799,64 @@ NotebookServiceTracingStub::CreateExecution( child_->CreateExecution(context, options, request)); } +StatusOr +NotebookServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v1.NotebookService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +NotebookServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v1.NotebookService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr NotebookServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v1.NotebookService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr NotebookServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v1.NotebookService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +NotebookServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v1.NotebookService", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> NotebookServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/notebooks/v1/internal/notebook_tracing_stub.h b/google/cloud/notebooks/v1/internal/notebook_tracing_stub.h index ce23998931fd5..510076e063b7d 100644 --- a/google/cloud/notebooks/v1/internal/notebook_tracing_stub.h +++ b/google/cloud/notebooks/v1/internal/notebook_tracing_stub.h @@ -372,6 +372,26 @@ class NotebookServiceTracingStub : public NotebookServiceStub { google::cloud::notebooks::v1::CreateExecutionRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/notebooks/v1/managed_notebook_client.cc b/google/cloud/notebooks/v1/managed_notebook_client.cc index e177f745f8865..4c0231d8df0e5 100644 --- a/google/cloud/notebooks/v1/managed_notebook_client.cc +++ b/google/cloud/notebooks/v1/managed_notebook_client.cc @@ -521,6 +521,39 @@ ManagedNotebookServiceClient::DiagnoseRuntime( return connection_->DiagnoseRuntime(operation); } +StreamRange +ManagedNotebookServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +ManagedNotebookServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr ManagedNotebookServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr ManagedNotebookServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +ManagedNotebookServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace notebooks_v1 } // namespace cloud diff --git a/google/cloud/notebooks/v1/managed_notebook_client.h b/google/cloud/notebooks/v1/managed_notebook_client.h index fae8facf74802..f2b876966605e 100644 --- a/google/cloud/notebooks/v1/managed_notebook_client.h +++ b/google/cloud/notebooks/v1/managed_notebook_client.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -1456,6 +1457,178 @@ class ManagedNotebookServiceClient { future> DiagnoseRuntime( google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/notebooks/v1/managed_notebook_connection.cc b/google/cloud/notebooks/v1/managed_notebook_connection.cc index be2683eb765ee..df51bb9727fc3 100644 --- a/google/cloud/notebooks/v1/managed_notebook_connection.cc +++ b/google/cloud/notebooks/v1/managed_notebook_connection.cc @@ -289,6 +289,38 @@ ManagedNotebookServiceConnection::DiagnoseRuntime( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +ManagedNotebookServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +ManagedNotebookServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +ManagedNotebookServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +ManagedNotebookServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +ManagedNotebookServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeManagedNotebookServiceConnection(Options options) { internal::CheckExpectedOptions #include #include +#include #include #include @@ -308,6 +310,21 @@ class ManagedNotebookServiceConnection { virtual future> DiagnoseRuntime(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/notebooks/v1/managed_notebook_connection_idempotency_policy.cc b/google/cloud/notebooks/v1/managed_notebook_connection_idempotency_policy.cc index b79a6b330c63a..c5d8dec1b8527 100644 --- a/google/cloud/notebooks/v1/managed_notebook_connection_idempotency_policy.cc +++ b/google/cloud/notebooks/v1/managed_notebook_connection_idempotency_policy.cc @@ -102,6 +102,33 @@ Idempotency ManagedNotebookServiceConnectionIdempotencyPolicy::DiagnoseRuntime( return Idempotency::kNonIdempotent; } +Idempotency ManagedNotebookServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ManagedNotebookServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ManagedNotebookServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency ManagedNotebookServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +ManagedNotebookServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultManagedNotebookServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/notebooks/v1/managed_notebook_connection_idempotency_policy.h b/google/cloud/notebooks/v1/managed_notebook_connection_idempotency_policy.h index 62403b689e839..de07a8be1fb11 100644 --- a/google/cloud/notebooks/v1/managed_notebook_connection_idempotency_policy.h +++ b/google/cloud/notebooks/v1/managed_notebook_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -76,6 +78,21 @@ class ManagedNotebookServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DiagnoseRuntime( google::cloud::notebooks::v1::DiagnoseRuntimeRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/notebooks/v1/mocks/mock_managed_notebook_connection.h b/google/cloud/notebooks/v1/mocks/mock_managed_notebook_connection.h index fad7fa8add286..a9935ce0556b4 100644 --- a/google/cloud/notebooks/v1/mocks/mock_managed_notebook_connection.h +++ b/google/cloud/notebooks/v1/mocks/mock_managed_notebook_connection.h @@ -444,6 +444,27 @@ class MockManagedNotebookServiceConnection MOCK_METHOD(future>, DiagnoseRuntime, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/notebooks/v1/mocks/mock_notebook_connection.h b/google/cloud/notebooks/v1/mocks/mock_notebook_connection.h index 586ebfcc8b57b..7f8a3f2cf0b94 100644 --- a/google/cloud/notebooks/v1/mocks/mock_notebook_connection.h +++ b/google/cloud/notebooks/v1/mocks/mock_notebook_connection.h @@ -1005,6 +1005,27 @@ class MockNotebookServiceConnection MOCK_METHOD(future>, CreateExecution, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/notebooks/v1/notebook_client.cc b/google/cloud/notebooks/v1/notebook_client.cc index ff1ea48f86faf..7b366547eb92a 100644 --- a/google/cloud/notebooks/v1/notebook_client.cc +++ b/google/cloud/notebooks/v1/notebook_client.cc @@ -926,6 +926,38 @@ NotebookServiceClient::CreateExecution( return connection_->CreateExecution(operation); } +StreamRange +NotebookServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr NotebookServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr NotebookServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr NotebookServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +NotebookServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace notebooks_v1 } // namespace cloud diff --git a/google/cloud/notebooks/v1/notebook_client.h b/google/cloud/notebooks/v1/notebook_client.h index ebe20165ab155..3d509f2352edf 100644 --- a/google/cloud/notebooks/v1/notebook_client.h +++ b/google/cloud/notebooks/v1/notebook_client.h @@ -2741,6 +2741,178 @@ class NotebookServiceClient { future> CreateExecution( google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/notebooks/v1/notebook_connection.cc b/google/cloud/notebooks/v1/notebook_connection.cc index 0f8413a6ae4b9..0e53f3e526a90 100644 --- a/google/cloud/notebooks/v1/notebook_connection.cc +++ b/google/cloud/notebooks/v1/notebook_connection.cc @@ -646,6 +646,36 @@ NotebookServiceConnection::CreateExecution( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +NotebookServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +NotebookServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr NotebookServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr NotebookServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +NotebookServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeNotebookServiceConnection( Options options) { internal::CheckExpectedOptions #include +#include #include #include @@ -486,6 +488,21 @@ class NotebookServiceConnection { virtual future> CreateExecution(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/notebooks/v1/notebook_connection_idempotency_policy.cc b/google/cloud/notebooks/v1/notebook_connection_idempotency_policy.cc index d3d83a43a4d97..de82d2b5313c0 100644 --- a/google/cloud/notebooks/v1/notebook_connection_idempotency_policy.cc +++ b/google/cloud/notebooks/v1/notebook_connection_idempotency_policy.cc @@ -206,6 +206,32 @@ Idempotency NotebookServiceConnectionIdempotencyPolicy::CreateExecution( return Idempotency::kNonIdempotent; } +Idempotency NotebookServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency NotebookServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency NotebookServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency NotebookServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency NotebookServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultNotebookServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/notebooks/v1/notebook_connection_idempotency_policy.h b/google/cloud/notebooks/v1/notebook_connection_idempotency_policy.h index 2e75ef7cefec9..70c93b12742ac 100644 --- a/google/cloud/notebooks/v1/notebook_connection_idempotency_policy.h +++ b/google/cloud/notebooks/v1/notebook_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -144,6 +146,21 @@ class NotebookServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency CreateExecution( google::cloud::notebooks::v1::CreateExecutionRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/notebooks/v2/internal/notebook_auth_decorator.cc b/google/cloud/notebooks/v2/internal/notebook_auth_decorator.cc index 518a0f36bab04..cfe5b2775c529 100644 --- a/google/cloud/notebooks/v2/internal/notebook_auth_decorator.cc +++ b/google/cloud/notebooks/v2/internal/notebook_auth_decorator.cc @@ -311,6 +311,48 @@ StatusOr NotebookServiceAuth::DiagnoseInstance( return child_->DiagnoseInstance(context, options, request); } +StatusOr +NotebookServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr NotebookServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr NotebookServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr NotebookServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +NotebookServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> NotebookServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/notebooks/v2/internal/notebook_auth_decorator.h b/google/cloud/notebooks/v2/internal/notebook_auth_decorator.h index 271f9f3072d2a..1d1402f3c0146 100644 --- a/google/cloud/notebooks/v2/internal/notebook_auth_decorator.h +++ b/google/cloud/notebooks/v2/internal/notebook_auth_decorator.h @@ -162,6 +162,26 @@ class NotebookServiceAuth : public NotebookServiceStub { google::cloud::notebooks::v2::DiagnoseInstanceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/notebooks/v2/internal/notebook_connection_impl.cc b/google/cloud/notebooks/v2/internal/notebook_connection_impl.cc index fb818d5a717ea..b1f5c1ff60a67 100644 --- a/google/cloud/notebooks/v2/internal/notebook_connection_impl.cc +++ b/google/cloud/notebooks/v2/internal/notebook_connection_impl.cc @@ -952,6 +952,94 @@ NotebookServiceConnectionImpl::DiagnoseInstance( polling_policy(*current), __func__); } +StreamRange +NotebookServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +NotebookServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr NotebookServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr NotebookServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +NotebookServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace notebooks_v2_internal } // namespace cloud diff --git a/google/cloud/notebooks/v2/internal/notebook_connection_impl.h b/google/cloud/notebooks/v2/internal/notebook_connection_impl.h index a2b28e022c38a..3e9a5e5ae99e4 100644 --- a/google/cloud/notebooks/v2/internal/notebook_connection_impl.h +++ b/google/cloud/notebooks/v2/internal/notebook_connection_impl.h @@ -171,6 +171,21 @@ class NotebookServiceConnectionImpl future> DiagnoseInstance( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/notebooks/v2/internal/notebook_logging_decorator.cc b/google/cloud/notebooks/v2/internal/notebook_logging_decorator.cc index aec741f5b42ed..4b1ad673a2f2c 100644 --- a/google/cloud/notebooks/v2/internal/notebook_logging_decorator.cc +++ b/google/cloud/notebooks/v2/internal/notebook_logging_decorator.cc @@ -355,6 +355,63 @@ NotebookServiceLogging::DiagnoseInstance( context, options, request, __func__, tracing_options_); } +StatusOr +NotebookServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr NotebookServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr NotebookServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr NotebookServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +NotebookServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> NotebookServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/notebooks/v2/internal/notebook_logging_decorator.h b/google/cloud/notebooks/v2/internal/notebook_logging_decorator.h index b3cb53af1029d..82d7a4a2d418b 100644 --- a/google/cloud/notebooks/v2/internal/notebook_logging_decorator.h +++ b/google/cloud/notebooks/v2/internal/notebook_logging_decorator.h @@ -162,6 +162,26 @@ class NotebookServiceLogging : public NotebookServiceStub { google::cloud::notebooks::v2::DiagnoseInstanceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/notebooks/v2/internal/notebook_metadata_decorator.cc b/google/cloud/notebooks/v2/internal/notebook_metadata_decorator.cc index f8fd5b2dad9e8..8c699a469b24d 100644 --- a/google/cloud/notebooks/v2/internal/notebook_metadata_decorator.cc +++ b/google/cloud/notebooks/v2/internal/notebook_metadata_decorator.cc @@ -261,6 +261,52 @@ NotebookServiceMetadata::DiagnoseInstance( return child_->DiagnoseInstance(context, options, request); } +StatusOr +NotebookServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +NotebookServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr NotebookServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr NotebookServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +NotebookServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> NotebookServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/notebooks/v2/internal/notebook_metadata_decorator.h b/google/cloud/notebooks/v2/internal/notebook_metadata_decorator.h index 7e2da0993797f..6cf36cffcfdeb 100644 --- a/google/cloud/notebooks/v2/internal/notebook_metadata_decorator.h +++ b/google/cloud/notebooks/v2/internal/notebook_metadata_decorator.h @@ -163,6 +163,26 @@ class NotebookServiceMetadata : public NotebookServiceStub { google::cloud::notebooks::v2::DiagnoseInstanceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/notebooks/v2/internal/notebook_stub.cc b/google/cloud/notebooks/v2/internal/notebook_stub.cc index 975557a40c21e..7d98548d034cf 100644 --- a/google/cloud/notebooks/v2/internal/notebook_stub.cc +++ b/google/cloud/notebooks/v2/internal/notebook_stub.cc @@ -342,6 +342,65 @@ DefaultNotebookServiceStub::DiagnoseInstance( return response; } +StatusOr +DefaultNotebookServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultNotebookServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultNotebookServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultNotebookServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultNotebookServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultNotebookServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/notebooks/v2/internal/notebook_stub.h b/google/cloud/notebooks/v2/internal/notebook_stub.h index 992c8e7dee9ea..b977a7d045652 100644 --- a/google/cloud/notebooks/v2/internal/notebook_stub.h +++ b/google/cloud/notebooks/v2/internal/notebook_stub.h @@ -24,7 +24,11 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include +#include +#include #include #include #include @@ -146,6 +150,28 @@ class NotebookServiceStub { grpc::ClientContext& context, Options options, google::cloud::notebooks::v2::DiagnoseInstanceRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -165,9 +191,15 @@ class DefaultNotebookServiceStub : public NotebookServiceStub { std::unique_ptr< google::cloud::notebooks::v2::NotebookService::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListInstances( grpc::ClientContext& context, Options const& options, @@ -292,6 +324,26 @@ class DefaultNotebookServiceStub : public NotebookServiceStub { google::cloud::notebooks::v2::DiagnoseInstanceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -307,6 +359,9 @@ class DefaultNotebookServiceStub : public NotebookServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/notebooks/v2/internal/notebook_stub_factory.cc b/google/cloud/notebooks/v2/internal/notebook_stub_factory.cc index 7df61792b8c31..636f7b29762aa 100644 --- a/google/cloud/notebooks/v2/internal/notebook_stub_factory.cc +++ b/google/cloud/notebooks/v2/internal/notebook_stub_factory.cc @@ -28,7 +28,9 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultNotebookServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::notebooks::v2::NotebookService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/notebooks/v2/internal/notebook_tracing_connection.cc b/google/cloud/notebooks/v2/internal/notebook_tracing_connection.cc index 89b82dae0eda2..e950bbcf7f503 100644 --- a/google/cloud/notebooks/v2/internal/notebook_tracing_connection.cc +++ b/google/cloud/notebooks/v2/internal/notebook_tracing_connection.cc @@ -323,6 +323,53 @@ NotebookServiceTracingConnection::DiagnoseInstance( child_->DiagnoseInstance(operation)); } +StreamRange +NotebookServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "notebooks_v2::NotebookServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +NotebookServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "notebooks_v2::NotebookServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +NotebookServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "notebooks_v2::NotebookServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +NotebookServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "notebooks_v2::NotebookServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +NotebookServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "notebooks_v2::NotebookServiceConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/notebooks/v2/internal/notebook_tracing_connection.h b/google/cloud/notebooks/v2/internal/notebook_tracing_connection.h index bb28d9d8f10d9..c77b89f32775a 100644 --- a/google/cloud/notebooks/v2/internal/notebook_tracing_connection.h +++ b/google/cloud/notebooks/v2/internal/notebook_tracing_connection.h @@ -159,6 +159,21 @@ class NotebookServiceTracingConnection future> DiagnoseInstance( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/notebooks/v2/internal/notebook_tracing_stub.cc b/google/cloud/notebooks/v2/internal/notebook_tracing_stub.cc index c44b8ba1a5559..1316d6ec5e293 100644 --- a/google/cloud/notebooks/v2/internal/notebook_tracing_stub.cc +++ b/google/cloud/notebooks/v2/internal/notebook_tracing_stub.cc @@ -311,6 +311,64 @@ NotebookServiceTracingStub::DiagnoseInstance( child_->DiagnoseInstance(context, options, request)); } +StatusOr +NotebookServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v2.NotebookService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +NotebookServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v2.NotebookService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr NotebookServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v2.NotebookService", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr NotebookServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v2.NotebookService", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +NotebookServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.notebooks.v2.NotebookService", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> NotebookServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/notebooks/v2/internal/notebook_tracing_stub.h b/google/cloud/notebooks/v2/internal/notebook_tracing_stub.h index ff0871993a26b..c1aafd77a48fa 100644 --- a/google/cloud/notebooks/v2/internal/notebook_tracing_stub.h +++ b/google/cloud/notebooks/v2/internal/notebook_tracing_stub.h @@ -162,6 +162,26 @@ class NotebookServiceTracingStub : public NotebookServiceStub { google::cloud::notebooks::v2::DiagnoseInstanceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/notebooks/v2/mocks/mock_notebook_connection.h b/google/cloud/notebooks/v2/mocks/mock_notebook_connection.h index 61120b7ca7431..443c9a0722de8 100644 --- a/google/cloud/notebooks/v2/mocks/mock_notebook_connection.h +++ b/google/cloud/notebooks/v2/mocks/mock_notebook_connection.h @@ -408,6 +408,27 @@ class MockNotebookServiceConnection MOCK_METHOD(future>, DiagnoseInstance, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/notebooks/v2/notebook_client.cc b/google/cloud/notebooks/v2/notebook_client.cc index ddf0b9333e721..a06d3e9be8816 100644 --- a/google/cloud/notebooks/v2/notebook_client.cc +++ b/google/cloud/notebooks/v2/notebook_client.cc @@ -367,6 +367,38 @@ NotebookServiceClient::DiagnoseInstance( return connection_->DiagnoseInstance(operation); } +StreamRange +NotebookServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr NotebookServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr NotebookServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr NotebookServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +NotebookServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace notebooks_v2 } // namespace cloud diff --git a/google/cloud/notebooks/v2/notebook_client.h b/google/cloud/notebooks/v2/notebook_client.h index ee1b41f95bab7..1d0ef7902dbd7 100644 --- a/google/cloud/notebooks/v2/notebook_client.h +++ b/google/cloud/notebooks/v2/notebook_client.h @@ -1050,6 +1050,178 @@ class NotebookServiceClient { future> DiagnoseInstance( google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/notebooks/v2/notebook_connection.cc b/google/cloud/notebooks/v2/notebook_connection.cc index 7a3404d5dbb29..63cbbef5f2ac6 100644 --- a/google/cloud/notebooks/v2/notebook_connection.cc +++ b/google/cloud/notebooks/v2/notebook_connection.cc @@ -264,6 +264,36 @@ NotebookServiceConnection::DiagnoseInstance( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +NotebookServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +NotebookServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr NotebookServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr NotebookServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +NotebookServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeNotebookServiceConnection( Options options) { internal::CheckExpectedOptions #include +#include #include #include @@ -296,6 +298,21 @@ class NotebookServiceConnection { virtual future> DiagnoseInstance(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/notebooks/v2/notebook_connection_idempotency_policy.cc b/google/cloud/notebooks/v2/notebook_connection_idempotency_policy.cc index 7071730d2ec8f..dd1ffbff5045e 100644 --- a/google/cloud/notebooks/v2/notebook_connection_idempotency_policy.cc +++ b/google/cloud/notebooks/v2/notebook_connection_idempotency_policy.cc @@ -95,6 +95,32 @@ Idempotency NotebookServiceConnectionIdempotencyPolicy::DiagnoseInstance( return Idempotency::kNonIdempotent; } +Idempotency NotebookServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency NotebookServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency NotebookServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency NotebookServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency NotebookServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultNotebookServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/notebooks/v2/notebook_connection_idempotency_policy.h b/google/cloud/notebooks/v2/notebook_connection_idempotency_policy.h index 61640e148ec33..0c26045129ce9 100644 --- a/google/cloud/notebooks/v2/notebook_connection_idempotency_policy.h +++ b/google/cloud/notebooks/v2/notebook_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -73,6 +75,21 @@ class NotebookServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DiagnoseInstance( google::cloud::notebooks::v2::DiagnoseInstanceRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/privateca/BUILD.bazel b/google/cloud/privateca/BUILD.bazel index 29cee95745b6e..5f413e7f5094d 100644 --- a/google/cloud/privateca/BUILD.bazel +++ b/google/cloud/privateca/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/security/privateca/v1:privateca_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/privateca/v1/certificate_authority_client.cc b/google/cloud/privateca/v1/certificate_authority_client.cc index 8cf7b0ba9bef2..4cd7825f5668f 100644 --- a/google/cloud/privateca/v1/certificate_authority_client.cc +++ b/google/cloud/privateca/v1/certificate_authority_client.cc @@ -1003,6 +1003,41 @@ CertificateAuthorityServiceClient::UpdateCertificateTemplate( return connection_->UpdateCertificateTemplate(operation); } +StreamRange +CertificateAuthorityServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +CertificateAuthorityServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr +CertificateAuthorityServiceClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr +CertificateAuthorityServiceClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +CertificateAuthorityServiceClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace privateca_v1 } // namespace cloud diff --git a/google/cloud/privateca/v1/certificate_authority_client.h b/google/cloud/privateca/v1/certificate_authority_client.h index d21d653d3f809..c0d61c7af223b 100644 --- a/google/cloud/privateca/v1/certificate_authority_client.h +++ b/google/cloud/privateca/v1/certificate_authority_client.h @@ -2926,6 +2926,178 @@ class CertificateAuthorityServiceClient { UpdateCertificateTemplate(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/privateca/v1/certificate_authority_connection.cc b/google/cloud/privateca/v1/certificate_authority_connection.cc index bb4e6aafee4d3..b1c7bdd913f5f 100644 --- a/google/cloud/privateca/v1/certificate_authority_connection.cc +++ b/google/cloud/privateca/v1/certificate_authority_connection.cc @@ -493,6 +493,38 @@ CertificateAuthorityServiceConnection::UpdateCertificateTemplate( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +CertificateAuthorityServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +CertificateAuthorityServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +CertificateAuthorityServiceConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +CertificateAuthorityServiceConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +CertificateAuthorityServiceConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCertificateAuthorityServiceConnection(Options options) { internal::CheckExpectedOptions #include +#include #include #include @@ -475,6 +477,21 @@ class CertificateAuthorityServiceConnection { virtual future< StatusOr> UpdateCertificateTemplate(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/privateca/v1/certificate_authority_connection_idempotency_policy.cc b/google/cloud/privateca/v1/certificate_authority_connection_idempotency_policy.cc index 6ea70647aa7b6..bd0bfa9a3767c 100644 --- a/google/cloud/privateca/v1/certificate_authority_connection_idempotency_policy.cc +++ b/google/cloud/privateca/v1/certificate_authority_connection_idempotency_policy.cc @@ -217,6 +217,36 @@ Idempotency CertificateAuthorityServiceConnectionIdempotencyPolicy:: return Idempotency::kNonIdempotent; } +Idempotency +CertificateAuthorityServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CertificateAuthorityServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +CertificateAuthorityServiceConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency +CertificateAuthorityServiceConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency +CertificateAuthorityServiceConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultCertificateAuthorityServiceConnectionIdempotencyPolicy() { return std::make_unique< diff --git a/google/cloud/privateca/v1/certificate_authority_connection_idempotency_policy.h b/google/cloud/privateca/v1/certificate_authority_connection_idempotency_policy.h index 51d904c0e520d..843d1864fd656 100644 --- a/google/cloud/privateca/v1/certificate_authority_connection_idempotency_policy.h +++ b/google/cloud/privateca/v1/certificate_authority_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -150,6 +152,21 @@ class CertificateAuthorityServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency UpdateCertificateTemplate( google::cloud::security::privateca::v1:: UpdateCertificateTemplateRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/privateca/v1/internal/certificate_authority_auth_decorator.cc b/google/cloud/privateca/v1/internal/certificate_authority_auth_decorator.cc index 3bc831099e107..fa3030746a4a2 100644 --- a/google/cloud/privateca/v1/internal/certificate_authority_auth_decorator.cc +++ b/google/cloud/privateca/v1/internal/certificate_authority_auth_decorator.cc @@ -617,6 +617,49 @@ CertificateAuthorityServiceAuth::UpdateCertificateTemplate( return child_->UpdateCertificateTemplate(context, options, request); } +StatusOr +CertificateAuthorityServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +CertificateAuthorityServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr CertificateAuthorityServiceAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr CertificateAuthorityServiceAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +CertificateAuthorityServiceAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> CertificateAuthorityServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/privateca/v1/internal/certificate_authority_auth_decorator.h b/google/cloud/privateca/v1/internal/certificate_authority_auth_decorator.h index 0bc319380fd4e..ee5379cec1931 100644 --- a/google/cloud/privateca/v1/internal/certificate_authority_auth_decorator.h +++ b/google/cloud/privateca/v1/internal/certificate_authority_auth_decorator.h @@ -309,6 +309,26 @@ class CertificateAuthorityServiceAuth : public CertificateAuthorityServiceStub { google::cloud::security::privateca::v1:: UpdateCertificateTemplateRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/privateca/v1/internal/certificate_authority_connection_impl.cc b/google/cloud/privateca/v1/internal/certificate_authority_connection_impl.cc index f97adbebf1afd..175e1f8207e0b 100644 --- a/google/cloud/privateca/v1/internal/certificate_authority_connection_impl.cc +++ b/google/cloud/privateca/v1/internal/certificate_authority_connection_impl.cc @@ -1755,6 +1755,97 @@ CertificateAuthorityServiceConnectionImpl::UpdateCertificateTemplate( polling_policy(*current), __func__); } +StreamRange +CertificateAuthorityServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr< + privateca_v1::CertificateAuthorityServiceRetryPolicy>( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +CertificateAuthorityServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +CertificateAuthorityServiceConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +CertificateAuthorityServiceConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +CertificateAuthorityServiceConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace privateca_v1_internal } // namespace cloud diff --git a/google/cloud/privateca/v1/internal/certificate_authority_connection_impl.h b/google/cloud/privateca/v1/internal/certificate_authority_connection_impl.h index 0554d477ceb68..04900fa468be1 100644 --- a/google/cloud/privateca/v1/internal/certificate_authority_connection_impl.h +++ b/google/cloud/privateca/v1/internal/certificate_authority_connection_impl.h @@ -316,6 +316,21 @@ class CertificateAuthorityServiceConnectionImpl UpdateCertificateTemplate( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/privateca/v1/internal/certificate_authority_logging_decorator.cc b/google/cloud/privateca/v1/internal/certificate_authority_logging_decorator.cc index 4706ded445241..e76e89b58f864 100644 --- a/google/cloud/privateca/v1/internal/certificate_authority_logging_decorator.cc +++ b/google/cloud/privateca/v1/internal/certificate_authority_logging_decorator.cc @@ -727,6 +727,66 @@ CertificateAuthorityServiceLogging::UpdateCertificateTemplate( context, options, request, __func__, tracing_options_); } +StatusOr +CertificateAuthorityServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +CertificateAuthorityServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +CertificateAuthorityServiceLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +CertificateAuthorityServiceLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +CertificateAuthorityServiceLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> CertificateAuthorityServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/privateca/v1/internal/certificate_authority_logging_decorator.h b/google/cloud/privateca/v1/internal/certificate_authority_logging_decorator.h index 12f38cd7c5159..b95af038d1ee2 100644 --- a/google/cloud/privateca/v1/internal/certificate_authority_logging_decorator.h +++ b/google/cloud/privateca/v1/internal/certificate_authority_logging_decorator.h @@ -310,6 +310,26 @@ class CertificateAuthorityServiceLogging google::cloud::security::privateca::v1:: UpdateCertificateTemplateRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/privateca/v1/internal/certificate_authority_metadata_decorator.cc b/google/cloud/privateca/v1/internal/certificate_authority_metadata_decorator.cc index a963326e2f458..f49fceb6f2090 100644 --- a/google/cloud/privateca/v1/internal/certificate_authority_metadata_decorator.cc +++ b/google/cloud/privateca/v1/internal/certificate_authority_metadata_decorator.cc @@ -533,6 +533,54 @@ CertificateAuthorityServiceMetadata::UpdateCertificateTemplate( return child_->UpdateCertificateTemplate(context, options, request); } +StatusOr +CertificateAuthorityServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +CertificateAuthorityServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr +CertificateAuthorityServiceMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr +CertificateAuthorityServiceMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +CertificateAuthorityServiceMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> CertificateAuthorityServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/privateca/v1/internal/certificate_authority_metadata_decorator.h b/google/cloud/privateca/v1/internal/certificate_authority_metadata_decorator.h index 525a386a64e48..abc0ce93e7c88 100644 --- a/google/cloud/privateca/v1/internal/certificate_authority_metadata_decorator.h +++ b/google/cloud/privateca/v1/internal/certificate_authority_metadata_decorator.h @@ -311,6 +311,26 @@ class CertificateAuthorityServiceMetadata google::cloud::security::privateca::v1:: UpdateCertificateTemplateRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/privateca/v1/internal/certificate_authority_stub.cc b/google/cloud/privateca/v1/internal/certificate_authority_stub.cc index db16e57b63e10..bd539abdedc2a 100644 --- a/google/cloud/privateca/v1/internal/certificate_authority_stub.cc +++ b/google/cloud/privateca/v1/internal/certificate_authority_stub.cc @@ -720,6 +720,67 @@ DefaultCertificateAuthorityServiceStub::UpdateCertificateTemplate( return response; } +StatusOr +DefaultCertificateAuthorityServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultCertificateAuthorityServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultCertificateAuthorityServiceStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultCertificateAuthorityServiceStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultCertificateAuthorityServiceStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultCertificateAuthorityServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/privateca/v1/internal/certificate_authority_stub.h b/google/cloud/privateca/v1/internal/certificate_authority_stub.h index 489da963e70d1..ece7f2f51a9c9 100644 --- a/google/cloud/privateca/v1/internal/certificate_authority_stub.h +++ b/google/cloud/privateca/v1/internal/certificate_authority_stub.h @@ -24,7 +24,11 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include +#include +#include #include #include #include @@ -311,6 +315,28 @@ class CertificateAuthorityServiceStub { google::cloud::security::privateca::v1:: UpdateCertificateTemplateRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -331,9 +357,15 @@ class DefaultCertificateAuthorityServiceStub std::unique_ptr grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr CreateCertificate( @@ -605,6 +637,26 @@ class DefaultCertificateAuthorityServiceStub google::cloud::security::privateca::v1:: UpdateCertificateTemplateRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -621,6 +673,9 @@ class DefaultCertificateAuthorityServiceStub std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/privateca/v1/internal/certificate_authority_stub_factory.cc b/google/cloud/privateca/v1/internal/certificate_authority_stub_factory.cc index 0b56d363c9f85..76e0cb5c878c7 100644 --- a/google/cloud/privateca/v1/internal/certificate_authority_stub_factory.cc +++ b/google/cloud/privateca/v1/internal/certificate_authority_stub_factory.cc @@ -28,7 +28,9 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include #include #include @@ -45,9 +47,13 @@ CreateDefaultCertificateAuthorityServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::security::privateca::v1:: CertificateAuthorityService::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/privateca/v1/internal/certificate_authority_tracing_connection.cc b/google/cloud/privateca/v1/internal/certificate_authority_tracing_connection.cc index fc216523ed1b2..c862a08d49b1a 100644 --- a/google/cloud/privateca/v1/internal/certificate_authority_tracing_connection.cc +++ b/google/cloud/privateca/v1/internal/certificate_authority_tracing_connection.cc @@ -684,6 +684,54 @@ CertificateAuthorityServiceTracingConnection::UpdateCertificateTemplate( child_->UpdateCertificateTemplate(operation)); } +StreamRange +CertificateAuthorityServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "privateca_v1::CertificateAuthorityServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CertificateAuthorityServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "privateca_v1::CertificateAuthorityServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +CertificateAuthorityServiceTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "privateca_v1::CertificateAuthorityServiceConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +CertificateAuthorityServiceTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "privateca_v1::CertificateAuthorityServiceConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +CertificateAuthorityServiceTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "privateca_v1::CertificateAuthorityServiceConnection::" + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/privateca/v1/internal/certificate_authority_tracing_connection.h b/google/cloud/privateca/v1/internal/certificate_authority_tracing_connection.h index e4a49037f01ba..745ab8cfdf901 100644 --- a/google/cloud/privateca/v1/internal/certificate_authority_tracing_connection.h +++ b/google/cloud/privateca/v1/internal/certificate_authority_tracing_connection.h @@ -304,6 +304,21 @@ class CertificateAuthorityServiceTracingConnection UpdateCertificateTemplate( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/privateca/v1/internal/certificate_authority_tracing_stub.cc b/google/cloud/privateca/v1/internal/certificate_authority_tracing_stub.cc index b21d5e0ad6da0..54cdebdb9b1da 100644 --- a/google/cloud/privateca/v1/internal/certificate_authority_tracing_stub.cc +++ b/google/cloud/privateca/v1/internal/certificate_authority_tracing_stub.cc @@ -693,6 +693,71 @@ CertificateAuthorityServiceTracingStub::UpdateCertificateTemplate( child_->UpdateCertificateTemplate(context, options, request)); } +StatusOr +CertificateAuthorityServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.security.privateca.v1.CertificateAuthorityService", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +CertificateAuthorityServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.security.privateca.v1.CertificateAuthorityService", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr +CertificateAuthorityServiceTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.security.privateca.v1.CertificateAuthorityService", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr +CertificateAuthorityServiceTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.security.privateca.v1.CertificateAuthorityService", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +CertificateAuthorityServiceTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.security.privateca.v1.CertificateAuthorityService", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> CertificateAuthorityServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/privateca/v1/internal/certificate_authority_tracing_stub.h b/google/cloud/privateca/v1/internal/certificate_authority_tracing_stub.h index fe6642a9e5459..c3901a92c9fb1 100644 --- a/google/cloud/privateca/v1/internal/certificate_authority_tracing_stub.h +++ b/google/cloud/privateca/v1/internal/certificate_authority_tracing_stub.h @@ -310,6 +310,26 @@ class CertificateAuthorityServiceTracingStub google::cloud::security::privateca::v1:: UpdateCertificateTemplateRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/privateca/v1/mocks/mock_certificate_authority_connection.h b/google/cloud/privateca/v1/mocks/mock_certificate_authority_connection.h index 99c5d8abecddb..7edadaf804351 100644 --- a/google/cloud/privateca/v1/mocks/mock_certificate_authority_connection.h +++ b/google/cloud/privateca/v1/mocks/mock_certificate_authority_connection.h @@ -765,6 +765,27 @@ class MockCertificateAuthorityServiceConnection google::cloud::security::privateca::v1::CertificateTemplate>>, UpdateCertificateTemplate, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/privilegedaccessmanager/BUILD.bazel b/google/cloud/privilegedaccessmanager/BUILD.bazel index 1ffb42a150823..9d574c4e59042 100644 --- a/google/cloud/privilegedaccessmanager/BUILD.bazel +++ b/google/cloud/privilegedaccessmanager/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/privilegedaccessmanager/v1:privilegedaccessmanager_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_auth_decorator.cc b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_auth_decorator.cc index 119473e35e7fb..9a8e8c07463b2 100644 --- a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_auth_decorator.cc +++ b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_auth_decorator.cc @@ -256,6 +256,24 @@ PrivilegedAccessManagerAuth::RevokeGrant( return child_->RevokeGrant(context, options, request); } +StatusOr +PrivilegedAccessManagerAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +PrivilegedAccessManagerAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> PrivilegedAccessManagerAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_auth_decorator.h b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_auth_decorator.h index daf1ae5bd957d..66b74ce361c18 100644 --- a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_auth_decorator.h +++ b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_auth_decorator.h @@ -144,6 +144,14 @@ class PrivilegedAccessManagerAuth : public PrivilegedAccessManagerStub { google::cloud::privilegedaccessmanager::v1::RevokeGrantRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_connection_impl.cc b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_connection_impl.cc index 8dd6d38361575..76cd2d50ed419 100644 --- a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_connection_impl.cc +++ b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_connection_impl.cc @@ -704,6 +704,55 @@ PrivilegedAccessManagerConnectionImpl::RevokeGrant( polling_policy(*current), __func__); } +StreamRange +PrivilegedAccessManagerConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr< + privilegedaccessmanager_v1::PrivilegedAccessManagerRetryPolicy>( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +PrivilegedAccessManagerConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace privilegedaccessmanager_v1_internal } // namespace cloud diff --git a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_connection_impl.h b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_connection_impl.h index 6d8d45c48586d..d0834dd6bf773 100644 --- a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_connection_impl.h +++ b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_connection_impl.h @@ -145,6 +145,12 @@ class PrivilegedAccessManagerConnectionImpl future> RevokeGrant(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr< diff --git a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_logging_decorator.cc b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_logging_decorator.cc index c4acb79772991..b7d7084d016ff 100644 --- a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_logging_decorator.cc +++ b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_logging_decorator.cc @@ -318,6 +318,30 @@ PrivilegedAccessManagerLogging::RevokeGrant( context, options, request, __func__, tracing_options_); } +StatusOr +PrivilegedAccessManagerLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +PrivilegedAccessManagerLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> PrivilegedAccessManagerLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_logging_decorator.h b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_logging_decorator.h index 7f8d75d8af085..2aa6b049599f1 100644 --- a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_logging_decorator.h +++ b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_logging_decorator.h @@ -144,6 +144,14 @@ class PrivilegedAccessManagerLogging : public PrivilegedAccessManagerStub { google::cloud::privilegedaccessmanager::v1::RevokeGrantRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_metadata_decorator.cc b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_metadata_decorator.cc index 6e5533597e3c2..bd30b6ca55cf1 100644 --- a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_metadata_decorator.cc +++ b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_metadata_decorator.cc @@ -239,6 +239,24 @@ PrivilegedAccessManagerMetadata::RevokeGrant( return child_->RevokeGrant(context, options, request); } +StatusOr +PrivilegedAccessManagerMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +PrivilegedAccessManagerMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> PrivilegedAccessManagerMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_metadata_decorator.h b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_metadata_decorator.h index f9bc674693655..6a173be19869c 100644 --- a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_metadata_decorator.h +++ b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_metadata_decorator.h @@ -145,6 +145,14 @@ class PrivilegedAccessManagerMetadata : public PrivilegedAccessManagerStub { google::cloud::privilegedaccessmanager::v1::RevokeGrantRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_stub.cc b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_stub.cc index e887b0ecc88ee..fdb56db18447f 100644 --- a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_stub.cc +++ b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_stub.cc @@ -297,6 +297,30 @@ DefaultPrivilegedAccessManagerStub::RevokeGrant( return response; } +StatusOr +DefaultPrivilegedAccessManagerStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultPrivilegedAccessManagerStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultPrivilegedAccessManagerStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_stub.h b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_stub.h index 9cb749962023d..c1a52a01dd3fd 100644 --- a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_stub.h +++ b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_stub.h @@ -24,6 +24,8 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include #include @@ -147,6 +149,15 @@ class PrivilegedAccessManagerStub { google::cloud::privilegedaccessmanager::v1::RevokeGrantRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -166,9 +177,13 @@ class DefaultPrivilegedAccessManagerStub : public PrivilegedAccessManagerStub { std::unique_ptr grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr< google::cloud::privilegedaccessmanager::v1::CheckOnboardingStatusResponse> @@ -275,6 +290,14 @@ class DefaultPrivilegedAccessManagerStub : public PrivilegedAccessManagerStub { google::cloud::privilegedaccessmanager::v1::RevokeGrantRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -291,6 +314,8 @@ class DefaultPrivilegedAccessManagerStub : public PrivilegedAccessManagerStub { std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_stub_factory.cc b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_stub_factory.cc index 4a66883048c82..7ef9b8bfd29fe 100644 --- a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_stub_factory.cc +++ b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_stub_factory.cc @@ -28,6 +28,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -45,9 +46,11 @@ CreateDefaultPrivilegedAccessManagerStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::privilegedaccessmanager::v1:: PrivilegedAccessManager::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_tracing_connection.cc b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_tracing_connection.cc index 5c67fbf9745d1..6d6046dd13bf5 100644 --- a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_tracing_connection.cc +++ b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_tracing_connection.cc @@ -295,6 +295,28 @@ PrivilegedAccessManagerTracingConnection::RevokeGrant( return internal::EndSpan(std::move(span), child_->RevokeGrant(operation)); } +StreamRange +PrivilegedAccessManagerTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "privilegedaccessmanager_v1::PrivilegedAccessManagerConnection::" + "ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +PrivilegedAccessManagerTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "privilegedaccessmanager_v1::PrivilegedAccessManagerConnection::" + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_tracing_connection.h b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_tracing_connection.h index df9b42448d5b4..67f05e21a42ba 100644 --- a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_tracing_connection.h +++ b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_tracing_connection.h @@ -133,6 +133,12 @@ class PrivilegedAccessManagerTracingConnection future> RevokeGrant(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; diff --git a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_tracing_stub.cc b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_tracing_stub.cc index dda0e94735b21..3939e8cbf9b46 100644 --- a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_tracing_stub.cc +++ b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_tracing_stub.cc @@ -296,6 +296,32 @@ PrivilegedAccessManagerTracingStub::RevokeGrant( child_->RevokeGrant(context, options, request)); } +StatusOr +PrivilegedAccessManagerTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +PrivilegedAccessManagerTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> PrivilegedAccessManagerTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_tracing_stub.h b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_tracing_stub.h index 607620603d968..f35d443ecc85a 100644 --- a/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_tracing_stub.h +++ b/google/cloud/privilegedaccessmanager/v1/internal/privileged_access_manager_tracing_stub.h @@ -144,6 +144,14 @@ class PrivilegedAccessManagerTracingStub : public PrivilegedAccessManagerStub { google::cloud::privilegedaccessmanager::v1::RevokeGrantRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/privilegedaccessmanager/v1/mocks/mock_privileged_access_manager_connection.h b/google/cloud/privilegedaccessmanager/v1/mocks/mock_privileged_access_manager_connection.h index 5f0c523a4663f..863b0fc8baa07 100644 --- a/google/cloud/privilegedaccessmanager/v1/mocks/mock_privileged_access_manager_connection.h +++ b/google/cloud/privilegedaccessmanager/v1/mocks/mock_privileged_access_manager_connection.h @@ -272,6 +272,14 @@ class MockPrivilegedAccessManagerConnection future>, RevokeGrant, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/privilegedaccessmanager/v1/privileged_access_manager_client.cc b/google/cloud/privilegedaccessmanager/v1/privileged_access_manager_client.cc index ef60f7d797475..a041f35ec37a2 100644 --- a/google/cloud/privilegedaccessmanager/v1/privileged_access_manager_client.cc +++ b/google/cloud/privilegedaccessmanager/v1/privileged_access_manager_client.cc @@ -337,6 +337,20 @@ PrivilegedAccessManagerClient::RevokeGrant( return connection_->RevokeGrant(operation); } +StreamRange +PrivilegedAccessManagerClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +PrivilegedAccessManagerClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace privilegedaccessmanager_v1 } // namespace cloud diff --git a/google/cloud/privilegedaccessmanager/v1/privileged_access_manager_client.h b/google/cloud/privilegedaccessmanager/v1/privileged_access_manager_client.h index fbb4976ac6f12..5ec7128b3b918 100644 --- a/google/cloud/privilegedaccessmanager/v1/privileged_access_manager_client.h +++ b/google/cloud/privilegedaccessmanager/v1/privileged_access_manager_client.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include #include #include @@ -1118,6 +1119,76 @@ class PrivilegedAccessManagerClient { RevokeGrant(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/privilegedaccessmanager/v1/privileged_access_manager_connection.cc b/google/cloud/privilegedaccessmanager/v1/privileged_access_manager_connection.cc index 36891ba78443f..1d06c40c3ebba 100644 --- a/google/cloud/privilegedaccessmanager/v1/privileged_access_manager_connection.cc +++ b/google/cloud/privilegedaccessmanager/v1/privileged_access_manager_connection.cc @@ -208,6 +208,20 @@ PrivilegedAccessManagerConnection::RevokeGrant( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +PrivilegedAccessManagerConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +PrivilegedAccessManagerConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakePrivilegedAccessManagerConnection(Options options) { internal::CheckExpectedOptions #include #include #include @@ -291,6 +292,12 @@ class PrivilegedAccessManagerConnection { virtual future> RevokeGrant(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/privilegedaccessmanager/v1/privileged_access_manager_connection_idempotency_policy.cc b/google/cloud/privilegedaccessmanager/v1/privileged_access_manager_connection_idempotency_policy.cc index 20723ae7539d5..52d9dfb1500e5 100644 --- a/google/cloud/privilegedaccessmanager/v1/privileged_access_manager_connection_idempotency_policy.cc +++ b/google/cloud/privilegedaccessmanager/v1/privileged_access_manager_connection_idempotency_policy.cc @@ -118,6 +118,16 @@ Idempotency PrivilegedAccessManagerConnectionIdempotencyPolicy::RevokeGrant( return Idempotency::kNonIdempotent; } +Idempotency PrivilegedAccessManagerConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency PrivilegedAccessManagerConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultPrivilegedAccessManagerConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/privilegedaccessmanager/v1/privileged_access_manager_connection_idempotency_policy.h b/google/cloud/privilegedaccessmanager/v1/privileged_access_manager_connection_idempotency_policy.h index 7a24fdf9dc934..96417ca8bd195 100644 --- a/google/cloud/privilegedaccessmanager/v1/privileged_access_manager_connection_idempotency_policy.h +++ b/google/cloud/privilegedaccessmanager/v1/privileged_access_manager_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -90,6 +91,12 @@ class PrivilegedAccessManagerConnectionIdempotencyPolicy { virtual google::cloud::Idempotency RevokeGrant( google::cloud::privilegedaccessmanager::v1::RevokeGrantRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/pubsub/BUILD.bazel b/google/cloud/pubsub/BUILD.bazel index 59bc8b0f07d40..084e1a0735e50 100644 --- a/google/cloud/pubsub/BUILD.bazel +++ b/google/cloud/pubsub/BUILD.bazel @@ -39,6 +39,8 @@ cc_library( "//:common", "//:grpc_utils", "@com_google_googleapis//google/pubsub/v1:pubsub_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", # Do not sort: grpc++ must come last "@com_github_grpc_grpc//:grpc++", ], diff --git a/google/cloud/pubsub/admin/internal/subscription_admin_stub.h b/google/cloud/pubsub/admin/internal/subscription_admin_stub.h index 4de313c1c280b..b4aeecb4bb331 100644 --- a/google/cloud/pubsub/admin/internal/subscription_admin_stub.h +++ b/google/cloud/pubsub/admin/internal/subscription_admin_stub.h @@ -22,6 +22,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/pubsub/admin/internal/topic_admin_stub.h b/google/cloud/pubsub/admin/internal/topic_admin_stub.h index f72e737b135e9..cd79c0f50d883 100644 --- a/google/cloud/pubsub/admin/internal/topic_admin_stub.h +++ b/google/cloud/pubsub/admin/internal/topic_admin_stub.h @@ -22,6 +22,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/pubsub/admin/subscription_admin_connection.h b/google/cloud/pubsub/admin/subscription_admin_connection.h index 457be81453ea9..3e08e8a9a8c84 100644 --- a/google/cloud/pubsub/admin/subscription_admin_connection.h +++ b/google/cloud/pubsub/admin/subscription_admin_connection.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/stream_range.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/pubsub/admin/topic_admin_connection.h b/google/cloud/pubsub/admin/topic_admin_connection.h index 4b4f64c8884cd..da19da86fe827 100644 --- a/google/cloud/pubsub/admin/topic_admin_connection.h +++ b/google/cloud/pubsub/admin/topic_admin_connection.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/stream_range.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/pubsub/internal/publisher_stub.h b/google/cloud/pubsub/internal/publisher_stub.h index 3af6d0ffbfc99..e53c9855a4c9e 100644 --- a/google/cloud/pubsub/internal/publisher_stub.h +++ b/google/cloud/pubsub/internal/publisher_stub.h @@ -24,6 +24,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/pubsub/internal/schema_stub.h b/google/cloud/pubsub/internal/schema_stub.h index 989303dc24603..f30f1bc8a7e6c 100644 --- a/google/cloud/pubsub/internal/schema_stub.h +++ b/google/cloud/pubsub/internal/schema_stub.h @@ -22,6 +22,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/pubsub/internal/subscriber_stub.h b/google/cloud/pubsub/internal/subscriber_stub.h index 0522b32342ef2..6c5befd95778d 100644 --- a/google/cloud/pubsub/internal/subscriber_stub.h +++ b/google/cloud/pubsub/internal/subscriber_stub.h @@ -25,6 +25,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/pubsub/quickstart/MODULE.bazel b/google/cloud/pubsub/quickstart/MODULE.bazel new file mode 100644 index 0000000000000..00bb18361f7f6 --- /dev/null +++ b/google/cloud/pubsub/quickstart/MODULE.bazel @@ -0,0 +1,6 @@ +############################################################################### +# Bazel now uses Bzlmod by default to manage external dependencies. +# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel. +# +# For more details, please check https://github.com/bazelbuild/bazel/issues/18958 +############################################################################### diff --git a/google/cloud/pubsub/schema_connection.h b/google/cloud/pubsub/schema_connection.h index 8dae5f0d4765e..b673003d04d47 100644 --- a/google/cloud/pubsub/schema_connection.h +++ b/google/cloud/pubsub/schema_connection.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/stream_range.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/rapidmigrationassessment/BUILD.bazel b/google/cloud/rapidmigrationassessment/BUILD.bazel index 272cc97984cae..27a5aacb102c0 100644 --- a/google/cloud/rapidmigrationassessment/BUILD.bazel +++ b/google/cloud/rapidmigrationassessment/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/rapidmigrationassessment/v1:rapidmigrationassessment_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_auth_decorator.cc b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_auth_decorator.cc index a3db2c9ddaa5e..a2452103c0bef 100644 --- a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_auth_decorator.cc +++ b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_auth_decorator.cc @@ -279,6 +279,24 @@ RapidMigrationAssessmentAuth::PauseCollector( return child_->PauseCollector(context, options, request); } +StatusOr +RapidMigrationAssessmentAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +RapidMigrationAssessmentAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> RapidMigrationAssessmentAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_auth_decorator.h b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_auth_decorator.h index f4af87fcd4e64..26e8b526a0154 100644 --- a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_auth_decorator.h +++ b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_auth_decorator.h @@ -141,6 +141,14 @@ class RapidMigrationAssessmentAuth : public RapidMigrationAssessmentStub { google::cloud::rapidmigrationassessment::v1::PauseCollectorRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_connection_impl.cc b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_connection_impl.cc index 4ea281be3ee40..754f843fb5128 100644 --- a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_connection_impl.cc +++ b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_connection_impl.cc @@ -813,6 +813,55 @@ RapidMigrationAssessmentConnectionImpl::PauseCollector( polling_policy(*current), __func__); } +StreamRange +RapidMigrationAssessmentConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr< + rapidmigrationassessment_v1::RapidMigrationAssessmentRetryPolicy>( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +RapidMigrationAssessmentConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace rapidmigrationassessment_v1_internal } // namespace cloud diff --git a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_connection_impl.h b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_connection_impl.h index 0260262bbbf97..78eaf99bbd67e 100644 --- a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_connection_impl.h +++ b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_connection_impl.h @@ -156,6 +156,12 @@ class RapidMigrationAssessmentConnectionImpl future> PauseCollector(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr< diff --git a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_logging_decorator.cc b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_logging_decorator.cc index 6975a87a66c14..ca08295eb27ef 100644 --- a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_logging_decorator.cc +++ b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_logging_decorator.cc @@ -316,6 +316,30 @@ RapidMigrationAssessmentLogging::PauseCollector( context, options, request, __func__, tracing_options_); } +StatusOr +RapidMigrationAssessmentLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +RapidMigrationAssessmentLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> RapidMigrationAssessmentLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_logging_decorator.h b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_logging_decorator.h index f70a7bf1589eb..59c0c9881c756 100644 --- a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_logging_decorator.h +++ b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_logging_decorator.h @@ -141,6 +141,14 @@ class RapidMigrationAssessmentLogging : public RapidMigrationAssessmentStub { google::cloud::rapidmigrationassessment::v1::PauseCollectorRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_metadata_decorator.cc b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_metadata_decorator.cc index ec4a03f889ba2..5677062c6a618 100644 --- a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_metadata_decorator.cc +++ b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_metadata_decorator.cc @@ -238,6 +238,24 @@ RapidMigrationAssessmentMetadata::PauseCollector( return child_->PauseCollector(context, options, request); } +StatusOr +RapidMigrationAssessmentMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +RapidMigrationAssessmentMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> RapidMigrationAssessmentMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_metadata_decorator.h b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_metadata_decorator.h index 94640b6f80ab6..a79b17852b209 100644 --- a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_metadata_decorator.h +++ b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_metadata_decorator.h @@ -142,6 +142,14 @@ class RapidMigrationAssessmentMetadata : public RapidMigrationAssessmentStub { google::cloud::rapidmigrationassessment::v1::PauseCollectorRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_stub.cc b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_stub.cc index 096f14c613710..cdba00f3a13d8 100644 --- a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_stub.cc +++ b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_stub.cc @@ -302,6 +302,30 @@ DefaultRapidMigrationAssessmentStub::PauseCollector( return response; } +StatusOr +DefaultRapidMigrationAssessmentStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultRapidMigrationAssessmentStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultRapidMigrationAssessmentStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_stub.h b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_stub.h index a29ae42e56f50..49306869600c6 100644 --- a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_stub.h +++ b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include #include @@ -142,6 +144,15 @@ class RapidMigrationAssessmentStub { google::cloud::rapidmigrationassessment::v1::PauseCollectorRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -162,9 +173,13 @@ class DefaultRapidMigrationAssessmentStub std::unique_ptr grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateCollector( google::cloud::CompletionQueue& cq, @@ -267,6 +282,14 @@ class DefaultRapidMigrationAssessmentStub google::cloud::rapidmigrationassessment::v1::PauseCollectorRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -283,6 +306,8 @@ class DefaultRapidMigrationAssessmentStub std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_stub_factory.cc b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_stub_factory.cc index d94a68bbebd05..62e2d3f7323c9 100644 --- a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_stub_factory.cc +++ b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -46,9 +47,11 @@ CreateDefaultRapidMigrationAssessmentStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::rapidmigrationassessment::v1:: RapidMigrationAssessment::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_tracing_connection.cc b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_tracing_connection.cc index e86f3b204e02f..b504b781bbdeb 100644 --- a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_tracing_connection.cc +++ b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_tracing_connection.cc @@ -313,6 +313,28 @@ RapidMigrationAssessmentTracingConnection::PauseCollector( return internal::EndSpan(std::move(span), child_->PauseCollector(operation)); } +StreamRange +RapidMigrationAssessmentTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "rapidmigrationassessment_v1::RapidMigrationAssessmentConnection::" + "ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +RapidMigrationAssessmentTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "rapidmigrationassessment_v1::RapidMigrationAssessmentConnection::" + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_tracing_connection.h b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_tracing_connection.h index dc36ec87c3366..e0e049ccafa41 100644 --- a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_tracing_connection.h +++ b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_tracing_connection.h @@ -144,6 +144,12 @@ class RapidMigrationAssessmentTracingConnection future> PauseCollector(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr< rapidmigrationassessment_v1::RapidMigrationAssessmentConnection> diff --git a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_tracing_stub.cc b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_tracing_stub.cc index 37e467f88f368..54845faabc99f 100644 --- a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_tracing_stub.cc +++ b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_tracing_stub.cc @@ -292,6 +292,32 @@ RapidMigrationAssessmentTracingStub::PauseCollector( child_->PauseCollector(context, options, request)); } +StatusOr +RapidMigrationAssessmentTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +RapidMigrationAssessmentTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> RapidMigrationAssessmentTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_tracing_stub.h b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_tracing_stub.h index bcf2dbe39b50b..f9bf2f7713bfe 100644 --- a/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_tracing_stub.h +++ b/google/cloud/rapidmigrationassessment/v1/internal/rapid_migration_assessment_tracing_stub.h @@ -142,6 +142,14 @@ class RapidMigrationAssessmentTracingStub google::cloud::rapidmigrationassessment::v1::PauseCollectorRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/rapidmigrationassessment/v1/mocks/mock_rapid_migration_assessment_connection.h b/google/cloud/rapidmigrationassessment/v1/mocks/mock_rapid_migration_assessment_connection.h index e050b5f1c617a..19436d9e1b454 100644 --- a/google/cloud/rapidmigrationassessment/v1/mocks/mock_rapid_migration_assessment_connection.h +++ b/google/cloud/rapidmigrationassessment/v1/mocks/mock_rapid_migration_assessment_connection.h @@ -350,6 +350,14 @@ class MockRapidMigrationAssessmentConnection future>, PauseCollector, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_client.cc b/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_client.cc index 2e2265d7e33a8..f1a37a891860e 100644 --- a/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_client.cc +++ b/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_client.cc @@ -418,6 +418,20 @@ RapidMigrationAssessmentClient::PauseCollector( return connection_->PauseCollector(operation); } +StreamRange +RapidMigrationAssessmentClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +RapidMigrationAssessmentClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace rapidmigrationassessment_v1 } // namespace cloud diff --git a/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_client.h b/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_client.h index e5431f8753e72..9aad33baf37ef 100644 --- a/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_client.h +++ b/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_client.h @@ -1120,6 +1120,76 @@ class RapidMigrationAssessmentClient { PauseCollector(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_connection.cc b/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_connection.cc index cedbc23e859bc..5d6278925f2a2 100644 --- a/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_connection.cc +++ b/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_connection.cc @@ -234,6 +234,20 @@ RapidMigrationAssessmentConnection::PauseCollector( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +RapidMigrationAssessmentConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +RapidMigrationAssessmentConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeRapidMigrationAssessmentConnection(Options options) { internal::CheckExpectedOptions #include #include #include @@ -316,6 +317,12 @@ class RapidMigrationAssessmentConnection { virtual future< StatusOr> PauseCollector(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_connection_idempotency_policy.cc b/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_connection_idempotency_policy.cc index 26caa189bb845..27f7bfcff2549 100644 --- a/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_connection_idempotency_policy.cc +++ b/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_connection_idempotency_policy.cc @@ -99,6 +99,16 @@ Idempotency RapidMigrationAssessmentConnectionIdempotencyPolicy::PauseCollector( return Idempotency::kNonIdempotent; } +Idempotency RapidMigrationAssessmentConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency RapidMigrationAssessmentConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultRapidMigrationAssessmentConnectionIdempotencyPolicy() { return std::make_unique< diff --git a/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_connection_idempotency_policy.h b/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_connection_idempotency_policy.h index fccd7c1bc53b2..10a72665b4393 100644 --- a/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_connection_idempotency_policy.h +++ b/google/cloud/rapidmigrationassessment/v1/rapid_migration_assessment_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -77,6 +78,12 @@ class RapidMigrationAssessmentConnectionIdempotencyPolicy { virtual google::cloud::Idempotency PauseCollector( google::cloud::rapidmigrationassessment::v1::PauseCollectorRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/redis/BUILD.bazel b/google/cloud/redis/BUILD.bazel index 7072c4ab75382..44902af46f84d 100644 --- a/google/cloud/redis/BUILD.bazel +++ b/google/cloud/redis/BUILD.bazel @@ -27,6 +27,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/redis/cluster/v1:cluster_cc_grpc", "@com_google_googleapis//google/cloud/redis/v1:redis_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/redis/cluster/v1/cloud_redis_cluster_client.cc b/google/cloud/redis/cluster/v1/cloud_redis_cluster_client.cc index edb153e1be138..8a99f1616ebb2 100644 --- a/google/cloud/redis/cluster/v1/cloud_redis_cluster_client.cc +++ b/google/cloud/redis/cluster/v1/cloud_redis_cluster_client.cc @@ -212,6 +212,20 @@ CloudRedisClusterClient::GetClusterCertificateAuthority( return connection_->GetClusterCertificateAuthority(request); } +StreamRange +CloudRedisClusterClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +CloudRedisClusterClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace redis_cluster_v1 } // namespace cloud diff --git a/google/cloud/redis/cluster/v1/cloud_redis_cluster_client.h b/google/cloud/redis/cluster/v1/cloud_redis_cluster_client.h index 327df3db7ba74..dd34474adf1a2 100644 --- a/google/cloud/redis/cluster/v1/cloud_redis_cluster_client.h +++ b/google/cloud/redis/cluster/v1/cloud_redis_cluster_client.h @@ -707,6 +707,76 @@ class CloudRedisClusterClient { GetClusterCertificateAuthorityRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/redis/cluster/v1/cloud_redis_cluster_connection.cc b/google/cloud/redis/cluster/v1/cloud_redis_cluster_connection.cc index 3173c4c3e5137..ae72351b88821 100644 --- a/google/cloud/redis/cluster/v1/cloud_redis_cluster_connection.cc +++ b/google/cloud/redis/cluster/v1/cloud_redis_cluster_connection.cc @@ -129,6 +129,20 @@ CloudRedisClusterConnection::GetClusterCertificateAuthority( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +CloudRedisClusterConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +CloudRedisClusterConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCloudRedisClusterConnection( Options options) { internal::CheckExpectedOptions #include #include #include @@ -229,6 +230,12 @@ class CloudRedisClusterConnection { GetClusterCertificateAuthority( google::cloud::redis::cluster::v1:: GetClusterCertificateAuthorityRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/redis/cluster/v1/cloud_redis_cluster_connection_idempotency_policy.cc b/google/cloud/redis/cluster/v1/cloud_redis_cluster_connection_idempotency_policy.cc index 1d9eb84878b6d..4b77544a1bf71 100644 --- a/google/cloud/redis/cluster/v1/cloud_redis_cluster_connection_idempotency_policy.cc +++ b/google/cloud/redis/cluster/v1/cloud_redis_cluster_connection_idempotency_policy.cc @@ -66,6 +66,16 @@ CloudRedisClusterConnectionIdempotencyPolicy::GetClusterCertificateAuthority( return Idempotency::kIdempotent; } +Idempotency CloudRedisClusterConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CloudRedisClusterConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultCloudRedisClusterConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/redis/cluster/v1/cloud_redis_cluster_connection_idempotency_policy.h b/google/cloud/redis/cluster/v1/cloud_redis_cluster_connection_idempotency_policy.h index f379fd34fc145..461d1cc78627a 100644 --- a/google/cloud/redis/cluster/v1/cloud_redis_cluster_connection_idempotency_policy.h +++ b/google/cloud/redis/cluster/v1/cloud_redis_cluster_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -55,6 +56,12 @@ class CloudRedisClusterConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GetClusterCertificateAuthority( google::cloud::redis::cluster::v1:: GetClusterCertificateAuthorityRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_auth_decorator.cc b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_auth_decorator.cc index 55c92b4d980d1..79c64cd8553c9 100644 --- a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_auth_decorator.cc +++ b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_auth_decorator.cc @@ -143,6 +143,23 @@ CloudRedisClusterAuth::GetClusterCertificateAuthority( return child_->GetClusterCertificateAuthority(context, options, request); } +StatusOr +CloudRedisClusterAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr CloudRedisClusterAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> CloudRedisClusterAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_auth_decorator.h b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_auth_decorator.h index af51e51019d9e..0ae734c0e6345 100644 --- a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_auth_decorator.h +++ b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_auth_decorator.h @@ -91,6 +91,14 @@ class CloudRedisClusterAuth : public CloudRedisClusterStub { google::cloud::redis::cluster::v1:: GetClusterCertificateAuthorityRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_connection_impl.cc b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_connection_impl.cc index 5a541fbbf3c14..f309caab4b2f0 100644 --- a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_connection_impl.cc +++ b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_connection_impl.cc @@ -408,6 +408,54 @@ CloudRedisClusterConnectionImpl::GetClusterCertificateAuthority( *current, request, __func__); } +StreamRange +CloudRedisClusterConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +CloudRedisClusterConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace redis_cluster_v1_internal } // namespace cloud diff --git a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_connection_impl.h b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_connection_impl.h index 72148144abf56..2f4765e04ef1a 100644 --- a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_connection_impl.h +++ b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_connection_impl.h @@ -100,6 +100,12 @@ class CloudRedisClusterConnectionImpl google::cloud::redis::cluster::v1:: GetClusterCertificateAuthorityRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_logging_decorator.cc b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_logging_decorator.cc index 6bd257289c2c4..639f854c1f462 100644 --- a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_logging_decorator.cc +++ b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_logging_decorator.cc @@ -172,6 +172,30 @@ CloudRedisClusterLogging::GetClusterCertificateAuthority( context, options, request, __func__, tracing_options_); } +StatusOr +CloudRedisClusterLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +CloudRedisClusterLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> CloudRedisClusterLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_logging_decorator.h b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_logging_decorator.h index 8ac2c5300de43..c4fea5a7c12bf 100644 --- a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_logging_decorator.h +++ b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_logging_decorator.h @@ -91,6 +91,14 @@ class CloudRedisClusterLogging : public CloudRedisClusterStub { google::cloud::redis::cluster::v1:: GetClusterCertificateAuthorityRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_metadata_decorator.cc b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_metadata_decorator.cc index f6ff1ab005a43..35d46158904b9 100644 --- a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_metadata_decorator.cc +++ b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_metadata_decorator.cc @@ -137,6 +137,24 @@ CloudRedisClusterMetadata::GetClusterCertificateAuthority( return child_->GetClusterCertificateAuthority(context, options, request); } +StatusOr +CloudRedisClusterMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +CloudRedisClusterMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> CloudRedisClusterMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_metadata_decorator.h b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_metadata_decorator.h index fdefefa65e1a6..2065bfb52b28c 100644 --- a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_metadata_decorator.h +++ b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_metadata_decorator.h @@ -92,6 +92,14 @@ class CloudRedisClusterMetadata : public CloudRedisClusterStub { google::cloud::redis::cluster::v1:: GetClusterCertificateAuthorityRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_stub.cc b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_stub.cc index 60ba788c77742..5aa93c86cdd68 100644 --- a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_stub.cc +++ b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_stub.cc @@ -162,6 +162,30 @@ DefaultCloudRedisClusterStub::GetClusterCertificateAuthority( return response; } +StatusOr +DefaultCloudRedisClusterStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultCloudRedisClusterStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultCloudRedisClusterStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_stub.h b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_stub.h index 38b10db7877d2..c5a3e82f77dbd 100644 --- a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_stub.h +++ b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_stub.h @@ -24,6 +24,8 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include #include @@ -89,6 +91,15 @@ class CloudRedisClusterStub { google::cloud::redis::cluster::v1:: GetClusterCertificateAuthorityRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -108,9 +119,13 @@ class DefaultCloudRedisClusterStub : public CloudRedisClusterStub { std::unique_ptr< google::cloud::redis::cluster::v1::CloudRedisCluster::StubInterface> grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListClusters(grpc::ClientContext& context, Options const& options, @@ -164,6 +179,14 @@ class DefaultCloudRedisClusterStub : public CloudRedisClusterStub { google::cloud::redis::cluster::v1:: GetClusterCertificateAuthorityRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -180,6 +203,8 @@ class DefaultCloudRedisClusterStub : public CloudRedisClusterStub { std::unique_ptr< google::cloud::redis::cluster::v1::CloudRedisCluster::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_stub_factory.cc b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_stub_factory.cc index ae8578d598306..6a6ce44eab834 100644 --- a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_stub_factory.cc +++ b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_stub_factory.cc @@ -28,6 +28,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultCloudRedisClusterStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::redis::cluster::v1::CloudRedisCluster::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_tracing_connection.cc b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_tracing_connection.cc index f8a5e5ff5cd97..cb8e5c2186006 100644 --- a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_tracing_connection.cc +++ b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_tracing_connection.cc @@ -150,6 +150,26 @@ CloudRedisClusterTracingConnection::GetClusterCertificateAuthority( child_->GetClusterCertificateAuthority(request)); } +StreamRange +CloudRedisClusterTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "redis_cluster_v1::CloudRedisClusterConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CloudRedisClusterTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "redis_cluster_v1::CloudRedisClusterConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_tracing_connection.h b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_tracing_connection.h index 66fa7e88c3c16..21e2231e781f2 100644 --- a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_tracing_connection.h +++ b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_tracing_connection.h @@ -88,6 +88,12 @@ class CloudRedisClusterTracingConnection google::cloud::redis::cluster::v1:: GetClusterCertificateAuthorityRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_tracing_stub.cc b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_tracing_stub.cc index 97a70eb9ffbab..169309dfe1aad 100644 --- a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_tracing_stub.cc +++ b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_tracing_stub.cc @@ -149,6 +149,30 @@ CloudRedisClusterTracingStub::GetClusterCertificateAuthority( child_->GetClusterCertificateAuthority(context, options, request)); } +StatusOr +CloudRedisClusterTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.redis.cluster.v1.CloudRedisCluster", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +CloudRedisClusterTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.redis.cluster.v1.CloudRedisCluster", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> CloudRedisClusterTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_tracing_stub.h b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_tracing_stub.h index 0fc471c7d7e05..b5d67961c667a 100644 --- a/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_tracing_stub.h +++ b/google/cloud/redis/cluster/v1/internal/cloud_redis_cluster_tracing_stub.h @@ -91,6 +91,14 @@ class CloudRedisClusterTracingStub : public CloudRedisClusterStub { google::cloud::redis::cluster::v1:: GetClusterCertificateAuthorityRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/redis/cluster/v1/mocks/mock_cloud_redis_cluster_connection.h b/google/cloud/redis/cluster/v1/mocks/mock_cloud_redis_cluster_connection.h index 3150a3f1f7bea..013adb9cce712 100644 --- a/google/cloud/redis/cluster/v1/mocks/mock_cloud_redis_cluster_connection.h +++ b/google/cloud/redis/cluster/v1/mocks/mock_cloud_redis_cluster_connection.h @@ -177,6 +177,14 @@ class MockCloudRedisClusterConnection (google::cloud::redis::cluster::v1:: GetClusterCertificateAuthorityRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/redis/v1/cloud_redis_client.cc b/google/cloud/redis/v1/cloud_redis_client.cc index cf390bd9a7ce7..748e2a4da93fd 100644 --- a/google/cloud/redis/v1/cloud_redis_client.cc +++ b/google/cloud/redis/v1/cloud_redis_client.cc @@ -431,6 +431,18 @@ CloudRedisClient::RescheduleMaintenance( return connection_->RescheduleMaintenance(operation); } +StreamRange CloudRedisClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr CloudRedisClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace redis_v1 } // namespace cloud diff --git a/google/cloud/redis/v1/cloud_redis_client.h b/google/cloud/redis/v1/cloud_redis_client.h index f10373d9eb309..fde54277e00ca 100644 --- a/google/cloud/redis/v1/cloud_redis_client.h +++ b/google/cloud/redis/v1/cloud_redis_client.h @@ -1341,6 +1341,76 @@ class CloudRedisClient { future> RescheduleMaintenance( google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/redis/v1/cloud_redis_connection.cc b/google/cloud/redis/v1/cloud_redis_connection.cc index 532b869570a93..7549a7efadbd7 100644 --- a/google/cloud/redis/v1/cloud_redis_connection.cc +++ b/google/cloud/redis/v1/cloud_redis_connection.cc @@ -227,6 +227,19 @@ CloudRedisConnection::RescheduleMaintenance( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +CloudRedisConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr CloudRedisConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCloudRedisConnection( Options options) { internal::CheckExpectedOptions #include #include #include @@ -276,6 +277,12 @@ class CloudRedisConnection { virtual future> RescheduleMaintenance(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/redis/v1/cloud_redis_connection_idempotency_policy.cc b/google/cloud/redis/v1/cloud_redis_connection_idempotency_policy.cc index c6745f8fac3d7..651f93ab0562f 100644 --- a/google/cloud/redis/v1/cloud_redis_connection_idempotency_policy.cc +++ b/google/cloud/redis/v1/cloud_redis_connection_idempotency_policy.cc @@ -89,6 +89,16 @@ Idempotency CloudRedisConnectionIdempotencyPolicy::RescheduleMaintenance( return Idempotency::kNonIdempotent; } +Idempotency CloudRedisConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CloudRedisConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultCloudRedisConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/redis/v1/cloud_redis_connection_idempotency_policy.h b/google/cloud/redis/v1/cloud_redis_connection_idempotency_policy.h index 602aedc315186..2063188c4ea39 100644 --- a/google/cloud/redis/v1/cloud_redis_connection_idempotency_policy.h +++ b/google/cloud/redis/v1/cloud_redis_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -68,6 +69,12 @@ class CloudRedisConnectionIdempotencyPolicy { virtual google::cloud::Idempotency RescheduleMaintenance( google::cloud::redis::v1::RescheduleMaintenanceRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/redis/v1/internal/cloud_redis_auth_decorator.cc b/google/cloud/redis/v1/internal/cloud_redis_auth_decorator.cc index 90fe2ca37950f..15e40dc1e831e 100644 --- a/google/cloud/redis/v1/internal/cloud_redis_auth_decorator.cc +++ b/google/cloud/redis/v1/internal/cloud_redis_auth_decorator.cc @@ -281,6 +281,23 @@ StatusOr CloudRedisAuth::RescheduleMaintenance( return child_->RescheduleMaintenance(context, options, request); } +StatusOr +CloudRedisAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr CloudRedisAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> CloudRedisAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/redis/v1/internal/cloud_redis_auth_decorator.h b/google/cloud/redis/v1/internal/cloud_redis_auth_decorator.h index 8663eed7a3634..bf2dbe270664f 100644 --- a/google/cloud/redis/v1/internal/cloud_redis_auth_decorator.h +++ b/google/cloud/redis/v1/internal/cloud_redis_auth_decorator.h @@ -136,6 +136,14 @@ class CloudRedisAuth : public CloudRedisStub { google::cloud::redis::v1::RescheduleMaintenanceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/redis/v1/internal/cloud_redis_connection_impl.cc b/google/cloud/redis/v1/internal/cloud_redis_connection_impl.cc index a94826e938edb..1a502aec74e7e 100644 --- a/google/cloud/redis/v1/internal/cloud_redis_connection_impl.cc +++ b/google/cloud/redis/v1/internal/cloud_redis_connection_impl.cc @@ -848,6 +848,54 @@ CloudRedisConnectionImpl::RescheduleMaintenance( polling_policy(*current), __func__); } +StreamRange +CloudRedisConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +CloudRedisConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace redis_v1_internal } // namespace cloud diff --git a/google/cloud/redis/v1/internal/cloud_redis_connection_impl.h b/google/cloud/redis/v1/internal/cloud_redis_connection_impl.h index 1917e496f8096..4d97ab880da85 100644 --- a/google/cloud/redis/v1/internal/cloud_redis_connection_impl.h +++ b/google/cloud/redis/v1/internal/cloud_redis_connection_impl.h @@ -144,6 +144,12 @@ class CloudRedisConnectionImpl : public redis_v1::CloudRedisConnection { future> RescheduleMaintenance( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/redis/v1/internal/cloud_redis_logging_decorator.cc b/google/cloud/redis/v1/internal/cloud_redis_logging_decorator.cc index 2a097f44784e1..9c4963011668c 100644 --- a/google/cloud/redis/v1/internal/cloud_redis_logging_decorator.cc +++ b/google/cloud/redis/v1/internal/cloud_redis_logging_decorator.cc @@ -306,6 +306,29 @@ CloudRedisLogging::RescheduleMaintenance( context, options, request, __func__, tracing_options_); } +StatusOr +CloudRedisLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr CloudRedisLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> CloudRedisLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/redis/v1/internal/cloud_redis_logging_decorator.h b/google/cloud/redis/v1/internal/cloud_redis_logging_decorator.h index 80e5e09cd3ec5..63fea203a8b29 100644 --- a/google/cloud/redis/v1/internal/cloud_redis_logging_decorator.h +++ b/google/cloud/redis/v1/internal/cloud_redis_logging_decorator.h @@ -136,6 +136,14 @@ class CloudRedisLogging : public CloudRedisStub { google::cloud::redis::v1::RescheduleMaintenanceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/redis/v1/internal/cloud_redis_metadata_decorator.cc b/google/cloud/redis/v1/internal/cloud_redis_metadata_decorator.cc index 43b46c4653568..dd7822cc69b0f 100644 --- a/google/cloud/redis/v1/internal/cloud_redis_metadata_decorator.cc +++ b/google/cloud/redis/v1/internal/cloud_redis_metadata_decorator.cc @@ -233,6 +233,23 @@ CloudRedisMetadata::RescheduleMaintenance( return child_->RescheduleMaintenance(context, options, request); } +StatusOr +CloudRedisMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr CloudRedisMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> CloudRedisMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/redis/v1/internal/cloud_redis_metadata_decorator.h b/google/cloud/redis/v1/internal/cloud_redis_metadata_decorator.h index 153f83837f095..3351c9e5384b1 100644 --- a/google/cloud/redis/v1/internal/cloud_redis_metadata_decorator.h +++ b/google/cloud/redis/v1/internal/cloud_redis_metadata_decorator.h @@ -136,6 +136,14 @@ class CloudRedisMetadata : public CloudRedisStub { google::cloud::redis::v1::RescheduleMaintenanceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/redis/v1/internal/cloud_redis_stub.cc b/google/cloud/redis/v1/internal/cloud_redis_stub.cc index 7dc53d4bafefe..26f904d62a31f 100644 --- a/google/cloud/redis/v1/internal/cloud_redis_stub.cc +++ b/google/cloud/redis/v1/internal/cloud_redis_stub.cc @@ -301,6 +301,29 @@ DefaultCloudRedisStub::RescheduleMaintenance( return response; } +StatusOr +DefaultCloudRedisStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultCloudRedisStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultCloudRedisStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/redis/v1/internal/cloud_redis_stub.h b/google/cloud/redis/v1/internal/cloud_redis_stub.h index b352aa344727f..9b06dd42a57d5 100644 --- a/google/cloud/redis/v1/internal/cloud_redis_stub.h +++ b/google/cloud/redis/v1/internal/cloud_redis_stub.h @@ -24,6 +24,8 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include #include @@ -137,6 +139,15 @@ class CloudRedisStub { google::cloud::redis::v1::RescheduleMaintenanceRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -155,9 +166,13 @@ class DefaultCloudRedisStub : public CloudRedisStub { DefaultCloudRedisStub( std::unique_ptr grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListInstances( grpc::ClientContext& context, Options const& options, @@ -256,6 +271,14 @@ class DefaultCloudRedisStub : public CloudRedisStub { google::cloud::redis::v1::RescheduleMaintenanceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -271,6 +294,8 @@ class DefaultCloudRedisStub : public CloudRedisStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/redis/v1/internal/cloud_redis_stub_factory.cc b/google/cloud/redis/v1/internal/cloud_redis_stub_factory.cc index d30468567a892..4aa4ee4eca7ae 100644 --- a/google/cloud/redis/v1/internal/cloud_redis_stub_factory.cc +++ b/google/cloud/redis/v1/internal/cloud_redis_stub_factory.cc @@ -28,6 +28,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultCloudRedisStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::redis::v1::CloudRedis::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/redis/v1/internal/cloud_redis_tracing_connection.cc b/google/cloud/redis/v1/internal/cloud_redis_tracing_connection.cc index 49166f6c10dcd..c4a2c47cfc75a 100644 --- a/google/cloud/redis/v1/internal/cloud_redis_tracing_connection.cc +++ b/google/cloud/redis/v1/internal/cloud_redis_tracing_connection.cc @@ -296,6 +296,25 @@ CloudRedisTracingConnection::RescheduleMaintenance( child_->RescheduleMaintenance(operation)); } +StreamRange +CloudRedisTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("redis_v1::CloudRedisConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CloudRedisTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan("redis_v1::CloudRedisConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeCloudRedisTracingConnection( diff --git a/google/cloud/redis/v1/internal/cloud_redis_tracing_connection.h b/google/cloud/redis/v1/internal/cloud_redis_tracing_connection.h index f4724429fdaf7..d7fe49ceeda85 100644 --- a/google/cloud/redis/v1/internal/cloud_redis_tracing_connection.h +++ b/google/cloud/redis/v1/internal/cloud_redis_tracing_connection.h @@ -133,6 +133,12 @@ class CloudRedisTracingConnection : public redis_v1::CloudRedisConnection { future> RescheduleMaintenance( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/redis/v1/internal/cloud_redis_tracing_stub.cc b/google/cloud/redis/v1/internal/cloud_redis_tracing_stub.cc index 17dbc7fbea98b..64a9377e44904 100644 --- a/google/cloud/redis/v1/internal/cloud_redis_tracing_stub.cc +++ b/google/cloud/redis/v1/internal/cloud_redis_tracing_stub.cc @@ -277,6 +277,29 @@ CloudRedisTracingStub::RescheduleMaintenance( context, *span, child_->RescheduleMaintenance(context, options, request)); } +StatusOr +CloudRedisTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.redis.v1.CloudRedis", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr CloudRedisTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.redis.v1.CloudRedis", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> CloudRedisTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/redis/v1/internal/cloud_redis_tracing_stub.h b/google/cloud/redis/v1/internal/cloud_redis_tracing_stub.h index af0fdc0b9a40b..a3481ac84a05a 100644 --- a/google/cloud/redis/v1/internal/cloud_redis_tracing_stub.h +++ b/google/cloud/redis/v1/internal/cloud_redis_tracing_stub.h @@ -135,6 +135,14 @@ class CloudRedisTracingStub : public CloudRedisStub { google::cloud::redis::v1::RescheduleMaintenanceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/redis/v1/mocks/mock_cloud_redis_connection.h b/google/cloud/redis/v1/mocks/mock_cloud_redis_connection.h index 5a1506f3abb43..c547237d5fd12 100644 --- a/google/cloud/redis/v1/mocks/mock_cloud_redis_connection.h +++ b/google/cloud/redis/v1/mocks/mock_cloud_redis_connection.h @@ -358,6 +358,14 @@ class MockCloudRedisConnection : public redis_v1::CloudRedisConnection { MOCK_METHOD(future>, RescheduleMaintenance, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/retail/BUILD.bazel b/google/cloud/retail/BUILD.bazel index 4481503e6194b..a2d6361631115 100644 --- a/google/cloud/retail/BUILD.bazel +++ b/google/cloud/retail/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/retail/v2:retail_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/retail/v2/analytics_connection.h b/google/cloud/retail/v2/analytics_connection.h index 800ab2870d8b3..177be1448a337 100644 --- a/google/cloud/retail/v2/analytics_connection.h +++ b/google/cloud/retail/v2/analytics_connection.h @@ -29,6 +29,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/retail/v2/catalog_connection.h b/google/cloud/retail/v2/catalog_connection.h index e3cd7cea13719..44e8226ee38d9 100644 --- a/google/cloud/retail/v2/catalog_connection.h +++ b/google/cloud/retail/v2/catalog_connection.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/stream_range.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/retail/v2/completion_connection.h b/google/cloud/retail/v2/completion_connection.h index e7dd6595a7fb7..4cf9f10f5324d 100644 --- a/google/cloud/retail/v2/completion_connection.h +++ b/google/cloud/retail/v2/completion_connection.h @@ -29,6 +29,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/retail/v2/control_connection.h b/google/cloud/retail/v2/control_connection.h index b0897ce6f3d90..6eb161b8c6694 100644 --- a/google/cloud/retail/v2/control_connection.h +++ b/google/cloud/retail/v2/control_connection.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/stream_range.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/retail/v2/internal/analytics_stub.h b/google/cloud/retail/v2/internal/analytics_stub.h index 7f670ff5c7382..406ee2d1114c6 100644 --- a/google/cloud/retail/v2/internal/analytics_stub.h +++ b/google/cloud/retail/v2/internal/analytics_stub.h @@ -24,6 +24,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/retail/v2/internal/catalog_stub.h b/google/cloud/retail/v2/internal/catalog_stub.h index d9ab5a09dd119..7862dfd87ace9 100644 --- a/google/cloud/retail/v2/internal/catalog_stub.h +++ b/google/cloud/retail/v2/internal/catalog_stub.h @@ -22,6 +22,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/retail/v2/internal/completion_stub.h b/google/cloud/retail/v2/internal/completion_stub.h index 60697cea8fad0..2a94c112de4e2 100644 --- a/google/cloud/retail/v2/internal/completion_stub.h +++ b/google/cloud/retail/v2/internal/completion_stub.h @@ -24,6 +24,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/retail/v2/internal/control_stub.h b/google/cloud/retail/v2/internal/control_stub.h index a5fb0e876c702..66940de6c6f85 100644 --- a/google/cloud/retail/v2/internal/control_stub.h +++ b/google/cloud/retail/v2/internal/control_stub.h @@ -22,6 +22,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/retail/v2/internal/model_stub.h b/google/cloud/retail/v2/internal/model_stub.h index 49c984fa709d8..3adc8219fb9a1 100644 --- a/google/cloud/retail/v2/internal/model_stub.h +++ b/google/cloud/retail/v2/internal/model_stub.h @@ -24,6 +24,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/retail/v2/internal/prediction_stub.h b/google/cloud/retail/v2/internal/prediction_stub.h index 6995ef92c3c54..f1c591f6a95d0 100644 --- a/google/cloud/retail/v2/internal/prediction_stub.h +++ b/google/cloud/retail/v2/internal/prediction_stub.h @@ -22,6 +22,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/retail/v2/internal/product_stub.h b/google/cloud/retail/v2/internal/product_stub.h index 5bb3df2c55563..7811d568425ac 100644 --- a/google/cloud/retail/v2/internal/product_stub.h +++ b/google/cloud/retail/v2/internal/product_stub.h @@ -24,6 +24,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/retail/v2/internal/search_stub.h b/google/cloud/retail/v2/internal/search_stub.h index 79ca39483f9a6..2bebbfad869df 100644 --- a/google/cloud/retail/v2/internal/search_stub.h +++ b/google/cloud/retail/v2/internal/search_stub.h @@ -22,6 +22,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/retail/v2/internal/serving_config_stub.h b/google/cloud/retail/v2/internal/serving_config_stub.h index f83e240125d5e..7c4b782e14820 100644 --- a/google/cloud/retail/v2/internal/serving_config_stub.h +++ b/google/cloud/retail/v2/internal/serving_config_stub.h @@ -22,6 +22,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/retail/v2/internal/user_event_stub.h b/google/cloud/retail/v2/internal/user_event_stub.h index 3160fda785c7f..fc24feac8652e 100644 --- a/google/cloud/retail/v2/internal/user_event_stub.h +++ b/google/cloud/retail/v2/internal/user_event_stub.h @@ -24,6 +24,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/retail/v2/model_connection.h b/google/cloud/retail/v2/model_connection.h index 9a0096c74d678..7ed4ebd80a5cf 100644 --- a/google/cloud/retail/v2/model_connection.h +++ b/google/cloud/retail/v2/model_connection.h @@ -30,6 +30,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/stream_range.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/retail/v2/prediction_connection.h b/google/cloud/retail/v2/prediction_connection.h index 9289fc79a05b4..76da8b0b01607 100644 --- a/google/cloud/retail/v2/prediction_connection.h +++ b/google/cloud/retail/v2/prediction_connection.h @@ -26,6 +26,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/retail/v2/product_connection.h b/google/cloud/retail/v2/product_connection.h index b4116b3e8b73f..68dfdade8be20 100644 --- a/google/cloud/retail/v2/product_connection.h +++ b/google/cloud/retail/v2/product_connection.h @@ -30,6 +30,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/stream_range.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/retail/v2/search_connection.h b/google/cloud/retail/v2/search_connection.h index 18a5d2ee8ba74..677d4c7e0a345 100644 --- a/google/cloud/retail/v2/search_connection.h +++ b/google/cloud/retail/v2/search_connection.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/stream_range.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/retail/v2/serving_config_connection.h b/google/cloud/retail/v2/serving_config_connection.h index bedf93387bec7..3c17200db3f6b 100644 --- a/google/cloud/retail/v2/serving_config_connection.h +++ b/google/cloud/retail/v2/serving_config_connection.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/stream_range.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/retail/v2/user_event_connection.h b/google/cloud/retail/v2/user_event_connection.h index 87ec209d1310f..3d328a9ad066e 100644 --- a/google/cloud/retail/v2/user_event_connection.h +++ b/google/cloud/retail/v2/user_event_connection.h @@ -29,6 +29,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/run/BUILD.bazel b/google/cloud/run/BUILD.bazel index c88d2bf6c1e82..59e7689a770d8 100644 --- a/google/cloud/run/BUILD.bazel +++ b/google/cloud/run/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/run/v2:run_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/run/v2/executions_connection.h b/google/cloud/run/v2/executions_connection.h index ca73be8b0d674..6a2f517fa91a2 100644 --- a/google/cloud/run/v2/executions_connection.h +++ b/google/cloud/run/v2/executions_connection.h @@ -30,6 +30,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/stream_range.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/run/v2/internal/executions_stub.h b/google/cloud/run/v2/internal/executions_stub.h index ddcdc4719cb15..68c8b7106ba5a 100644 --- a/google/cloud/run/v2/internal/executions_stub.h +++ b/google/cloud/run/v2/internal/executions_stub.h @@ -24,6 +24,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/run/v2/internal/jobs_stub.h b/google/cloud/run/v2/internal/jobs_stub.h index dbaa402a0cff5..6ffa1dc485f96 100644 --- a/google/cloud/run/v2/internal/jobs_stub.h +++ b/google/cloud/run/v2/internal/jobs_stub.h @@ -24,6 +24,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/run/v2/internal/revisions_stub.h b/google/cloud/run/v2/internal/revisions_stub.h index 3c07a1027008c..f888e243c0fb6 100644 --- a/google/cloud/run/v2/internal/revisions_stub.h +++ b/google/cloud/run/v2/internal/revisions_stub.h @@ -24,6 +24,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/run/v2/internal/services_stub.h b/google/cloud/run/v2/internal/services_stub.h index 378e3a3f84788..1caca7e272cff 100644 --- a/google/cloud/run/v2/internal/services_stub.h +++ b/google/cloud/run/v2/internal/services_stub.h @@ -24,6 +24,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/run/v2/internal/tasks_stub.h b/google/cloud/run/v2/internal/tasks_stub.h index 2eacae6d94f0b..161b6ccd02433 100644 --- a/google/cloud/run/v2/internal/tasks_stub.h +++ b/google/cloud/run/v2/internal/tasks_stub.h @@ -22,6 +22,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/run/v2/jobs_connection.h b/google/cloud/run/v2/jobs_connection.h index 69cbdd5f3fb01..104f9ab4724bf 100644 --- a/google/cloud/run/v2/jobs_connection.h +++ b/google/cloud/run/v2/jobs_connection.h @@ -30,6 +30,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/stream_range.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/run/v2/revisions_connection.h b/google/cloud/run/v2/revisions_connection.h index 2f64ecabdf6ac..062b75467474a 100644 --- a/google/cloud/run/v2/revisions_connection.h +++ b/google/cloud/run/v2/revisions_connection.h @@ -30,6 +30,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/stream_range.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/run/v2/services_connection.h b/google/cloud/run/v2/services_connection.h index f1ff1d662d890..096fa5f4504d6 100644 --- a/google/cloud/run/v2/services_connection.h +++ b/google/cloud/run/v2/services_connection.h @@ -30,6 +30,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/stream_range.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/run/v2/tasks_connection.h b/google/cloud/run/v2/tasks_connection.h index ba62eee3ccf44..847dfc7f48b00 100644 --- a/google/cloud/run/v2/tasks_connection.h +++ b/google/cloud/run/v2/tasks_connection.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/stream_range.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/scheduler/BUILD.bazel b/google/cloud/scheduler/BUILD.bazel index d2f15d3dc935d..0f6561fc9fe4a 100644 --- a/google/cloud/scheduler/BUILD.bazel +++ b/google/cloud/scheduler/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/scheduler/v1:scheduler_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/scheduler/v1/cloud_scheduler_client.cc b/google/cloud/scheduler/v1/cloud_scheduler_client.cc index 8f51c00b411b6..835b377997b87 100644 --- a/google/cloud/scheduler/v1/cloud_scheduler_client.cc +++ b/google/cloud/scheduler/v1/cloud_scheduler_client.cc @@ -152,6 +152,19 @@ StatusOr CloudSchedulerClient::RunJob( return connection_->RunJob(request); } +StreamRange +CloudSchedulerClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr CloudSchedulerClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace scheduler_v1 } // namespace cloud diff --git a/google/cloud/scheduler/v1/cloud_scheduler_client.h b/google/cloud/scheduler/v1/cloud_scheduler_client.h index dcb40500a13ec..eeb8ddd73fda6 100644 --- a/google/cloud/scheduler/v1/cloud_scheduler_client.h +++ b/google/cloud/scheduler/v1/cloud_scheduler_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -640,6 +641,76 @@ class CloudSchedulerClient { google::cloud::scheduler::v1::RunJobRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/scheduler/v1/cloud_scheduler_connection.cc b/google/cloud/scheduler/v1/cloud_scheduler_connection.cc index b005fcf1fcc93..7339bbaddfa17 100644 --- a/google/cloud/scheduler/v1/cloud_scheduler_connection.cc +++ b/google/cloud/scheduler/v1/cloud_scheduler_connection.cc @@ -81,6 +81,20 @@ StatusOr CloudSchedulerConnection::RunJob( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +CloudSchedulerConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +CloudSchedulerConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCloudSchedulerConnection( Options options) { internal::CheckExpectedOptions #include #include @@ -205,6 +206,12 @@ class CloudSchedulerConnection { virtual StatusOr RunJob( google::cloud::scheduler::v1::RunJobRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/scheduler/v1/cloud_scheduler_connection_idempotency_policy.cc b/google/cloud/scheduler/v1/cloud_scheduler_connection_idempotency_policy.cc index 0de5baca68e5d..6b3a37172b91b 100644 --- a/google/cloud/scheduler/v1/cloud_scheduler_connection_idempotency_policy.cc +++ b/google/cloud/scheduler/v1/cloud_scheduler_connection_idempotency_policy.cc @@ -74,6 +74,16 @@ Idempotency CloudSchedulerConnectionIdempotencyPolicy::RunJob( return Idempotency::kNonIdempotent; } +Idempotency CloudSchedulerConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CloudSchedulerConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultCloudSchedulerConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/scheduler/v1/cloud_scheduler_connection_idempotency_policy.h b/google/cloud/scheduler/v1/cloud_scheduler_connection_idempotency_policy.h index c54a199ab584d..22e095e371197 100644 --- a/google/cloud/scheduler/v1/cloud_scheduler_connection_idempotency_policy.h +++ b/google/cloud/scheduler/v1/cloud_scheduler_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -60,6 +61,12 @@ class CloudSchedulerConnectionIdempotencyPolicy { virtual google::cloud::Idempotency RunJob( google::cloud::scheduler::v1::RunJobRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/scheduler/v1/internal/cloud_scheduler_auth_decorator.cc b/google/cloud/scheduler/v1/internal/cloud_scheduler_auth_decorator.cc index 934c7847666b9..cf53941711794 100644 --- a/google/cloud/scheduler/v1/internal/cloud_scheduler_auth_decorator.cc +++ b/google/cloud/scheduler/v1/internal/cloud_scheduler_auth_decorator.cc @@ -96,6 +96,23 @@ StatusOr CloudSchedulerAuth::RunJob( return child_->RunJob(context, options, request); } +StatusOr +CloudSchedulerAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr CloudSchedulerAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace scheduler_v1_internal } // namespace cloud diff --git a/google/cloud/scheduler/v1/internal/cloud_scheduler_auth_decorator.h b/google/cloud/scheduler/v1/internal/cloud_scheduler_auth_decorator.h index fcb4c34beaf4e..944de210af00d 100644 --- a/google/cloud/scheduler/v1/internal/cloud_scheduler_auth_decorator.h +++ b/google/cloud/scheduler/v1/internal/cloud_scheduler_auth_decorator.h @@ -70,6 +70,14 @@ class CloudSchedulerAuth : public CloudSchedulerStub { grpc::ClientContext& context, Options const& options, google::cloud::scheduler::v1::RunJobRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/scheduler/v1/internal/cloud_scheduler_connection_impl.cc b/google/cloud/scheduler/v1/internal/cloud_scheduler_connection_impl.cc index b02044ff5d977..59e00de2da217 100644 --- a/google/cloud/scheduler/v1/internal/cloud_scheduler_connection_impl.cc +++ b/google/cloud/scheduler/v1/internal/cloud_scheduler_connection_impl.cc @@ -190,6 +190,54 @@ CloudSchedulerConnectionImpl::RunJob( *current, request, __func__); } +StreamRange +CloudSchedulerConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +CloudSchedulerConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace scheduler_v1_internal } // namespace cloud diff --git a/google/cloud/scheduler/v1/internal/cloud_scheduler_connection_impl.h b/google/cloud/scheduler/v1/internal/cloud_scheduler_connection_impl.h index 378323a57c666..9f6890aa61d65 100644 --- a/google/cloud/scheduler/v1/internal/cloud_scheduler_connection_impl.h +++ b/google/cloud/scheduler/v1/internal/cloud_scheduler_connection_impl.h @@ -73,6 +73,12 @@ class CloudSchedulerConnectionImpl StatusOr RunJob( google::cloud::scheduler::v1::RunJobRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/scheduler/v1/internal/cloud_scheduler_logging_decorator.cc b/google/cloud/scheduler/v1/internal/cloud_scheduler_logging_decorator.cc index 7c553f463db6f..ce049626513ad 100644 --- a/google/cloud/scheduler/v1/internal/cloud_scheduler_logging_decorator.cc +++ b/google/cloud/scheduler/v1/internal/cloud_scheduler_logging_decorator.cc @@ -124,6 +124,29 @@ StatusOr CloudSchedulerLogging::RunJob( context, options, request, __func__, tracing_options_); } +StatusOr +CloudSchedulerLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr CloudSchedulerLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace scheduler_v1_internal } // namespace cloud diff --git a/google/cloud/scheduler/v1/internal/cloud_scheduler_logging_decorator.h b/google/cloud/scheduler/v1/internal/cloud_scheduler_logging_decorator.h index cae2eaaa57ea4..bcbc9e1bc4e34 100644 --- a/google/cloud/scheduler/v1/internal/cloud_scheduler_logging_decorator.h +++ b/google/cloud/scheduler/v1/internal/cloud_scheduler_logging_decorator.h @@ -70,6 +70,14 @@ class CloudSchedulerLogging : public CloudSchedulerStub { grpc::ClientContext& context, Options const& options, google::cloud::scheduler::v1::RunJobRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/scheduler/v1/internal/cloud_scheduler_metadata_decorator.cc b/google/cloud/scheduler/v1/internal/cloud_scheduler_metadata_decorator.cc index f842cd9fecc85..75807d95ec4d0 100644 --- a/google/cloud/scheduler/v1/internal/cloud_scheduler_metadata_decorator.cc +++ b/google/cloud/scheduler/v1/internal/cloud_scheduler_metadata_decorator.cc @@ -110,6 +110,23 @@ StatusOr CloudSchedulerMetadata::RunJob( return child_->RunJob(context, options, request); } +StatusOr +CloudSchedulerMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr CloudSchedulerMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void CloudSchedulerMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/scheduler/v1/internal/cloud_scheduler_metadata_decorator.h b/google/cloud/scheduler/v1/internal/cloud_scheduler_metadata_decorator.h index fb6344b95ab15..69c998a76cc6e 100644 --- a/google/cloud/scheduler/v1/internal/cloud_scheduler_metadata_decorator.h +++ b/google/cloud/scheduler/v1/internal/cloud_scheduler_metadata_decorator.h @@ -70,6 +70,14 @@ class CloudSchedulerMetadata : public CloudSchedulerStub { grpc::ClientContext& context, Options const& options, google::cloud::scheduler::v1::RunJobRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/scheduler/v1/internal/cloud_scheduler_stub.cc b/google/cloud/scheduler/v1/internal/cloud_scheduler_stub.cc index 3b98938f86b2b..3f92cfe48b930 100644 --- a/google/cloud/scheduler/v1/internal/cloud_scheduler_stub.cc +++ b/google/cloud/scheduler/v1/internal/cloud_scheduler_stub.cc @@ -122,6 +122,30 @@ StatusOr DefaultCloudSchedulerStub::RunJob( return response; } +StatusOr +DefaultCloudSchedulerStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultCloudSchedulerStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace scheduler_v1_internal } // namespace cloud diff --git a/google/cloud/scheduler/v1/internal/cloud_scheduler_stub.h b/google/cloud/scheduler/v1/internal/cloud_scheduler_stub.h index aee5ca9cec56e..90182766f0bcb 100644 --- a/google/cloud/scheduler/v1/internal/cloud_scheduler_stub.h +++ b/google/cloud/scheduler/v1/internal/cloud_scheduler_stub.h @@ -22,6 +22,8 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include #include @@ -66,6 +68,15 @@ class CloudSchedulerStub { virtual StatusOr RunJob( grpc::ClientContext& context, Options const& options, google::cloud::scheduler::v1::RunJobRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultCloudSchedulerStub : public CloudSchedulerStub { @@ -73,8 +84,11 @@ class DefaultCloudSchedulerStub : public CloudSchedulerStub { explicit DefaultCloudSchedulerStub( std::unique_ptr< google::cloud::scheduler::v1::CloudScheduler::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListJobs( grpc::ClientContext& context, Options const& options, @@ -108,9 +122,19 @@ class DefaultCloudSchedulerStub : public CloudSchedulerStub { grpc::ClientContext& context, Options const& options, google::cloud::scheduler::v1::RunJobRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/scheduler/v1/internal/cloud_scheduler_stub_factory.cc b/google/cloud/scheduler/v1/internal/cloud_scheduler_stub_factory.cc index c567143d19063..b5439a4121c8c 100644 --- a/google/cloud/scheduler/v1/internal/cloud_scheduler_stub_factory.cc +++ b/google/cloud/scheduler/v1/internal/cloud_scheduler_stub_factory.cc @@ -28,6 +28,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -44,8 +45,11 @@ std::shared_ptr CreateDefaultCloudSchedulerStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::scheduler::v1::CloudScheduler::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + std::make_shared( + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = diff --git a/google/cloud/scheduler/v1/internal/cloud_scheduler_tracing_connection.cc b/google/cloud/scheduler/v1/internal/cloud_scheduler_tracing_connection.cc index d6003ff8b8686..4b27e7b1c7148 100644 --- a/google/cloud/scheduler/v1/internal/cloud_scheduler_tracing_connection.cc +++ b/google/cloud/scheduler/v1/internal/cloud_scheduler_tracing_connection.cc @@ -106,6 +106,26 @@ CloudSchedulerTracingConnection::RunJob( return internal::EndSpan(*span, child_->RunJob(request)); } +StreamRange +CloudSchedulerTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "scheduler_v1::CloudSchedulerConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CloudSchedulerTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("scheduler_v1::CloudSchedulerConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/scheduler/v1/internal/cloud_scheduler_tracing_connection.h b/google/cloud/scheduler/v1/internal/cloud_scheduler_tracing_connection.h index d2e358569a543..d59c57c27f28f 100644 --- a/google/cloud/scheduler/v1/internal/cloud_scheduler_tracing_connection.h +++ b/google/cloud/scheduler/v1/internal/cloud_scheduler_tracing_connection.h @@ -64,6 +64,12 @@ class CloudSchedulerTracingConnection StatusOr RunJob( google::cloud::scheduler::v1::RunJobRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/scheduler/v1/internal/cloud_scheduler_tracing_stub.cc b/google/cloud/scheduler/v1/internal/cloud_scheduler_tracing_stub.cc index 5d446815b50f1..4846d56ed0af9 100644 --- a/google/cloud/scheduler/v1/internal/cloud_scheduler_tracing_stub.cc +++ b/google/cloud/scheduler/v1/internal/cloud_scheduler_tracing_stub.cc @@ -124,6 +124,30 @@ StatusOr CloudSchedulerTracingStub::RunJob( child_->RunJob(context, options, request)); } +StatusOr +CloudSchedulerTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.scheduler.v1.CloudScheduler", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +CloudSchedulerTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.scheduler.v1.CloudScheduler", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeCloudSchedulerTracingStub( diff --git a/google/cloud/scheduler/v1/internal/cloud_scheduler_tracing_stub.h b/google/cloud/scheduler/v1/internal/cloud_scheduler_tracing_stub.h index 51f45dda9c85e..2bf6cc785e00a 100644 --- a/google/cloud/scheduler/v1/internal/cloud_scheduler_tracing_stub.h +++ b/google/cloud/scheduler/v1/internal/cloud_scheduler_tracing_stub.h @@ -70,6 +70,14 @@ class CloudSchedulerTracingStub : public CloudSchedulerStub { grpc::ClientContext& context, Options const& options, google::cloud::scheduler::v1::RunJobRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/scheduler/v1/mocks/mock_cloud_scheduler_connection.h b/google/cloud/scheduler/v1/mocks/mock_cloud_scheduler_connection.h index 75a8956cf7541..15fb1c1101fd5 100644 --- a/google/cloud/scheduler/v1/mocks/mock_cloud_scheduler_connection.h +++ b/google/cloud/scheduler/v1/mocks/mock_cloud_scheduler_connection.h @@ -78,6 +78,14 @@ class MockCloudSchedulerConnection MOCK_METHOD(StatusOr, RunJob, (google::cloud::scheduler::v1::RunJobRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/secretmanager/BUILD.bazel b/google/cloud/secretmanager/BUILD.bazel index e54f4680e3542..e5a16b5197d85 100644 --- a/google/cloud/secretmanager/BUILD.bazel +++ b/google/cloud/secretmanager/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/secretmanager/v1:secretmanager_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/secretmanager/v1/internal/secret_manager_auth_decorator.cc b/google/cloud/secretmanager/v1/internal/secret_manager_auth_decorator.cc index 08b0629155c40..0a108b16dc6d0 100644 --- a/google/cloud/secretmanager/v1/internal/secret_manager_auth_decorator.cc +++ b/google/cloud/secretmanager/v1/internal/secret_manager_auth_decorator.cc @@ -168,6 +168,24 @@ SecretManagerServiceAuth::TestIamPermissions( return child_->TestIamPermissions(context, options, request); } +StatusOr +SecretManagerServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +SecretManagerServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace secretmanager_v1_internal } // namespace cloud diff --git a/google/cloud/secretmanager/v1/internal/secret_manager_auth_decorator.h b/google/cloud/secretmanager/v1/internal/secret_manager_auth_decorator.h index 30b376e2f58c6..fd840b087848c 100644 --- a/google/cloud/secretmanager/v1/internal/secret_manager_auth_decorator.h +++ b/google/cloud/secretmanager/v1/internal/secret_manager_auth_decorator.h @@ -114,6 +114,14 @@ class SecretManagerServiceAuth : public SecretManagerServiceStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/secretmanager/v1/internal/secret_manager_connection_impl.cc b/google/cloud/secretmanager/v1/internal/secret_manager_connection_impl.cc index 60b7888c3c746..eede11c777ed6 100644 --- a/google/cloud/secretmanager/v1/internal/secret_manager_connection_impl.cc +++ b/google/cloud/secretmanager/v1/internal/secret_manager_connection_impl.cc @@ -332,6 +332,55 @@ SecretManagerServiceConnectionImpl::TestIamPermissions( *current, request, __func__); } +StreamRange +SecretManagerServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = + std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +SecretManagerServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace secretmanager_v1_internal } // namespace cloud diff --git a/google/cloud/secretmanager/v1/internal/secret_manager_connection_impl.h b/google/cloud/secretmanager/v1/internal/secret_manager_connection_impl.h index d94d3c50a2014..9bac170ca9f56 100644 --- a/google/cloud/secretmanager/v1/internal/secret_manager_connection_impl.h +++ b/google/cloud/secretmanager/v1/internal/secret_manager_connection_impl.h @@ -108,6 +108,12 @@ class SecretManagerServiceConnectionImpl StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/secretmanager/v1/internal/secret_manager_logging_decorator.cc b/google/cloud/secretmanager/v1/internal/secret_manager_logging_decorator.cc index 1ae32eef84984..937554e35ab1e 100644 --- a/google/cloud/secretmanager/v1/internal/secret_manager_logging_decorator.cc +++ b/google/cloud/secretmanager/v1/internal/secret_manager_logging_decorator.cc @@ -231,6 +231,30 @@ SecretManagerServiceLogging::TestIamPermissions( context, options, request, __func__, tracing_options_); } +StatusOr +SecretManagerServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +SecretManagerServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace secretmanager_v1_internal } // namespace cloud diff --git a/google/cloud/secretmanager/v1/internal/secret_manager_logging_decorator.h b/google/cloud/secretmanager/v1/internal/secret_manager_logging_decorator.h index 19da46aad3c0e..040de9f3dca62 100644 --- a/google/cloud/secretmanager/v1/internal/secret_manager_logging_decorator.h +++ b/google/cloud/secretmanager/v1/internal/secret_manager_logging_decorator.h @@ -114,6 +114,14 @@ class SecretManagerServiceLogging : public SecretManagerServiceStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/secretmanager/v1/internal/secret_manager_metadata_decorator.cc b/google/cloud/secretmanager/v1/internal/secret_manager_metadata_decorator.cc index edc6b51cb6c01..b10049334d21e 100644 --- a/google/cloud/secretmanager/v1/internal/secret_manager_metadata_decorator.cc +++ b/google/cloud/secretmanager/v1/internal/secret_manager_metadata_decorator.cc @@ -185,6 +185,24 @@ SecretManagerServiceMetadata::TestIamPermissions( return child_->TestIamPermissions(context, options, request); } +StatusOr +SecretManagerServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +SecretManagerServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void SecretManagerServiceMetadata::SetMetadata( grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/secretmanager/v1/internal/secret_manager_metadata_decorator.h b/google/cloud/secretmanager/v1/internal/secret_manager_metadata_decorator.h index 74fa4ea545240..b8588c2f3f765 100644 --- a/google/cloud/secretmanager/v1/internal/secret_manager_metadata_decorator.h +++ b/google/cloud/secretmanager/v1/internal/secret_manager_metadata_decorator.h @@ -115,6 +115,14 @@ class SecretManagerServiceMetadata : public SecretManagerServiceStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/secretmanager/v1/internal/secret_manager_stub.cc b/google/cloud/secretmanager/v1/internal/secret_manager_stub.cc index 96e6fb13416f3..19c110253915e 100644 --- a/google/cloud/secretmanager/v1/internal/secret_manager_stub.cc +++ b/google/cloud/secretmanager/v1/internal/secret_manager_stub.cc @@ -212,6 +212,30 @@ DefaultSecretManagerServiceStub::TestIamPermissions( return response; } +StatusOr +DefaultSecretManagerServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultSecretManagerServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace secretmanager_v1_internal } // namespace cloud diff --git a/google/cloud/secretmanager/v1/internal/secret_manager_stub.h b/google/cloud/secretmanager/v1/internal/secret_manager_stub.h index 1587e318c94a9..31efad80872dd 100644 --- a/google/cloud/secretmanager/v1/internal/secret_manager_stub.h +++ b/google/cloud/secretmanager/v1/internal/secret_manager_stub.h @@ -22,6 +22,8 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include #include @@ -111,6 +113,15 @@ class SecretManagerServiceStub { TestIamPermissions( grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultSecretManagerServiceStub : public SecretManagerServiceStub { @@ -118,8 +129,11 @@ class DefaultSecretManagerServiceStub : public SecretManagerServiceStub { explicit DefaultSecretManagerServiceStub( std::unique_ptr< google::cloud::secretmanager::v1::SecretManagerService::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListSecrets( grpc::ClientContext& context, Options const& options, @@ -197,10 +211,20 @@ class DefaultSecretManagerServiceStub : public SecretManagerServiceStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr< google::cloud::secretmanager::v1::SecretManagerService::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/secretmanager/v1/internal/secret_manager_stub_factory.cc b/google/cloud/secretmanager/v1/internal/secret_manager_stub_factory.cc index 0adb38fad71c6..d4461b4ed80e5 100644 --- a/google/cloud/secretmanager/v1/internal/secret_manager_stub_factory.cc +++ b/google/cloud/secretmanager/v1/internal/secret_manager_stub_factory.cc @@ -28,6 +28,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultSecretManagerServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::secretmanager::v1::SecretManagerService::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/secretmanager/v1/internal/secret_manager_tracing_connection.cc b/google/cloud/secretmanager/v1/internal/secret_manager_tracing_connection.cc index ffadae2679529..86775307618e2 100644 --- a/google/cloud/secretmanager/v1/internal/secret_manager_tracing_connection.cc +++ b/google/cloud/secretmanager/v1/internal/secret_manager_tracing_connection.cc @@ -176,6 +176,26 @@ SecretManagerServiceTracingConnection::TestIamPermissions( return internal::EndSpan(*span, child_->TestIamPermissions(request)); } +StreamRange +SecretManagerServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "secretmanager_v1::SecretManagerServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SecretManagerServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "secretmanager_v1::SecretManagerServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/secretmanager/v1/internal/secret_manager_tracing_connection.h b/google/cloud/secretmanager/v1/internal/secret_manager_tracing_connection.h index 4ae97f4b18077..038bafd99e049 100644 --- a/google/cloud/secretmanager/v1/internal/secret_manager_tracing_connection.h +++ b/google/cloud/secretmanager/v1/internal/secret_manager_tracing_connection.h @@ -99,6 +99,12 @@ class SecretManagerServiceTracingConnection StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/secretmanager/v1/internal/secret_manager_tracing_stub.cc b/google/cloud/secretmanager/v1/internal/secret_manager_tracing_stub.cc index 3ce67824f38af..92888a8899b78 100644 --- a/google/cloud/secretmanager/v1/internal/secret_manager_tracing_stub.cc +++ b/google/cloud/secretmanager/v1/internal/secret_manager_tracing_stub.cc @@ -220,6 +220,30 @@ SecretManagerServiceTracingStub::TestIamPermissions( context, *span, child_->TestIamPermissions(context, options, request)); } +StatusOr +SecretManagerServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.secretmanager.v1.SecretManagerService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +SecretManagerServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.secretmanager.v1.SecretManagerService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeSecretManagerServiceTracingStub( diff --git a/google/cloud/secretmanager/v1/internal/secret_manager_tracing_stub.h b/google/cloud/secretmanager/v1/internal/secret_manager_tracing_stub.h index 0893465ce1617..73a6793ff8cde 100644 --- a/google/cloud/secretmanager/v1/internal/secret_manager_tracing_stub.h +++ b/google/cloud/secretmanager/v1/internal/secret_manager_tracing_stub.h @@ -115,6 +115,14 @@ class SecretManagerServiceTracingStub : public SecretManagerServiceStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/secretmanager/v1/mocks/mock_secret_manager_connection.h b/google/cloud/secretmanager/v1/mocks/mock_secret_manager_connection.h index 74787a6cad4e6..d2f1a3b619742 100644 --- a/google/cloud/secretmanager/v1/mocks/mock_secret_manager_connection.h +++ b/google/cloud/secretmanager/v1/mocks/mock_secret_manager_connection.h @@ -130,6 +130,14 @@ class MockSecretManagerServiceConnection TestIamPermissions, (google::iam::v1::TestIamPermissionsRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/secretmanager/v1/secret_manager_client.cc b/google/cloud/secretmanager/v1/secret_manager_client.cc index 15d527bb418e8..4b1cef7bec355 100644 --- a/google/cloud/secretmanager/v1/secret_manager_client.cc +++ b/google/cloud/secretmanager/v1/secret_manager_client.cc @@ -262,6 +262,20 @@ SecretManagerServiceClient::TestIamPermissions( return connection_->TestIamPermissions(request); } +StreamRange +SecretManagerServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +SecretManagerServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace secretmanager_v1 } // namespace cloud diff --git a/google/cloud/secretmanager/v1/secret_manager_client.h b/google/cloud/secretmanager/v1/secret_manager_client.h index 61a5ac2e21671..07e3c3122d37d 100644 --- a/google/cloud/secretmanager/v1/secret_manager_client.h +++ b/google/cloud/secretmanager/v1/secret_manager_client.h @@ -1042,6 +1042,76 @@ class SecretManagerServiceClient { google::iam::v1::TestIamPermissionsRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/secretmanager/v1/secret_manager_connection.cc b/google/cloud/secretmanager/v1/secret_manager_connection.cc index c9258265ef086..cee1f2cd07f5b 100644 --- a/google/cloud/secretmanager/v1/secret_manager_connection.cc +++ b/google/cloud/secretmanager/v1/secret_manager_connection.cc @@ -129,6 +129,20 @@ SecretManagerServiceConnection::TestIamPermissions( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +SecretManagerServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +SecretManagerServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSecretManagerServiceConnection(Options options) { internal::CheckExpectedOptions #include #include @@ -243,6 +244,12 @@ class SecretManagerServiceConnection { virtual StatusOr TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/secretmanager/v1/secret_manager_connection_idempotency_policy.cc b/google/cloud/secretmanager/v1/secret_manager_connection_idempotency_policy.cc index 39f59ea87b584..ac79ee855c323 100644 --- a/google/cloud/secretmanager/v1/secret_manager_connection_idempotency_policy.cc +++ b/google/cloud/secretmanager/v1/secret_manager_connection_idempotency_policy.cc @@ -115,6 +115,16 @@ Idempotency SecretManagerServiceConnectionIdempotencyPolicy::TestIamPermissions( return Idempotency::kIdempotent; } +Idempotency SecretManagerServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SecretManagerServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultSecretManagerServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/secretmanager/v1/secret_manager_connection_idempotency_policy.h b/google/cloud/secretmanager/v1/secret_manager_connection_idempotency_policy.h index d3e27d5eb734d..1a55e8e9c2ef4 100644 --- a/google/cloud/secretmanager/v1/secret_manager_connection_idempotency_policy.h +++ b/google/cloud/secretmanager/v1/secret_manager_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -85,6 +86,12 @@ class SecretManagerServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/securesourcemanager/BUILD.bazel b/google/cloud/securesourcemanager/BUILD.bazel index 186fabf4020bb..59cf0b02b256a 100644 --- a/google/cloud/securesourcemanager/BUILD.bazel +++ b/google/cloud/securesourcemanager/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/securesourcemanager/v1:securesourcemanager_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_auth_decorator.cc b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_auth_decorator.cc index 314fe5891f332..65dcd68551c8a 100644 --- a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_auth_decorator.cc +++ b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_auth_decorator.cc @@ -219,6 +219,49 @@ SecureSourceManagerAuth::TestIamPermissionsRepo( return child_->TestIamPermissionsRepo(context, options, request); } +StatusOr +SecureSourceManagerAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +SecureSourceManagerAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr SecureSourceManagerAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr SecureSourceManagerAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +SecureSourceManagerAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> SecureSourceManagerAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_auth_decorator.h b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_auth_decorator.h index f2b0de9699d65..e4927afc75c81 100644 --- a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_auth_decorator.h +++ b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_auth_decorator.h @@ -121,6 +121,26 @@ class SecureSourceManagerAuth : public SecureSourceManagerStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_connection_impl.cc b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_connection_impl.cc index 3939610e67335..1998e0d65657c 100644 --- a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_connection_impl.cc +++ b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_connection_impl.cc @@ -606,6 +606,97 @@ SecureSourceManagerConnectionImpl::TestIamPermissionsRepo( *current, request, __func__); } +StreamRange +SecureSourceManagerConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr< + securesourcemanager_v1::SecureSourceManagerRetryPolicy>( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +SecureSourceManagerConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +SecureSourceManagerConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +SecureSourceManagerConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +SecureSourceManagerConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace securesourcemanager_v1_internal } // namespace cloud diff --git a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_connection_impl.h b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_connection_impl.h index a2246172c6b12..5426aada7205d 100644 --- a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_connection_impl.h +++ b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_connection_impl.h @@ -131,6 +131,21 @@ class SecureSourceManagerConnectionImpl StatusOr TestIamPermissionsRepo( google::iam::v1::TestIamPermissionsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr diff --git a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_logging_decorator.cc b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_logging_decorator.cc index 3fd7b31745614..1f4e82e922a51 100644 --- a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_logging_decorator.cc +++ b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_logging_decorator.cc @@ -269,6 +269,64 @@ SecureSourceManagerLogging::TestIamPermissionsRepo( context, options, request, __func__, tracing_options_); } +StatusOr +SecureSourceManagerLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +SecureSourceManagerLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr SecureSourceManagerLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr SecureSourceManagerLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +SecureSourceManagerLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> SecureSourceManagerLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_logging_decorator.h b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_logging_decorator.h index 0f9c17cf93852..02b552bf92507 100644 --- a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_logging_decorator.h +++ b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_logging_decorator.h @@ -121,6 +121,26 @@ class SecureSourceManagerLogging : public SecureSourceManagerStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_metadata_decorator.cc b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_metadata_decorator.cc index 7ad1e507541e7..011241f8786b8 100644 --- a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_metadata_decorator.cc +++ b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_metadata_decorator.cc @@ -203,6 +203,52 @@ SecureSourceManagerMetadata::TestIamPermissionsRepo( return child_->TestIamPermissionsRepo(context, options, request); } +StatusOr +SecureSourceManagerMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +SecureSourceManagerMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr SecureSourceManagerMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr SecureSourceManagerMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +SecureSourceManagerMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> SecureSourceManagerMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_metadata_decorator.h b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_metadata_decorator.h index 44ee54771eea9..a814f8d249df7 100644 --- a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_metadata_decorator.h +++ b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_metadata_decorator.h @@ -122,6 +122,26 @@ class SecureSourceManagerMetadata : public SecureSourceManagerStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_stub.cc b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_stub.cc index 0cfe44e7a4972..e3c8bc9fac94d 100644 --- a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_stub.cc +++ b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_stub.cc @@ -255,6 +255,65 @@ DefaultSecureSourceManagerStub::TestIamPermissionsRepo( return response; } +StatusOr +DefaultSecureSourceManagerStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultSecureSourceManagerStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultSecureSourceManagerStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultSecureSourceManagerStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultSecureSourceManagerStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultSecureSourceManagerStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_stub.h b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_stub.h index 9634f2f571395..e35e3ccb5f87f 100644 --- a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_stub.h +++ b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_stub.h @@ -24,7 +24,11 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include +#include +#include #include #include #include @@ -126,6 +130,28 @@ class SecureSourceManagerStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -145,9 +171,15 @@ class DefaultSecureSourceManagerStub : public SecureSourceManagerStub { std::unique_ptr grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListInstances( @@ -231,6 +263,26 @@ class DefaultSecureSourceManagerStub : public SecureSourceManagerStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -247,6 +299,9 @@ class DefaultSecureSourceManagerStub : public SecureSourceManagerStub { std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_stub_factory.cc b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_stub_factory.cc index 3694bb3198eef..e9ca7f78cc7c7 100644 --- a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_stub_factory.cc +++ b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_stub_factory.cc @@ -28,7 +28,9 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include #include #include @@ -45,9 +47,13 @@ std::shared_ptr CreateDefaultSecureSourceManagerStub( auto service_grpc_stub = google::cloud::securesourcemanager::v1::SecureSourceManager::NewStub( channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_tracing_connection.cc b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_tracing_connection.cc index fa8bca9618b41..84eb9d92245c4 100644 --- a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_tracing_connection.cc +++ b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_tracing_connection.cc @@ -240,6 +240,54 @@ SecureSourceManagerTracingConnection::TestIamPermissionsRepo( return internal::EndSpan(*span, child_->TestIamPermissionsRepo(request)); } +StreamRange +SecureSourceManagerTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "securesourcemanager_v1::SecureSourceManagerConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SecureSourceManagerTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "securesourcemanager_v1::SecureSourceManagerConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr +SecureSourceManagerTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "securesourcemanager_v1::SecureSourceManagerConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr +SecureSourceManagerTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "securesourcemanager_v1::SecureSourceManagerConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +SecureSourceManagerTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "securesourcemanager_v1::SecureSourceManagerConnection::" + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_tracing_connection.h b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_tracing_connection.h index 4a4ac1555028b..752e5715fafa3 100644 --- a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_tracing_connection.h +++ b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_tracing_connection.h @@ -119,6 +119,21 @@ class SecureSourceManagerTracingConnection StatusOr TestIamPermissionsRepo( google::iam::v1::TestIamPermissionsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_tracing_stub.cc b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_tracing_stub.cc index 6600d312811be..3d9a30f2f4c8c 100644 --- a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_tracing_stub.cc +++ b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_tracing_stub.cc @@ -250,6 +250,68 @@ SecureSourceManagerTracingStub::TestIamPermissionsRepo( child_->TestIamPermissionsRepo(context, options, request)); } +StatusOr +SecureSourceManagerTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.securesourcemanager.v1.SecureSourceManager", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +SecureSourceManagerTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.securesourcemanager.v1.SecureSourceManager", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr SecureSourceManagerTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.securesourcemanager.v1.SecureSourceManager", + "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr SecureSourceManagerTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.securesourcemanager.v1.SecureSourceManager", + "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +SecureSourceManagerTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.securesourcemanager.v1.SecureSourceManager", + "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> SecureSourceManagerTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_tracing_stub.h b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_tracing_stub.h index 3c40b5fc5aec7..75d7f70721c0a 100644 --- a/google/cloud/securesourcemanager/v1/internal/secure_source_manager_tracing_stub.h +++ b/google/cloud/securesourcemanager/v1/internal/secure_source_manager_tracing_stub.h @@ -121,6 +121,26 @@ class SecureSourceManagerTracingStub : public SecureSourceManagerStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/securesourcemanager/v1/mocks/mock_secure_source_manager_connection.h b/google/cloud/securesourcemanager/v1/mocks/mock_secure_source_manager_connection.h index fe792781a73db..7cd781fa17f1c 100644 --- a/google/cloud/securesourcemanager/v1/mocks/mock_secure_source_manager_connection.h +++ b/google/cloud/securesourcemanager/v1/mocks/mock_secure_source_manager_connection.h @@ -256,6 +256,27 @@ class MockSecureSourceManagerConnection TestIamPermissionsRepo, (google::iam::v1::TestIamPermissionsRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/securesourcemanager/v1/secure_source_manager_client.cc b/google/cloud/securesourcemanager/v1/secure_source_manager_client.cc index 9386fa7ef52c8..de551f3679032 100644 --- a/google/cloud/securesourcemanager/v1/secure_source_manager_client.cc +++ b/google/cloud/securesourcemanager/v1/secure_source_manager_client.cc @@ -335,6 +335,39 @@ SecureSourceManagerClient::TestIamPermissionsRepo( return connection_->TestIamPermissionsRepo(request); } +StreamRange +SecureSourceManagerClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +SecureSourceManagerClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr SecureSourceManagerClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr SecureSourceManagerClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +SecureSourceManagerClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace securesourcemanager_v1 } // namespace cloud diff --git a/google/cloud/securesourcemanager/v1/secure_source_manager_client.h b/google/cloud/securesourcemanager/v1/secure_source_manager_client.h index 02fd61e300460..fa46e2e03e58c 100644 --- a/google/cloud/securesourcemanager/v1/secure_source_manager_client.h +++ b/google/cloud/securesourcemanager/v1/secure_source_manager_client.h @@ -1043,6 +1043,178 @@ class SecureSourceManagerClient { google::iam::v1::TestIamPermissionsRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/securesourcemanager/v1/secure_source_manager_connection.cc b/google/cloud/securesourcemanager/v1/secure_source_manager_connection.cc index 261a4dc2bdae9..eee8e3bfc992d 100644 --- a/google/cloud/securesourcemanager/v1/secure_source_manager_connection.cc +++ b/google/cloud/securesourcemanager/v1/secure_source_manager_connection.cc @@ -180,6 +180,36 @@ SecureSourceManagerConnection::TestIamPermissionsRepo( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +SecureSourceManagerConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +SecureSourceManagerConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr SecureSourceManagerConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr SecureSourceManagerConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +SecureSourceManagerConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSecureSourceManagerConnection(Options options) { internal::CheckExpectedOptions #include +#include #include #include @@ -272,6 +274,21 @@ class SecureSourceManagerConnection { virtual StatusOr TestIamPermissionsRepo( google::iam::v1::TestIamPermissionsRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/securesourcemanager/v1/secure_source_manager_connection_idempotency_policy.cc b/google/cloud/securesourcemanager/v1/secure_source_manager_connection_idempotency_policy.cc index 7ed15fbc805b6..5d6321eb4ba3c 100644 --- a/google/cloud/securesourcemanager/v1/secure_source_manager_connection_idempotency_policy.cc +++ b/google/cloud/securesourcemanager/v1/secure_source_manager_connection_idempotency_policy.cc @@ -93,6 +93,32 @@ SecureSourceManagerConnectionIdempotencyPolicy::TestIamPermissionsRepo( return Idempotency::kNonIdempotent; } +Idempotency SecureSourceManagerConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SecureSourceManagerConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency SecureSourceManagerConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency SecureSourceManagerConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency SecureSourceManagerConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultSecureSourceManagerConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/securesourcemanager/v1/secure_source_manager_connection_idempotency_policy.h b/google/cloud/securesourcemanager/v1/secure_source_manager_connection_idempotency_policy.h index 31355e9885884..d2e2fc925d73c 100644 --- a/google/cloud/securesourcemanager/v1/secure_source_manager_connection_idempotency_policy.h +++ b/google/cloud/securesourcemanager/v1/secure_source_manager_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -75,6 +77,21 @@ class SecureSourceManagerConnectionIdempotencyPolicy { virtual google::cloud::Idempotency TestIamPermissionsRepo( google::iam::v1::TestIamPermissionsRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/securitycentermanagement/BUILD.bazel b/google/cloud/securitycentermanagement/BUILD.bazel index f037e3967d9e5..e120e4e76d105 100644 --- a/google/cloud/securitycentermanagement/BUILD.bazel +++ b/google/cloud/securitycentermanagement/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/securitycentermanagement/v1:securitycentermanagement_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/securitycentermanagement/v1/internal/security_center_management_auth_decorator.cc b/google/cloud/securitycentermanagement/v1/internal/security_center_management_auth_decorator.cc index c0727c1fc458e..64756ee568c9a 100644 --- a/google/cloud/securitycentermanagement/v1/internal/security_center_management_auth_decorator.cc +++ b/google/cloud/securitycentermanagement/v1/internal/security_center_management_auth_decorator.cc @@ -277,6 +277,24 @@ SecurityCenterManagementAuth::UpdateSecurityCenterService( return child_->UpdateSecurityCenterService(context, options, request); } +StatusOr +SecurityCenterManagementAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +SecurityCenterManagementAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace securitycentermanagement_v1_internal } // namespace cloud diff --git a/google/cloud/securitycentermanagement/v1/internal/security_center_management_auth_decorator.h b/google/cloud/securitycentermanagement/v1/internal/security_center_management_auth_decorator.h index 6f1b8a2392693..9326588f830d8 100644 --- a/google/cloud/securitycentermanagement/v1/internal/security_center_management_auth_decorator.h +++ b/google/cloud/securitycentermanagement/v1/internal/security_center_management_auth_decorator.h @@ -196,6 +196,14 @@ class SecurityCenterManagementAuth : public SecurityCenterManagementStub { google::cloud::securitycentermanagement::v1:: UpdateSecurityCenterServiceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/securitycentermanagement/v1/internal/security_center_management_connection_impl.cc b/google/cloud/securitycentermanagement/v1/internal/security_center_management_connection_impl.cc index 54b4c17204151..05ff0ad1f4523 100644 --- a/google/cloud/securitycentermanagement/v1/internal/security_center_management_connection_impl.cc +++ b/google/cloud/securitycentermanagement/v1/internal/security_center_management_connection_impl.cc @@ -669,6 +669,55 @@ SecurityCenterManagementConnectionImpl::UpdateSecurityCenterService( *current, request, __func__); } +StreamRange +SecurityCenterManagementConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr< + securitycentermanagement_v1::SecurityCenterManagementRetryPolicy>( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +SecurityCenterManagementConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace securitycentermanagement_v1_internal } // namespace cloud diff --git a/google/cloud/securitycentermanagement/v1/internal/security_center_management_connection_impl.h b/google/cloud/securitycentermanagement/v1/internal/security_center_management_connection_impl.h index e804925576ed3..f8a0bd4bf4232 100644 --- a/google/cloud/securitycentermanagement/v1/internal/security_center_management_connection_impl.h +++ b/google/cloud/securitycentermanagement/v1/internal/security_center_management_connection_impl.h @@ -187,6 +187,12 @@ class SecurityCenterManagementConnectionImpl google::cloud::securitycentermanagement::v1:: UpdateSecurityCenterServiceRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr< diff --git a/google/cloud/securitycentermanagement/v1/internal/security_center_management_logging_decorator.cc b/google/cloud/securitycentermanagement/v1/internal/security_center_management_logging_decorator.cc index 5f1f1db883fe6..1aaf5ee8b9275 100644 --- a/google/cloud/securitycentermanagement/v1/internal/security_center_management_logging_decorator.cc +++ b/google/cloud/securitycentermanagement/v1/internal/security_center_management_logging_decorator.cc @@ -385,6 +385,30 @@ SecurityCenterManagementLogging::UpdateSecurityCenterService( context, options, request, __func__, tracing_options_); } +StatusOr +SecurityCenterManagementLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +SecurityCenterManagementLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace securitycentermanagement_v1_internal } // namespace cloud diff --git a/google/cloud/securitycentermanagement/v1/internal/security_center_management_logging_decorator.h b/google/cloud/securitycentermanagement/v1/internal/security_center_management_logging_decorator.h index 57b78020ca5fa..ddc86a639da66 100644 --- a/google/cloud/securitycentermanagement/v1/internal/security_center_management_logging_decorator.h +++ b/google/cloud/securitycentermanagement/v1/internal/security_center_management_logging_decorator.h @@ -196,6 +196,14 @@ class SecurityCenterManagementLogging : public SecurityCenterManagementStub { google::cloud::securitycentermanagement::v1:: UpdateSecurityCenterServiceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/securitycentermanagement/v1/internal/security_center_management_metadata_decorator.cc b/google/cloud/securitycentermanagement/v1/internal/security_center_management_metadata_decorator.cc index 57bcc7715ac95..1b502638ebadf 100644 --- a/google/cloud/securitycentermanagement/v1/internal/security_center_management_metadata_decorator.cc +++ b/google/cloud/securitycentermanagement/v1/internal/security_center_management_metadata_decorator.cc @@ -307,6 +307,24 @@ SecurityCenterManagementMetadata::UpdateSecurityCenterService( return child_->UpdateSecurityCenterService(context, options, request); } +StatusOr +SecurityCenterManagementMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +SecurityCenterManagementMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void SecurityCenterManagementMetadata::SetMetadata( grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/securitycentermanagement/v1/internal/security_center_management_metadata_decorator.h b/google/cloud/securitycentermanagement/v1/internal/security_center_management_metadata_decorator.h index 93c25ad1211fd..984498c2d93f7 100644 --- a/google/cloud/securitycentermanagement/v1/internal/security_center_management_metadata_decorator.h +++ b/google/cloud/securitycentermanagement/v1/internal/security_center_management_metadata_decorator.h @@ -197,6 +197,14 @@ class SecurityCenterManagementMetadata : public SecurityCenterManagementStub { google::cloud::securitycentermanagement::v1:: UpdateSecurityCenterServiceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/securitycentermanagement/v1/internal/security_center_management_stub.cc b/google/cloud/securitycentermanagement/v1/internal/security_center_management_stub.cc index 2a0ff3a317ceb..3e4375c9bfdb2 100644 --- a/google/cloud/securitycentermanagement/v1/internal/security_center_management_stub.cc +++ b/google/cloud/securitycentermanagement/v1/internal/security_center_management_stub.cc @@ -372,6 +372,30 @@ DefaultSecurityCenterManagementStub::UpdateSecurityCenterService( return response; } +StatusOr +DefaultSecurityCenterManagementStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultSecurityCenterManagementStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace securitycentermanagement_v1_internal } // namespace cloud diff --git a/google/cloud/securitycentermanagement/v1/internal/security_center_management_stub.h b/google/cloud/securitycentermanagement/v1/internal/security_center_management_stub.h index 85f17701101f1..a5e0453aa1815 100644 --- a/google/cloud/securitycentermanagement/v1/internal/security_center_management_stub.h +++ b/google/cloud/securitycentermanagement/v1/internal/security_center_management_stub.h @@ -23,6 +23,8 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include #include @@ -187,6 +189,15 @@ class SecurityCenterManagementStub { grpc::ClientContext& context, Options const& options, google::cloud::securitycentermanagement::v1:: UpdateSecurityCenterServiceRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultSecurityCenterManagementStub @@ -195,8 +206,11 @@ class DefaultSecurityCenterManagementStub explicit DefaultSecurityCenterManagementStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr @@ -355,10 +369,20 @@ class DefaultSecurityCenterManagementStub google::cloud::securitycentermanagement::v1:: UpdateSecurityCenterServiceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/securitycentermanagement/v1/internal/security_center_management_stub_factory.cc b/google/cloud/securitycentermanagement/v1/internal/security_center_management_stub_factory.cc index 611bddfe019d5..4eb0865866361 100644 --- a/google/cloud/securitycentermanagement/v1/internal/security_center_management_stub_factory.cc +++ b/google/cloud/securitycentermanagement/v1/internal/security_center_management_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -46,9 +47,11 @@ CreateDefaultSecurityCenterManagementStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::securitycentermanagement::v1:: SecurityCenterManagement::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/securitycentermanagement/v1/internal/security_center_management_tracing_connection.cc b/google/cloud/securitycentermanagement/v1/internal/security_center_management_tracing_connection.cc index 514bd29ddca1a..7f853dbbd7807 100644 --- a/google/cloud/securitycentermanagement/v1/internal/security_center_management_tracing_connection.cc +++ b/google/cloud/securitycentermanagement/v1/internal/security_center_management_tracing_connection.cc @@ -341,6 +341,28 @@ SecurityCenterManagementTracingConnection::UpdateSecurityCenterService( return internal::EndSpan(*span, child_->UpdateSecurityCenterService(request)); } +StreamRange +SecurityCenterManagementTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "securitycentermanagement_v1::SecurityCenterManagementConnection::" + "ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SecurityCenterManagementTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "securitycentermanagement_v1::SecurityCenterManagementConnection::" + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/securitycentermanagement/v1/internal/security_center_management_tracing_connection.h b/google/cloud/securitycentermanagement/v1/internal/security_center_management_tracing_connection.h index 84476ad8bef0a..4ad2407574b9a 100644 --- a/google/cloud/securitycentermanagement/v1/internal/security_center_management_tracing_connection.h +++ b/google/cloud/securitycentermanagement/v1/internal/security_center_management_tracing_connection.h @@ -178,6 +178,12 @@ class SecurityCenterManagementTracingConnection google::cloud::securitycentermanagement::v1:: UpdateSecurityCenterServiceRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr< securitycentermanagement_v1::SecurityCenterManagementConnection> diff --git a/google/cloud/securitycentermanagement/v1/internal/security_center_management_tracing_stub.cc b/google/cloud/securitycentermanagement/v1/internal/security_center_management_tracing_stub.cc index fca61d28f61b5..c2ccbb580b421 100644 --- a/google/cloud/securitycentermanagement/v1/internal/security_center_management_tracing_stub.cc +++ b/google/cloud/securitycentermanagement/v1/internal/security_center_management_tracing_stub.cc @@ -383,6 +383,32 @@ SecurityCenterManagementTracingStub::UpdateSecurityCenterService( child_->UpdateSecurityCenterService(context, options, request)); } +StatusOr +SecurityCenterManagementTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +SecurityCenterManagementTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/securitycentermanagement/v1/internal/security_center_management_tracing_stub.h b/google/cloud/securitycentermanagement/v1/internal/security_center_management_tracing_stub.h index 6272d136595d9..80d28004c4b08 100644 --- a/google/cloud/securitycentermanagement/v1/internal/security_center_management_tracing_stub.h +++ b/google/cloud/securitycentermanagement/v1/internal/security_center_management_tracing_stub.h @@ -198,6 +198,14 @@ class SecurityCenterManagementTracingStub google::cloud::securitycentermanagement::v1:: UpdateSecurityCenterServiceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/securitycentermanagement/v1/mocks/mock_security_center_management_connection.h b/google/cloud/securitycentermanagement/v1/mocks/mock_security_center_management_connection.h index 6d06a9d32c6e4..8961a69c7a201 100644 --- a/google/cloud/securitycentermanagement/v1/mocks/mock_security_center_management_connection.h +++ b/google/cloud/securitycentermanagement/v1/mocks/mock_security_center_management_connection.h @@ -208,6 +208,14 @@ class MockSecurityCenterManagementConnection (google::cloud::securitycentermanagement::v1:: UpdateSecurityCenterServiceRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/securitycentermanagement/v1/security_center_management_client.cc b/google/cloud/securitycentermanagement/v1/security_center_management_client.cc index 3aec8ba593508..b1de58607df29 100644 --- a/google/cloud/securitycentermanagement/v1/security_center_management_client.cc +++ b/google/cloud/securitycentermanagement/v1/security_center_management_client.cc @@ -496,6 +496,20 @@ SecurityCenterManagementClient::UpdateSecurityCenterService( return connection_->UpdateSecurityCenterService(request); } +StreamRange +SecurityCenterManagementClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +SecurityCenterManagementClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace securitycentermanagement_v1 } // namespace cloud diff --git a/google/cloud/securitycentermanagement/v1/security_center_management_client.h b/google/cloud/securitycentermanagement/v1/security_center_management_client.h index ae9a24a02a6b2..4bea6ed3301b1 100644 --- a/google/cloud/securitycentermanagement/v1/security_center_management_client.h +++ b/google/cloud/securitycentermanagement/v1/security_center_management_client.h @@ -1647,6 +1647,76 @@ class SecurityCenterManagementClient { UpdateSecurityCenterServiceRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/securitycentermanagement/v1/security_center_management_connection.cc b/google/cloud/securitycentermanagement/v1/security_center_management_connection.cc index a47890671b74a..afc73b14c459c 100644 --- a/google/cloud/securitycentermanagement/v1/security_center_management_connection.cc +++ b/google/cloud/securitycentermanagement/v1/security_center_management_connection.cc @@ -222,6 +222,20 @@ SecurityCenterManagementConnection::UpdateSecurityCenterService( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +SecurityCenterManagementConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +SecurityCenterManagementConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSecurityCenterManagementConnection(Options options) { internal::CheckExpectedOptions #include #include @@ -317,6 +318,12 @@ class SecurityCenterManagementConnection { UpdateSecurityCenterService( google::cloud::securitycentermanagement::v1:: UpdateSecurityCenterServiceRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/securitycentermanagement/v1/security_center_management_connection_idempotency_policy.cc b/google/cloud/securitycentermanagement/v1/security_center_management_connection_idempotency_policy.cc index d7be3188c9c31..1f11043090d3c 100644 --- a/google/cloud/securitycentermanagement/v1/security_center_management_connection_idempotency_policy.cc +++ b/google/cloud/securitycentermanagement/v1/security_center_management_connection_idempotency_policy.cc @@ -182,6 +182,16 @@ Idempotency SecurityCenterManagementConnectionIdempotencyPolicy:: return Idempotency::kNonIdempotent; } +Idempotency SecurityCenterManagementConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SecurityCenterManagementConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultSecurityCenterManagementConnectionIdempotencyPolicy() { return std::make_unique< diff --git a/google/cloud/securitycentermanagement/v1/security_center_management_connection_idempotency_policy.h b/google/cloud/securitycentermanagement/v1/security_center_management_connection_idempotency_policy.h index 7c67689bf29a0..27315750d8ca0 100644 --- a/google/cloud/securitycentermanagement/v1/security_center_management_connection_idempotency_policy.h +++ b/google/cloud/securitycentermanagement/v1/security_center_management_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -129,6 +130,12 @@ class SecurityCenterManagementConnectionIdempotencyPolicy { virtual google::cloud::Idempotency UpdateSecurityCenterService( google::cloud::securitycentermanagement::v1:: UpdateSecurityCenterServiceRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/servicedirectory/BUILD.bazel b/google/cloud/servicedirectory/BUILD.bazel index 77e33da3c8fa4..1ebcbd0860197 100644 --- a/google/cloud/servicedirectory/BUILD.bazel +++ b/google/cloud/servicedirectory/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/servicedirectory/v1:servicedirectory_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/servicedirectory/v1/internal/lookup_auth_decorator.cc b/google/cloud/servicedirectory/v1/internal/lookup_auth_decorator.cc index 9bfe4bf38c982..8232f7a4c7c88 100644 --- a/google/cloud/servicedirectory/v1/internal/lookup_auth_decorator.cc +++ b/google/cloud/servicedirectory/v1/internal/lookup_auth_decorator.cc @@ -40,6 +40,23 @@ LookupServiceAuth::ResolveService( return child_->ResolveService(context, options, request); } +StatusOr +LookupServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr LookupServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace servicedirectory_v1_internal } // namespace cloud diff --git a/google/cloud/servicedirectory/v1/internal/lookup_auth_decorator.h b/google/cloud/servicedirectory/v1/internal/lookup_auth_decorator.h index 9ca5fcc246e86..2c0681dbf74bd 100644 --- a/google/cloud/servicedirectory/v1/internal/lookup_auth_decorator.h +++ b/google/cloud/servicedirectory/v1/internal/lookup_auth_decorator.h @@ -44,6 +44,14 @@ class LookupServiceAuth : public LookupServiceStub { google::cloud::servicedirectory::v1::ResolveServiceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/servicedirectory/v1/internal/lookup_connection_impl.cc b/google/cloud/servicedirectory/v1/internal/lookup_connection_impl.cc index 7a8a835051261..817ddbc55967b 100644 --- a/google/cloud/servicedirectory/v1/internal/lookup_connection_impl.cc +++ b/google/cloud/servicedirectory/v1/internal/lookup_connection_impl.cc @@ -21,6 +21,7 @@ #include "google/cloud/background_threads.h" #include "google/cloud/common_options.h" #include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/retry_loop.h" #include #include @@ -76,6 +77,54 @@ LookupServiceConnectionImpl::ResolveService( *current, request, __func__); } +StreamRange +LookupServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +LookupServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace servicedirectory_v1_internal } // namespace cloud diff --git a/google/cloud/servicedirectory/v1/internal/lookup_connection_impl.h b/google/cloud/servicedirectory/v1/internal/lookup_connection_impl.h index ef559522cb206..e932b358af595 100644 --- a/google/cloud/servicedirectory/v1/internal/lookup_connection_impl.h +++ b/google/cloud/servicedirectory/v1/internal/lookup_connection_impl.h @@ -28,6 +28,7 @@ #include "google/cloud/backoff_policy.h" #include "google/cloud/options.h" #include "google/cloud/status_or.h" +#include "google/cloud/stream_range.h" #include "google/cloud/version.h" #include @@ -53,6 +54,12 @@ class LookupServiceConnectionImpl google::cloud::servicedirectory::v1::ResolveServiceRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/servicedirectory/v1/internal/lookup_logging_decorator.cc b/google/cloud/servicedirectory/v1/internal/lookup_logging_decorator.cc index 7cbc3df7f44b7..e67fd31703f6d 100644 --- a/google/cloud/servicedirectory/v1/internal/lookup_logging_decorator.cc +++ b/google/cloud/servicedirectory/v1/internal/lookup_logging_decorator.cc @@ -48,6 +48,29 @@ LookupServiceLogging::ResolveService( context, options, request, __func__, tracing_options_); } +StatusOr +LookupServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr LookupServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace servicedirectory_v1_internal } // namespace cloud diff --git a/google/cloud/servicedirectory/v1/internal/lookup_logging_decorator.h b/google/cloud/servicedirectory/v1/internal/lookup_logging_decorator.h index a5cdf377e9a23..9db99dd7fde0a 100644 --- a/google/cloud/servicedirectory/v1/internal/lookup_logging_decorator.h +++ b/google/cloud/servicedirectory/v1/internal/lookup_logging_decorator.h @@ -44,6 +44,14 @@ class LookupServiceLogging : public LookupServiceStub { google::cloud::servicedirectory::v1::ResolveServiceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/servicedirectory/v1/internal/lookup_metadata_decorator.cc b/google/cloud/servicedirectory/v1/internal/lookup_metadata_decorator.cc index 064d1827bc820..385a023edfcf3 100644 --- a/google/cloud/servicedirectory/v1/internal/lookup_metadata_decorator.cc +++ b/google/cloud/servicedirectory/v1/internal/lookup_metadata_decorator.cc @@ -53,6 +53,23 @@ LookupServiceMetadata::ResolveService( return child_->ResolveService(context, options, request); } +StatusOr +LookupServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr LookupServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void LookupServiceMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/servicedirectory/v1/internal/lookup_metadata_decorator.h b/google/cloud/servicedirectory/v1/internal/lookup_metadata_decorator.h index f1cc7f1eaf0ad..dd2eee8f9cb3e 100644 --- a/google/cloud/servicedirectory/v1/internal/lookup_metadata_decorator.h +++ b/google/cloud/servicedirectory/v1/internal/lookup_metadata_decorator.h @@ -44,6 +44,14 @@ class LookupServiceMetadata : public LookupServiceStub { google::cloud::servicedirectory::v1::ResolveServiceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/servicedirectory/v1/internal/lookup_stub.cc b/google/cloud/servicedirectory/v1/internal/lookup_stub.cc index 7779a31157e93..401d2dcb3a864 100644 --- a/google/cloud/servicedirectory/v1/internal/lookup_stub.cc +++ b/google/cloud/servicedirectory/v1/internal/lookup_stub.cc @@ -42,6 +42,30 @@ DefaultLookupServiceStub::ResolveService( return response; } +StatusOr +DefaultLookupServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultLookupServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace servicedirectory_v1_internal } // namespace cloud diff --git a/google/cloud/servicedirectory/v1/internal/lookup_stub.h b/google/cloud/servicedirectory/v1/internal/lookup_stub.h index 99281e160c1cb..d969650c6b397 100644 --- a/google/cloud/servicedirectory/v1/internal/lookup_stub.h +++ b/google/cloud/servicedirectory/v1/internal/lookup_stub.h @@ -22,6 +22,8 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include #include @@ -40,6 +42,15 @@ class LookupServiceStub { grpc::ClientContext& context, Options const& options, google::cloud::servicedirectory::v1::ResolveServiceRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultLookupServiceStub : public LookupServiceStub { @@ -47,8 +58,11 @@ class DefaultLookupServiceStub : public LookupServiceStub { explicit DefaultLookupServiceStub( std::unique_ptr< google::cloud::servicedirectory::v1::LookupService::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ResolveService( @@ -56,10 +70,20 @@ class DefaultLookupServiceStub : public LookupServiceStub { google::cloud::servicedirectory::v1::ResolveServiceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr< google::cloud::servicedirectory::v1::LookupService::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/servicedirectory/v1/internal/lookup_stub_factory.cc b/google/cloud/servicedirectory/v1/internal/lookup_stub_factory.cc index bf8ee053e0562..591267c340d6b 100644 --- a/google/cloud/servicedirectory/v1/internal/lookup_stub_factory.cc +++ b/google/cloud/servicedirectory/v1/internal/lookup_stub_factory.cc @@ -28,6 +28,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -44,8 +45,11 @@ std::shared_ptr CreateDefaultLookupServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::servicedirectory::v1::LookupService::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + std::make_shared( + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = diff --git a/google/cloud/servicedirectory/v1/internal/lookup_tracing_connection.cc b/google/cloud/servicedirectory/v1/internal/lookup_tracing_connection.cc index d9b7122b561ef..98c928e7ac94a 100644 --- a/google/cloud/servicedirectory/v1/internal/lookup_tracing_connection.cc +++ b/google/cloud/servicedirectory/v1/internal/lookup_tracing_connection.cc @@ -18,6 +18,7 @@ #include "google/cloud/servicedirectory/v1/internal/lookup_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" #include #include @@ -41,6 +42,26 @@ LookupServiceTracingConnection::ResolveService( return internal::EndSpan(*span, child_->ResolveService(request)); } +StreamRange +LookupServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "servicedirectory_v1::LookupServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +LookupServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "servicedirectory_v1::LookupServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/servicedirectory/v1/internal/lookup_tracing_connection.h b/google/cloud/servicedirectory/v1/internal/lookup_tracing_connection.h index 3726c7366b4ea..e5618e5e819c5 100644 --- a/google/cloud/servicedirectory/v1/internal/lookup_tracing_connection.h +++ b/google/cloud/servicedirectory/v1/internal/lookup_tracing_connection.h @@ -45,6 +45,12 @@ class LookupServiceTracingConnection google::cloud::servicedirectory::v1::ResolveServiceRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/servicedirectory/v1/internal/lookup_tracing_stub.cc b/google/cloud/servicedirectory/v1/internal/lookup_tracing_stub.cc index b118b8014f07b..e2a8eb0fb436b 100644 --- a/google/cloud/servicedirectory/v1/internal/lookup_tracing_stub.cc +++ b/google/cloud/servicedirectory/v1/internal/lookup_tracing_stub.cc @@ -44,6 +44,30 @@ LookupServiceTracingStub::ResolveService( child_->ResolveService(context, options, request)); } +StatusOr +LookupServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.servicedirectory.v1.LookupService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +LookupServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.servicedirectory.v1.LookupService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeLookupServiceTracingStub( diff --git a/google/cloud/servicedirectory/v1/internal/lookup_tracing_stub.h b/google/cloud/servicedirectory/v1/internal/lookup_tracing_stub.h index a711fe7ff0ffa..fd5b16d914776 100644 --- a/google/cloud/servicedirectory/v1/internal/lookup_tracing_stub.h +++ b/google/cloud/servicedirectory/v1/internal/lookup_tracing_stub.h @@ -44,6 +44,14 @@ class LookupServiceTracingStub : public LookupServiceStub { google::cloud::servicedirectory::v1::ResolveServiceRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/servicedirectory/v1/internal/registration_auth_decorator.cc b/google/cloud/servicedirectory/v1/internal/registration_auth_decorator.cc index 2fba03d194578..47e9734dfefd1 100644 --- a/google/cloud/servicedirectory/v1/internal/registration_auth_decorator.cc +++ b/google/cloud/servicedirectory/v1/internal/registration_auth_decorator.cc @@ -191,6 +191,24 @@ RegistrationServiceAuth::TestIamPermissions( return child_->TestIamPermissions(context, options, request); } +StatusOr +RegistrationServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr +RegistrationServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace servicedirectory_v1_internal } // namespace cloud diff --git a/google/cloud/servicedirectory/v1/internal/registration_auth_decorator.h b/google/cloud/servicedirectory/v1/internal/registration_auth_decorator.h index 1bea8906a0c99..1663e37e2fae4 100644 --- a/google/cloud/servicedirectory/v1/internal/registration_auth_decorator.h +++ b/google/cloud/servicedirectory/v1/internal/registration_auth_decorator.h @@ -126,6 +126,14 @@ class RegistrationServiceAuth : public RegistrationServiceStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/servicedirectory/v1/internal/registration_connection_impl.cc b/google/cloud/servicedirectory/v1/internal/registration_connection_impl.cc index 28eb2c80232b1..c6b385208c569 100644 --- a/google/cloud/servicedirectory/v1/internal/registration_connection_impl.cc +++ b/google/cloud/servicedirectory/v1/internal/registration_connection_impl.cc @@ -394,6 +394,55 @@ RegistrationServiceConnectionImpl::TestIamPermissions( *current, request, __func__); } +StreamRange +RegistrationServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = + std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +RegistrationServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace servicedirectory_v1_internal } // namespace cloud diff --git a/google/cloud/servicedirectory/v1/internal/registration_connection_impl.h b/google/cloud/servicedirectory/v1/internal/registration_connection_impl.h index 7de2583493dc9..96cd44504a5f8 100644 --- a/google/cloud/servicedirectory/v1/internal/registration_connection_impl.h +++ b/google/cloud/servicedirectory/v1/internal/registration_connection_impl.h @@ -119,6 +119,12 @@ class RegistrationServiceConnectionImpl StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/servicedirectory/v1/internal/registration_logging_decorator.cc b/google/cloud/servicedirectory/v1/internal/registration_logging_decorator.cc index 691ef74d918bb..34ae7ecaf8359 100644 --- a/google/cloud/servicedirectory/v1/internal/registration_logging_decorator.cc +++ b/google/cloud/servicedirectory/v1/internal/registration_logging_decorator.cc @@ -264,6 +264,30 @@ RegistrationServiceLogging::TestIamPermissions( context, options, request, __func__, tracing_options_); } +StatusOr +RegistrationServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +RegistrationServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace servicedirectory_v1_internal } // namespace cloud diff --git a/google/cloud/servicedirectory/v1/internal/registration_logging_decorator.h b/google/cloud/servicedirectory/v1/internal/registration_logging_decorator.h index 71f9ec1e30bd2..7b7dabe9c5305 100644 --- a/google/cloud/servicedirectory/v1/internal/registration_logging_decorator.h +++ b/google/cloud/servicedirectory/v1/internal/registration_logging_decorator.h @@ -126,6 +126,14 @@ class RegistrationServiceLogging : public RegistrationServiceStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/servicedirectory/v1/internal/registration_metadata_decorator.cc b/google/cloud/servicedirectory/v1/internal/registration_metadata_decorator.cc index 1a2b43345c9c9..da21c765a77df 100644 --- a/google/cloud/servicedirectory/v1/internal/registration_metadata_decorator.cc +++ b/google/cloud/servicedirectory/v1/internal/registration_metadata_decorator.cc @@ -210,6 +210,24 @@ RegistrationServiceMetadata::TestIamPermissions( return child_->TestIamPermissions(context, options, request); } +StatusOr +RegistrationServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +RegistrationServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void RegistrationServiceMetadata::SetMetadata( grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/servicedirectory/v1/internal/registration_metadata_decorator.h b/google/cloud/servicedirectory/v1/internal/registration_metadata_decorator.h index 63174b81a9042..d173c4bd5fb64 100644 --- a/google/cloud/servicedirectory/v1/internal/registration_metadata_decorator.h +++ b/google/cloud/servicedirectory/v1/internal/registration_metadata_decorator.h @@ -127,6 +127,14 @@ class RegistrationServiceMetadata : public RegistrationServiceStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/servicedirectory/v1/internal/registration_stub.cc b/google/cloud/servicedirectory/v1/internal/registration_stub.cc index 764b21f05e115..f8457526979ef 100644 --- a/google/cloud/servicedirectory/v1/internal/registration_stub.cc +++ b/google/cloud/servicedirectory/v1/internal/registration_stub.cc @@ -244,6 +244,30 @@ DefaultRegistrationServiceStub::TestIamPermissions( return response; } +StatusOr +DefaultRegistrationServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultRegistrationServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace servicedirectory_v1_internal } // namespace cloud diff --git a/google/cloud/servicedirectory/v1/internal/registration_stub.h b/google/cloud/servicedirectory/v1/internal/registration_stub.h index 24a3e582e5536..065d02ed54d1a 100644 --- a/google/cloud/servicedirectory/v1/internal/registration_stub.h +++ b/google/cloud/servicedirectory/v1/internal/registration_stub.h @@ -22,6 +22,8 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include #include @@ -127,6 +129,15 @@ class RegistrationServiceStub { TestIamPermissions( grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultRegistrationServiceStub : public RegistrationServiceStub { @@ -134,8 +145,11 @@ class DefaultRegistrationServiceStub : public RegistrationServiceStub { explicit DefaultRegistrationServiceStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr CreateNamespace( grpc::ClientContext& context, Options const& options, @@ -225,10 +239,20 @@ class DefaultRegistrationServiceStub : public RegistrationServiceStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr< google::cloud::servicedirectory::v1::RegistrationService::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/servicedirectory/v1/internal/registration_stub_factory.cc b/google/cloud/servicedirectory/v1/internal/registration_stub_factory.cc index 6e5b77d7fb185..ed9032d70407c 100644 --- a/google/cloud/servicedirectory/v1/internal/registration_stub_factory.cc +++ b/google/cloud/servicedirectory/v1/internal/registration_stub_factory.cc @@ -28,6 +28,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -45,9 +46,11 @@ std::shared_ptr CreateDefaultRegistrationServiceStub( auto service_grpc_stub = google::cloud::servicedirectory::v1::RegistrationService::NewStub( channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), diff --git a/google/cloud/servicedirectory/v1/internal/registration_tracing_connection.cc b/google/cloud/servicedirectory/v1/internal/registration_tracing_connection.cc index 5431afefdd3a2..5e5d8da1e8ae8 100644 --- a/google/cloud/servicedirectory/v1/internal/registration_tracing_connection.cc +++ b/google/cloud/servicedirectory/v1/internal/registration_tracing_connection.cc @@ -204,6 +204,26 @@ RegistrationServiceTracingConnection::TestIamPermissions( return internal::EndSpan(*span, child_->TestIamPermissions(request)); } +StreamRange +RegistrationServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "servicedirectory_v1::RegistrationServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +RegistrationServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "servicedirectory_v1::RegistrationServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/servicedirectory/v1/internal/registration_tracing_connection.h b/google/cloud/servicedirectory/v1/internal/registration_tracing_connection.h index 2ad5c7d9ecc1b..96777e2ef8dbf 100644 --- a/google/cloud/servicedirectory/v1/internal/registration_tracing_connection.h +++ b/google/cloud/servicedirectory/v1/internal/registration_tracing_connection.h @@ -110,6 +110,12 @@ class RegistrationServiceTracingConnection StatusOr TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/servicedirectory/v1/internal/registration_tracing_stub.cc b/google/cloud/servicedirectory/v1/internal/registration_tracing_stub.cc index 865bed063f34a..d7009eab91e0f 100644 --- a/google/cloud/servicedirectory/v1/internal/registration_tracing_stub.cc +++ b/google/cloud/servicedirectory/v1/internal/registration_tracing_stub.cc @@ -250,6 +250,30 @@ RegistrationServiceTracingStub::TestIamPermissions( context, *span, child_->TestIamPermissions(context, options, request)); } +StatusOr +RegistrationServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.servicedirectory.v1.RegistrationService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +RegistrationServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.servicedirectory.v1.RegistrationService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeRegistrationServiceTracingStub( diff --git a/google/cloud/servicedirectory/v1/internal/registration_tracing_stub.h b/google/cloud/servicedirectory/v1/internal/registration_tracing_stub.h index 6c1a5196d8d03..11b373a2493d2 100644 --- a/google/cloud/servicedirectory/v1/internal/registration_tracing_stub.h +++ b/google/cloud/servicedirectory/v1/internal/registration_tracing_stub.h @@ -127,6 +127,14 @@ class RegistrationServiceTracingStub : public RegistrationServiceStub { grpc::ClientContext& context, Options const& options, google::iam::v1::TestIamPermissionsRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/servicedirectory/v1/lookup_client.cc b/google/cloud/servicedirectory/v1/lookup_client.cc index abde06d3b3f77..816b119d2f41b 100644 --- a/google/cloud/servicedirectory/v1/lookup_client.cc +++ b/google/cloud/servicedirectory/v1/lookup_client.cc @@ -40,6 +40,19 @@ LookupServiceClient::ResolveService( return connection_->ResolveService(request); } +StreamRange +LookupServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr LookupServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace servicedirectory_v1 } // namespace cloud diff --git a/google/cloud/servicedirectory/v1/lookup_client.h b/google/cloud/servicedirectory/v1/lookup_client.h index a5f60e8ac8973..92cb08126921d 100644 --- a/google/cloud/servicedirectory/v1/lookup_client.h +++ b/google/cloud/servicedirectory/v1/lookup_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -120,6 +121,76 @@ class LookupServiceClient { google::cloud::servicedirectory::v1::ResolveServiceRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/servicedirectory/v1/lookup_connection.cc b/google/cloud/servicedirectory/v1/lookup_connection.cc index 67cd206d522db..d2747038e4175 100644 --- a/google/cloud/servicedirectory/v1/lookup_connection.cc +++ b/google/cloud/servicedirectory/v1/lookup_connection.cc @@ -26,6 +26,7 @@ #include "google/cloud/common_options.h" #include "google/cloud/credentials.h" #include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" #include "google/cloud/internal/unified_grpc_credentials.h" #include #include @@ -43,6 +44,20 @@ LookupServiceConnection::ResolveService( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +LookupServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +LookupServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeLookupServiceConnection( Options options) { internal::CheckExpectedOptions #include #include @@ -187,6 +189,12 @@ class LookupServiceConnection { ResolveService( google::cloud::servicedirectory::v1::ResolveServiceRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/servicedirectory/v1/lookup_connection_idempotency_policy.cc b/google/cloud/servicedirectory/v1/lookup_connection_idempotency_policy.cc index 08ac44f0f80df..7d5bbb9abff3b 100644 --- a/google/cloud/servicedirectory/v1/lookup_connection_idempotency_policy.cc +++ b/google/cloud/servicedirectory/v1/lookup_connection_idempotency_policy.cc @@ -39,6 +39,16 @@ Idempotency LookupServiceConnectionIdempotencyPolicy::ResolveService( return Idempotency::kNonIdempotent; } +Idempotency LookupServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency LookupServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultLookupServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/servicedirectory/v1/lookup_connection_idempotency_policy.h b/google/cloud/servicedirectory/v1/lookup_connection_idempotency_policy.h index bf0feb306a5a7..ad5130c57d640 100644 --- a/google/cloud/servicedirectory/v1/lookup_connection_idempotency_policy.h +++ b/google/cloud/servicedirectory/v1/lookup_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -40,6 +41,12 @@ class LookupServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ResolveService( google::cloud::servicedirectory::v1::ResolveServiceRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/servicedirectory/v1/mocks/mock_lookup_connection.h b/google/cloud/servicedirectory/v1/mocks/mock_lookup_connection.h index a88a8fc138209..856bd451b1e44 100644 --- a/google/cloud/servicedirectory/v1/mocks/mock_lookup_connection.h +++ b/google/cloud/servicedirectory/v1/mocks/mock_lookup_connection.h @@ -53,6 +53,14 @@ class MockLookupServiceConnection (google::cloud::servicedirectory::v1::ResolveServiceRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/servicedirectory/v1/mocks/mock_registration_connection.h b/google/cloud/servicedirectory/v1/mocks/mock_registration_connection.h index 11064f4dda873..14cb739d1397a 100644 --- a/google/cloud/servicedirectory/v1/mocks/mock_registration_connection.h +++ b/google/cloud/servicedirectory/v1/mocks/mock_registration_connection.h @@ -143,6 +143,14 @@ class MockRegistrationServiceConnection TestIamPermissions, (google::iam::v1::TestIamPermissionsRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/servicedirectory/v1/registration_client.cc b/google/cloud/servicedirectory/v1/registration_client.cc index 2c186f1c59a8a..f7ef638be1d87 100644 --- a/google/cloud/servicedirectory/v1/registration_client.cc +++ b/google/cloud/servicedirectory/v1/registration_client.cc @@ -315,6 +315,20 @@ RegistrationServiceClient::TestIamPermissions( return connection_->TestIamPermissions(request); } +StreamRange +RegistrationServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +RegistrationServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace servicedirectory_v1 } // namespace cloud diff --git a/google/cloud/servicedirectory/v1/registration_client.h b/google/cloud/servicedirectory/v1/registration_client.h index 7e60a01c3cfd7..3afa48d43d8c2 100644 --- a/google/cloud/servicedirectory/v1/registration_client.h +++ b/google/cloud/servicedirectory/v1/registration_client.h @@ -1120,6 +1120,76 @@ class RegistrationServiceClient { google::iam::v1::TestIamPermissionsRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/servicedirectory/v1/registration_connection.cc b/google/cloud/servicedirectory/v1/registration_connection.cc index 07aac809bebae..8f1c71e1d131f 100644 --- a/google/cloud/servicedirectory/v1/registration_connection.cc +++ b/google/cloud/servicedirectory/v1/registration_connection.cc @@ -147,6 +147,20 @@ RegistrationServiceConnection::TestIamPermissions( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +RegistrationServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +RegistrationServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeRegistrationServiceConnection(Options options) { internal::CheckExpectedOptions #include #include @@ -254,6 +255,12 @@ class RegistrationServiceConnection { virtual StatusOr TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/servicedirectory/v1/registration_connection_idempotency_policy.cc b/google/cloud/servicedirectory/v1/registration_connection_idempotency_policy.cc index 4c4d607e1c3d1..75f5a3da02d70 100644 --- a/google/cloud/servicedirectory/v1/registration_connection_idempotency_policy.cc +++ b/google/cloud/servicedirectory/v1/registration_connection_idempotency_policy.cc @@ -126,6 +126,16 @@ Idempotency RegistrationServiceConnectionIdempotencyPolicy::TestIamPermissions( return Idempotency::kIdempotent; } +Idempotency RegistrationServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency RegistrationServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultRegistrationServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/servicedirectory/v1/registration_connection_idempotency_policy.h b/google/cloud/servicedirectory/v1/registration_connection_idempotency_policy.h index f0bedd5a45b54..0697b4ce310e0 100644 --- a/google/cloud/servicedirectory/v1/registration_connection_idempotency_policy.h +++ b/google/cloud/servicedirectory/v1/registration_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -96,6 +97,12 @@ class RegistrationServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency TestIamPermissions( google::iam::v1::TestIamPermissionsRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/servicehealth/BUILD.bazel b/google/cloud/servicehealth/BUILD.bazel index aa1ac8cf6011b..139a4986d56a4 100644 --- a/google/cloud/servicehealth/BUILD.bazel +++ b/google/cloud/servicehealth/BUILD.bazel @@ -23,6 +23,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/servicehealth/logging/v1:logging_cc_grpc", "@com_google_googleapis//google/cloud/servicehealth/v1:servicehealth_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/servicehealth/v1/internal/service_health_auth_decorator.cc b/google/cloud/servicehealth/v1/internal/service_health_auth_decorator.cc index 4de321220953a..dc7e7ae4c0ee8 100644 --- a/google/cloud/servicehealth/v1/internal/service_health_auth_decorator.cc +++ b/google/cloud/servicehealth/v1/internal/service_health_auth_decorator.cc @@ -88,6 +88,23 @@ ServiceHealthAuth::GetOrganizationImpact( return child_->GetOrganizationImpact(context, options, request); } +StatusOr +ServiceHealthAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr ServiceHealthAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace servicehealth_v1_internal } // namespace cloud diff --git a/google/cloud/servicehealth/v1/internal/service_health_auth_decorator.h b/google/cloud/servicehealth/v1/internal/service_health_auth_decorator.h index 126ed654bca51..d335fcfbd1595 100644 --- a/google/cloud/servicehealth/v1/internal/service_health_auth_decorator.h +++ b/google/cloud/servicehealth/v1/internal/service_health_auth_decorator.h @@ -72,6 +72,14 @@ class ServiceHealthAuth : public ServiceHealthStub { google::cloud::servicehealth::v1::GetOrganizationImpactRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/servicehealth/v1/internal/service_health_connection_impl.cc b/google/cloud/servicehealth/v1/internal/service_health_connection_impl.cc index b2e6233dbe957..f66d2c2f8e5db 100644 --- a/google/cloud/servicehealth/v1/internal/service_health_connection_impl.cc +++ b/google/cloud/servicehealth/v1/internal/service_health_connection_impl.cc @@ -214,6 +214,54 @@ ServiceHealthConnectionImpl::GetOrganizationImpact( *current, request, __func__); } +StreamRange +ServiceHealthConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +ServiceHealthConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace servicehealth_v1_internal } // namespace cloud diff --git a/google/cloud/servicehealth/v1/internal/service_health_connection_impl.h b/google/cloud/servicehealth/v1/internal/service_health_connection_impl.h index 1c7bb6a2d9ebf..8ea87f768c9b6 100644 --- a/google/cloud/servicehealth/v1/internal/service_health_connection_impl.h +++ b/google/cloud/servicehealth/v1/internal/service_health_connection_impl.h @@ -76,6 +76,12 @@ class ServiceHealthConnectionImpl google::cloud::servicehealth::v1::GetOrganizationImpactRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/servicehealth/v1/internal/service_health_logging_decorator.cc b/google/cloud/servicehealth/v1/internal/service_health_logging_decorator.cc index 09482d30b6fba..e2c7c208fc26d 100644 --- a/google/cloud/servicehealth/v1/internal/service_health_logging_decorator.cc +++ b/google/cloud/servicehealth/v1/internal/service_health_logging_decorator.cc @@ -119,6 +119,29 @@ ServiceHealthLogging::GetOrganizationImpact( context, options, request, __func__, tracing_options_); } +StatusOr +ServiceHealthLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ServiceHealthLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace servicehealth_v1_internal } // namespace cloud diff --git a/google/cloud/servicehealth/v1/internal/service_health_logging_decorator.h b/google/cloud/servicehealth/v1/internal/service_health_logging_decorator.h index 0d30415667f49..3e16bc80de835 100644 --- a/google/cloud/servicehealth/v1/internal/service_health_logging_decorator.h +++ b/google/cloud/servicehealth/v1/internal/service_health_logging_decorator.h @@ -72,6 +72,14 @@ class ServiceHealthLogging : public ServiceHealthStub { google::cloud::servicehealth::v1::GetOrganizationImpactRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/servicehealth/v1/internal/service_health_metadata_decorator.cc b/google/cloud/servicehealth/v1/internal/service_health_metadata_decorator.cc index 4b6b1e3acfb34..61f5e1ca8a421 100644 --- a/google/cloud/servicehealth/v1/internal/service_health_metadata_decorator.cc +++ b/google/cloud/servicehealth/v1/internal/service_health_metadata_decorator.cc @@ -102,6 +102,23 @@ ServiceHealthMetadata::GetOrganizationImpact( return child_->GetOrganizationImpact(context, options, request); } +StatusOr +ServiceHealthMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr ServiceHealthMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void ServiceHealthMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/servicehealth/v1/internal/service_health_metadata_decorator.h b/google/cloud/servicehealth/v1/internal/service_health_metadata_decorator.h index 3e3d922c5100c..fce7cbdc2fd2e 100644 --- a/google/cloud/servicehealth/v1/internal/service_health_metadata_decorator.h +++ b/google/cloud/servicehealth/v1/internal/service_health_metadata_decorator.h @@ -72,6 +72,14 @@ class ServiceHealthMetadata : public ServiceHealthStub { google::cloud::servicehealth::v1::GetOrganizationImpactRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/servicehealth/v1/internal/service_health_stub.cc b/google/cloud/servicehealth/v1/internal/service_health_stub.cc index c43178b968173..4783f0eecb6a5 100644 --- a/google/cloud/servicehealth/v1/internal/service_health_stub.cc +++ b/google/cloud/servicehealth/v1/internal/service_health_stub.cc @@ -108,6 +108,30 @@ DefaultServiceHealthStub::GetOrganizationImpact( return response; } +StatusOr +DefaultServiceHealthStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultServiceHealthStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace servicehealth_v1_internal } // namespace cloud diff --git a/google/cloud/servicehealth/v1/internal/service_health_stub.h b/google/cloud/servicehealth/v1/internal/service_health_stub.h index 39a66927dfa71..7f05beb3dd3c0 100644 --- a/google/cloud/servicehealth/v1/internal/service_health_stub.h +++ b/google/cloud/servicehealth/v1/internal/service_health_stub.h @@ -22,6 +22,8 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include #include @@ -69,6 +71,15 @@ class ServiceHealthStub { grpc::ClientContext& context, Options const& options, google::cloud::servicehealth::v1::GetOrganizationImpactRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultServiceHealthStub : public ServiceHealthStub { @@ -76,8 +87,11 @@ class DefaultServiceHealthStub : public ServiceHealthStub { explicit DefaultServiceHealthStub( std::unique_ptr< google::cloud::servicehealth::v1::ServiceHealth::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListEvents( grpc::ClientContext& context, Options const& options, @@ -113,10 +127,20 @@ class DefaultServiceHealthStub : public ServiceHealthStub { google::cloud::servicehealth::v1::GetOrganizationImpactRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr< google::cloud::servicehealth::v1::ServiceHealth::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/servicehealth/v1/internal/service_health_stub_factory.cc b/google/cloud/servicehealth/v1/internal/service_health_stub_factory.cc index 81a64a7a9a157..114a9226b78f0 100644 --- a/google/cloud/servicehealth/v1/internal/service_health_stub_factory.cc +++ b/google/cloud/servicehealth/v1/internal/service_health_stub_factory.cc @@ -28,6 +28,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -44,8 +45,11 @@ std::shared_ptr CreateDefaultServiceHealthStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::servicehealth::v1::ServiceHealth::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + std::make_shared( + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = diff --git a/google/cloud/servicehealth/v1/internal/service_health_tracing_connection.cc b/google/cloud/servicehealth/v1/internal/service_health_tracing_connection.cc index 00c21d5065ad0..16e0d84caa8cc 100644 --- a/google/cloud/servicehealth/v1/internal/service_health_tracing_connection.cc +++ b/google/cloud/servicehealth/v1/internal/service_health_tracing_connection.cc @@ -97,6 +97,26 @@ ServiceHealthTracingConnection::GetOrganizationImpact( return internal::EndSpan(*span, child_->GetOrganizationImpact(request)); } +StreamRange +ServiceHealthTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "servicehealth_v1::ServiceHealthConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +ServiceHealthTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "servicehealth_v1::ServiceHealthConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/servicehealth/v1/internal/service_health_tracing_connection.h b/google/cloud/servicehealth/v1/internal/service_health_tracing_connection.h index b18c1af620063..b8c1d0466d901 100644 --- a/google/cloud/servicehealth/v1/internal/service_health_tracing_connection.h +++ b/google/cloud/servicehealth/v1/internal/service_health_tracing_connection.h @@ -67,6 +67,12 @@ class ServiceHealthTracingConnection google::cloud::servicehealth::v1::GetOrganizationImpactRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/servicehealth/v1/internal/service_health_tracing_stub.cc b/google/cloud/servicehealth/v1/internal/service_health_tracing_stub.cc index b197203b99748..224dace0ccbad 100644 --- a/google/cloud/servicehealth/v1/internal/service_health_tracing_stub.cc +++ b/google/cloud/servicehealth/v1/internal/service_health_tracing_stub.cc @@ -110,6 +110,30 @@ ServiceHealthTracingStub::GetOrganizationImpact( context, *span, child_->GetOrganizationImpact(context, options, request)); } +StatusOr +ServiceHealthTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.servicehealth.v1.ServiceHealth", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +ServiceHealthTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.servicehealth.v1.ServiceHealth", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeServiceHealthTracingStub( diff --git a/google/cloud/servicehealth/v1/internal/service_health_tracing_stub.h b/google/cloud/servicehealth/v1/internal/service_health_tracing_stub.h index 50f6024e1a928..80b4bddbfc86c 100644 --- a/google/cloud/servicehealth/v1/internal/service_health_tracing_stub.h +++ b/google/cloud/servicehealth/v1/internal/service_health_tracing_stub.h @@ -72,6 +72,14 @@ class ServiceHealthTracingStub : public ServiceHealthStub { google::cloud::servicehealth::v1::GetOrganizationImpactRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/servicehealth/v1/mocks/mock_service_health_connection.h b/google/cloud/servicehealth/v1/mocks/mock_service_health_connection.h index 65e004ba3d0cb..6fbec18c0c87a 100644 --- a/google/cloud/servicehealth/v1/mocks/mock_service_health_connection.h +++ b/google/cloud/servicehealth/v1/mocks/mock_service_health_connection.h @@ -83,6 +83,14 @@ class MockServiceHealthConnection (google::cloud::servicehealth::v1::GetOrganizationImpactRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/servicehealth/v1/service_health_client.cc b/google/cloud/servicehealth/v1/service_health_client.cc index 78412eb88794d..382496f961a0b 100644 --- a/google/cloud/servicehealth/v1/service_health_client.cc +++ b/google/cloud/servicehealth/v1/service_health_client.cc @@ -132,6 +132,19 @@ ServiceHealthClient::GetOrganizationImpact( return connection_->GetOrganizationImpact(request); } +StreamRange +ServiceHealthClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr ServiceHealthClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace servicehealth_v1 } // namespace cloud diff --git a/google/cloud/servicehealth/v1/service_health_client.h b/google/cloud/servicehealth/v1/service_health_client.h index 1383907a752be..b7a8f443aa739 100644 --- a/google/cloud/servicehealth/v1/service_health_client.h +++ b/google/cloud/servicehealth/v1/service_health_client.h @@ -25,6 +25,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -531,6 +532,76 @@ class ServiceHealthClient { request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/servicehealth/v1/service_health_connection.cc b/google/cloud/servicehealth/v1/service_health_connection.cc index b73a5a6dfeccc..90eb7d0c22c1e 100644 --- a/google/cloud/servicehealth/v1/service_health_connection.cc +++ b/google/cloud/servicehealth/v1/service_health_connection.cc @@ -80,6 +80,20 @@ ServiceHealthConnection::GetOrganizationImpact( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +ServiceHealthConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +ServiceHealthConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeServiceHealthConnection( Options options) { internal::CheckExpectedOptions #include #include @@ -205,6 +206,12 @@ class ServiceHealthConnection { GetOrganizationImpact( google::cloud::servicehealth::v1::GetOrganizationImpactRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/servicehealth/v1/service_health_connection_idempotency_policy.cc b/google/cloud/servicehealth/v1/service_health_connection_idempotency_policy.cc index 128842837749d..03af6ed77ea65 100644 --- a/google/cloud/servicehealth/v1/service_health_connection_idempotency_policy.cc +++ b/google/cloud/servicehealth/v1/service_health_connection_idempotency_policy.cc @@ -66,6 +66,16 @@ Idempotency ServiceHealthConnectionIdempotencyPolicy::GetOrganizationImpact( return Idempotency::kIdempotent; } +Idempotency ServiceHealthConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency ServiceHealthConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultServiceHealthConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/servicehealth/v1/service_health_connection_idempotency_policy.h b/google/cloud/servicehealth/v1/service_health_connection_idempotency_policy.h index 886ea9122fc1c..eb725cf911e73 100644 --- a/google/cloud/servicehealth/v1/service_health_connection_idempotency_policy.h +++ b/google/cloud/servicehealth/v1/service_health_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -56,6 +57,12 @@ class ServiceHealthConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GetOrganizationImpact( google::cloud::servicehealth::v1::GetOrganizationImpactRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/servicemanagement/BUILD.bazel b/google/cloud/servicemanagement/BUILD.bazel index adaa712d116f3..7efa8b5d68819 100644 --- a/google/cloud/servicemanagement/BUILD.bazel +++ b/google/cloud/servicemanagement/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/api/servicemanagement/v1:servicemanagement_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/servicemanagement/v1/internal/service_manager_auth_decorator.cc b/google/cloud/servicemanagement/v1/internal/service_manager_auth_decorator.cc index 9ddf482c7b38b..957fdd4c51462 100644 --- a/google/cloud/servicemanagement/v1/internal/service_manager_auth_decorator.cc +++ b/google/cloud/servicemanagement/v1/internal/service_manager_auth_decorator.cc @@ -252,6 +252,31 @@ ServiceManagerAuth::GenerateConfigReport( return child_->GenerateConfigReport(context, options, request); } +StatusOr ServiceManagerAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr ServiceManagerAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +ServiceManagerAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> ServiceManagerAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/servicemanagement/v1/internal/service_manager_auth_decorator.h b/google/cloud/servicemanagement/v1/internal/service_manager_auth_decorator.h index 2bc7779637b6f..f6967053878b3 100644 --- a/google/cloud/servicemanagement/v1/internal/service_manager_auth_decorator.h +++ b/google/cloud/servicemanagement/v1/internal/service_manager_auth_decorator.h @@ -142,6 +142,18 @@ class ServiceManagerAuth : public ServiceManagerStub { google::api::servicemanagement::v1::GenerateConfigReportRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/servicemanagement/v1/internal/service_manager_connection_impl.cc b/google/cloud/servicemanagement/v1/internal/service_manager_connection_impl.cc index cecb90375f69d..c3e9c84da8c8d 100644 --- a/google/cloud/servicemanagement/v1/internal/service_manager_connection_impl.cc +++ b/google/cloud/servicemanagement/v1/internal/service_manager_connection_impl.cc @@ -728,6 +728,46 @@ ServiceManagerConnectionImpl::GenerateConfigReport( *current, request, __func__); } +StatusOr ServiceManagerConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr ServiceManagerConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +ServiceManagerConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace servicemanagement_v1_internal } // namespace cloud diff --git a/google/cloud/servicemanagement/v1/internal/service_manager_connection_impl.h b/google/cloud/servicemanagement/v1/internal/service_manager_connection_impl.h index 5ae98266f89ec..31155e26ddc10 100644 --- a/google/cloud/servicemanagement/v1/internal/service_manager_connection_impl.h +++ b/google/cloud/servicemanagement/v1/internal/service_manager_connection_impl.h @@ -150,6 +150,15 @@ class ServiceManagerConnectionImpl google::api::servicemanagement::v1::GenerateConfigReportRequest const& request) override; + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/servicemanagement/v1/internal/service_manager_logging_decorator.cc b/google/cloud/servicemanagement/v1/internal/service_manager_logging_decorator.cc index 96011d4fc6362..a999957b12e79 100644 --- a/google/cloud/servicemanagement/v1/internal/service_manager_logging_decorator.cc +++ b/google/cloud/servicemanagement/v1/internal/service_manager_logging_decorator.cc @@ -312,6 +312,40 @@ ServiceManagerLogging::GenerateConfigReport( context, options, request, __func__, tracing_options_); } +StatusOr ServiceManagerLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr ServiceManagerLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +ServiceManagerLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> ServiceManagerLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/servicemanagement/v1/internal/service_manager_logging_decorator.h b/google/cloud/servicemanagement/v1/internal/service_manager_logging_decorator.h index a442fe467f472..b23c75ca8c5e7 100644 --- a/google/cloud/servicemanagement/v1/internal/service_manager_logging_decorator.h +++ b/google/cloud/servicemanagement/v1/internal/service_manager_logging_decorator.h @@ -142,6 +142,18 @@ class ServiceManagerLogging : public ServiceManagerStub { google::api::servicemanagement::v1::GenerateConfigReportRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/servicemanagement/v1/internal/service_manager_metadata_decorator.cc b/google/cloud/servicemanagement/v1/internal/service_manager_metadata_decorator.cc index c76da251f8115..3cd36959fdb2b 100644 --- a/google/cloud/servicemanagement/v1/internal/service_manager_metadata_decorator.cc +++ b/google/cloud/servicemanagement/v1/internal/service_manager_metadata_decorator.cc @@ -240,6 +240,34 @@ ServiceManagerMetadata::GenerateConfigReport( return child_->GenerateConfigReport(context, options, request); } +StatusOr ServiceManagerMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr ServiceManagerMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +ServiceManagerMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> ServiceManagerMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/servicemanagement/v1/internal/service_manager_metadata_decorator.h b/google/cloud/servicemanagement/v1/internal/service_manager_metadata_decorator.h index 991a19ef5d640..81521e249a1ad 100644 --- a/google/cloud/servicemanagement/v1/internal/service_manager_metadata_decorator.h +++ b/google/cloud/servicemanagement/v1/internal/service_manager_metadata_decorator.h @@ -142,6 +142,18 @@ class ServiceManagerMetadata : public ServiceManagerStub { google::api::servicemanagement::v1::GenerateConfigReportRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/servicemanagement/v1/internal/service_manager_stub.cc b/google/cloud/servicemanagement/v1/internal/service_manager_stub.cc index 884371629f5a4..9a1f5210c91c7 100644 --- a/google/cloud/servicemanagement/v1/internal/service_manager_stub.cc +++ b/google/cloud/servicemanagement/v1/internal/service_manager_stub.cc @@ -292,6 +292,41 @@ DefaultServiceManagerStub::GenerateConfigReport( return response; } +StatusOr DefaultServiceManagerStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultServiceManagerStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultServiceManagerStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultServiceManagerStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/servicemanagement/v1/internal/service_manager_stub.h b/google/cloud/servicemanagement/v1/internal/service_manager_stub.h index 4ffb794d9fc27..968535451bf5c 100644 --- a/google/cloud/servicemanagement/v1/internal/service_manager_stub.h +++ b/google/cloud/servicemanagement/v1/internal/service_manager_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include +#include +#include #include #include #include @@ -147,6 +149,19 @@ class ServiceManagerStub { google::api::servicemanagement::v1::GenerateConfigReportRequest const& request) = 0; + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -166,9 +181,12 @@ class DefaultServiceManagerStub : public ServiceManagerStub { std::unique_ptr< google::api::servicemanagement::v1::ServiceManager::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + operations_(std::move(operations)) {} StatusOr ListServices(grpc::ClientContext& context, Options const& options, @@ -273,6 +291,18 @@ class DefaultServiceManagerStub : public ServiceManagerStub { google::api::servicemanagement::v1::GenerateConfigReportRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -289,6 +319,7 @@ class DefaultServiceManagerStub : public ServiceManagerStub { std::unique_ptr< google::api::servicemanagement::v1::ServiceManager::StubInterface> grpc_stub_; + std::unique_ptr iampolicy_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/servicemanagement/v1/internal/service_manager_stub_factory.cc b/google/cloud/servicemanagement/v1/internal/service_manager_stub_factory.cc index 87a0efea3f3c3..707e88813f316 100644 --- a/google/cloud/servicemanagement/v1/internal/service_manager_stub_factory.cc +++ b/google/cloud/servicemanagement/v1/internal/service_manager_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,9 +45,10 @@ std::shared_ptr CreateDefaultServiceManagerStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::api::servicemanagement::v1::ServiceManager::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/servicemanagement/v1/internal/service_manager_tracing_connection.cc b/google/cloud/servicemanagement/v1/internal/service_manager_tracing_connection.cc index 295375ea58520..4af3d0912a0bc 100644 --- a/google/cloud/servicemanagement/v1/internal/service_manager_tracing_connection.cc +++ b/google/cloud/servicemanagement/v1/internal/service_manager_tracing_connection.cc @@ -268,6 +268,31 @@ ServiceManagerTracingConnection::GenerateConfigReport( return internal::EndSpan(*span, child_->GenerateConfigReport(request)); } +StatusOr ServiceManagerTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "servicemanagement_v1::ServiceManagerConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr ServiceManagerTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "servicemanagement_v1::ServiceManagerConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +ServiceManagerTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "servicemanagement_v1::ServiceManagerConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/servicemanagement/v1/internal/service_manager_tracing_connection.h b/google/cloud/servicemanagement/v1/internal/service_manager_tracing_connection.h index a686f3517dfa1..a1ac0e2f6b296 100644 --- a/google/cloud/servicemanagement/v1/internal/service_manager_tracing_connection.h +++ b/google/cloud/servicemanagement/v1/internal/service_manager_tracing_connection.h @@ -138,6 +138,15 @@ class ServiceManagerTracingConnection google::api::servicemanagement::v1::GenerateConfigReportRequest const& request) override; + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/servicemanagement/v1/internal/service_manager_tracing_stub.cc b/google/cloud/servicemanagement/v1/internal/service_manager_tracing_stub.cc index 063809b1adee1..9bf5985d13919 100644 --- a/google/cloud/servicemanagement/v1/internal/service_manager_tracing_stub.cc +++ b/google/cloud/servicemanagement/v1/internal/service_manager_tracing_stub.cc @@ -269,6 +269,40 @@ ServiceManagerTracingStub::GenerateConfigReport( context, *span, child_->GenerateConfigReport(context, options, request)); } +StatusOr ServiceManagerTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.api.servicemanagement.v1.ServiceManager", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr ServiceManagerTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.api.servicemanagement.v1.ServiceManager", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +ServiceManagerTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.api.servicemanagement.v1.ServiceManager", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> ServiceManagerTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/servicemanagement/v1/internal/service_manager_tracing_stub.h b/google/cloud/servicemanagement/v1/internal/service_manager_tracing_stub.h index c8650977e7c8f..21581f3ed17e1 100644 --- a/google/cloud/servicemanagement/v1/internal/service_manager_tracing_stub.h +++ b/google/cloud/servicemanagement/v1/internal/service_manager_tracing_stub.h @@ -141,6 +141,18 @@ class ServiceManagerTracingStub : public ServiceManagerStub { google::api::servicemanagement::v1::GenerateConfigReportRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/servicemanagement/v1/mocks/mock_service_manager_connection.h b/google/cloud/servicemanagement/v1/mocks/mock_service_manager_connection.h index 0a9da69776019..722d7afb6b78f 100644 --- a/google/cloud/servicemanagement/v1/mocks/mock_service_manager_connection.h +++ b/google/cloud/servicemanagement/v1/mocks/mock_service_manager_connection.h @@ -299,6 +299,19 @@ class MockServiceManagerConnection (google::api::servicemanagement::v1::GenerateConfigReportRequest const& request), (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/servicemanagement/v1/service_manager_client.cc b/google/cloud/servicemanagement/v1/service_manager_client.cc index 955ab2982377f..86aebb0a3df21 100644 --- a/google/cloud/servicemanagement/v1/service_manager_client.cc +++ b/google/cloud/servicemanagement/v1/service_manager_client.cc @@ -391,6 +391,25 @@ ServiceManagerClient::GenerateConfigReport( return connection_->GenerateConfigReport(request); } +StatusOr ServiceManagerClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr ServiceManagerClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +ServiceManagerClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace servicemanagement_v1 } // namespace cloud diff --git a/google/cloud/servicemanagement/v1/service_manager_client.h b/google/cloud/servicemanagement/v1/service_manager_client.h index ab8c11d72ba79..567deb1478488 100644 --- a/google/cloud/servicemanagement/v1/service_manager_client.h +++ b/google/cloud/servicemanagement/v1/service_manager_client.h @@ -1362,6 +1362,108 @@ class ServiceManagerClient { request, Options opts = {}); + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/servicemanagement/v1/service_manager_connection.cc b/google/cloud/servicemanagement/v1/service_manager_connection.cc index e6ed0c48da238..c1f28a8d23e18 100644 --- a/google/cloud/servicemanagement/v1/service_manager_connection.cc +++ b/google/cloud/servicemanagement/v1/service_manager_connection.cc @@ -207,6 +207,22 @@ ServiceManagerConnection::GenerateConfigReport( return Status(StatusCode::kUnimplemented, "not implemented"); } +StatusOr ServiceManagerConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr ServiceManagerConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +ServiceManagerConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeServiceManagerConnection( Options options) { internal::CheckExpectedOptions +#include #include #include @@ -285,6 +286,15 @@ class ServiceManagerConnection { GenerateConfigReport( google::api::servicemanagement::v1::GenerateConfigReportRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/servicemanagement/v1/service_manager_connection_idempotency_policy.cc b/google/cloud/servicemanagement/v1/service_manager_connection_idempotency_policy.cc index 4e7befcd00827..2419053dc977e 100644 --- a/google/cloud/servicemanagement/v1/service_manager_connection_idempotency_policy.cc +++ b/google/cloud/servicemanagement/v1/service_manager_connection_idempotency_policy.cc @@ -99,6 +99,22 @@ Idempotency ServiceManagerConnectionIdempotencyPolicy::GenerateConfigReport( return Idempotency::kNonIdempotent; } +Idempotency ServiceManagerConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency ServiceManagerConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency ServiceManagerConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultServiceManagerConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/servicemanagement/v1/service_manager_connection_idempotency_policy.h b/google/cloud/servicemanagement/v1/service_manager_connection_idempotency_policy.h index bacefae656e28..5368e1e759618 100644 --- a/google/cloud/servicemanagement/v1/service_manager_connection_idempotency_policy.h +++ b/google/cloud/servicemanagement/v1/service_manager_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -82,6 +83,15 @@ class ServiceManagerConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GenerateConfigReport( google::api::servicemanagement::v1::GenerateConfigReportRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/speech/BUILD.bazel b/google/cloud/speech/BUILD.bazel index 7f211c3fcf76e..544c2e4151262 100644 --- a/google/cloud/speech/BUILD.bazel +++ b/google/cloud/speech/BUILD.bazel @@ -27,6 +27,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/speech/v1:speech_cc_grpc", "@com_google_googleapis//google/cloud/speech/v2:speech_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/speech/v2/internal/speech_auth_decorator.cc b/google/cloud/speech/v2/internal/speech_auth_decorator.cc index 421aa2980370d..5174ce337b56d 100644 --- a/google/cloud/speech/v2/internal/speech_auth_decorator.cc +++ b/google/cloud/speech/v2/internal/speech_auth_decorator.cc @@ -490,6 +490,23 @@ StatusOr SpeechAuth::UndeletePhraseSet( return child_->UndeletePhraseSet(context, options, request); } +StatusOr +SpeechAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr SpeechAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> SpeechAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/speech/v2/internal/speech_auth_decorator.h b/google/cloud/speech/v2/internal/speech_auth_decorator.h index 6ef3e858dad65..9df087c63bc29 100644 --- a/google/cloud/speech/v2/internal/speech_auth_decorator.h +++ b/google/cloud/speech/v2/internal/speech_auth_decorator.h @@ -239,6 +239,14 @@ class SpeechAuth : public SpeechStub { google::cloud::speech::v2::UndeletePhraseSetRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/speech/v2/internal/speech_connection_impl.cc b/google/cloud/speech/v2/internal/speech_connection_impl.cc index bb206a898755d..106137314ba79 100644 --- a/google/cloud/speech/v2/internal/speech_connection_impl.cc +++ b/google/cloud/speech/v2/internal/speech_connection_impl.cc @@ -1429,6 +1429,53 @@ SpeechConnectionImpl::UndeletePhraseSet( polling_policy(*current), __func__); } +StreamRange +SpeechConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr SpeechConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace speech_v2_internal } // namespace cloud diff --git a/google/cloud/speech/v2/internal/speech_connection_impl.h b/google/cloud/speech/v2/internal/speech_connection_impl.h index b582ff3f05ea8..27928c39ca115 100644 --- a/google/cloud/speech/v2/internal/speech_connection_impl.h +++ b/google/cloud/speech/v2/internal/speech_connection_impl.h @@ -238,6 +238,12 @@ class SpeechConnectionImpl : public speech_v2::SpeechConnection { future> UndeletePhraseSet( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/speech/v2/internal/speech_logging_decorator.cc b/google/cloud/speech/v2/internal/speech_logging_decorator.cc index 34b72a071ef76..a75d40253368a 100644 --- a/google/cloud/speech/v2/internal/speech_logging_decorator.cc +++ b/google/cloud/speech/v2/internal/speech_logging_decorator.cc @@ -559,6 +559,29 @@ StatusOr SpeechLogging::UndeletePhraseSet( context, options, request, __func__, tracing_options_); } +StatusOr +SpeechLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr SpeechLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> SpeechLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/speech/v2/internal/speech_logging_decorator.h b/google/cloud/speech/v2/internal/speech_logging_decorator.h index 6486d255949b0..56630e5e85d99 100644 --- a/google/cloud/speech/v2/internal/speech_logging_decorator.h +++ b/google/cloud/speech/v2/internal/speech_logging_decorator.h @@ -239,6 +239,14 @@ class SpeechLogging : public SpeechStub { google::cloud::speech::v2::UndeletePhraseSetRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/speech/v2/internal/speech_metadata_decorator.cc b/google/cloud/speech/v2/internal/speech_metadata_decorator.cc index 8a15bcbd357db..54dc042f95eb9 100644 --- a/google/cloud/speech/v2/internal/speech_metadata_decorator.cc +++ b/google/cloud/speech/v2/internal/speech_metadata_decorator.cc @@ -402,6 +402,23 @@ StatusOr SpeechMetadata::UndeletePhraseSet( return child_->UndeletePhraseSet(context, options, request); } +StatusOr +SpeechMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr SpeechMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> SpeechMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/speech/v2/internal/speech_metadata_decorator.h b/google/cloud/speech/v2/internal/speech_metadata_decorator.h index 721513dde98fc..0565363bd52cd 100644 --- a/google/cloud/speech/v2/internal/speech_metadata_decorator.h +++ b/google/cloud/speech/v2/internal/speech_metadata_decorator.h @@ -239,6 +239,14 @@ class SpeechMetadata : public SpeechStub { google::cloud::speech::v2::UndeletePhraseSetRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/speech/v2/internal/speech_stub.cc b/google/cloud/speech/v2/internal/speech_stub.cc index bf68a7c127dbd..b58d3bd46380f 100644 --- a/google/cloud/speech/v2/internal/speech_stub.cc +++ b/google/cloud/speech/v2/internal/speech_stub.cc @@ -532,6 +532,29 @@ StatusOr DefaultSpeechStub::UndeletePhraseSet( return response; } +StatusOr +DefaultSpeechStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultSpeechStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultSpeechStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/speech/v2/internal/speech_stub.h b/google/cloud/speech/v2/internal/speech_stub.h index 84cc9a38bd520..29faca71b4ca9 100644 --- a/google/cloud/speech/v2/internal/speech_stub.h +++ b/google/cloud/speech/v2/internal/speech_stub.h @@ -25,6 +25,8 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include #include @@ -225,6 +227,15 @@ class SpeechStub { grpc::ClientContext& context, Options options, google::cloud::speech::v2::UndeletePhraseSetRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -243,9 +254,13 @@ class DefaultSpeechStub : public SpeechStub { DefaultSpeechStub( std::unique_ptr grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateRecognizer( google::cloud::CompletionQueue& cq, @@ -447,6 +462,14 @@ class DefaultSpeechStub : public SpeechStub { google::cloud::speech::v2::UndeletePhraseSetRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -461,6 +484,8 @@ class DefaultSpeechStub : public SpeechStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/speech/v2/internal/speech_stub_factory.cc b/google/cloud/speech/v2/internal/speech_stub_factory.cc index db02e9a45db38..d0c7dfd4fd519 100644 --- a/google/cloud/speech/v2/internal/speech_stub_factory.cc +++ b/google/cloud/speech/v2/internal/speech_stub_factory.cc @@ -28,6 +28,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -43,8 +44,10 @@ std::shared_ptr CreateDefaultSpeechStub( auto channel = auth->CreateChannel(options.get(), internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::speech::v2::Speech::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/speech/v2/internal/speech_tracing_connection.cc b/google/cloud/speech/v2/internal/speech_tracing_connection.cc index d4166ef36311b..55f5b3f0e0d93 100644 --- a/google/cloud/speech/v2/internal/speech_tracing_connection.cc +++ b/google/cloud/speech/v2/internal/speech_tracing_connection.cc @@ -504,6 +504,24 @@ SpeechTracingConnection::UndeletePhraseSet( child_->UndeletePhraseSet(operation)); } +StreamRange +SpeechTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan("speech_v2::SpeechConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +SpeechTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan("speech_v2::SpeechConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeSpeechTracingConnection( diff --git a/google/cloud/speech/v2/internal/speech_tracing_connection.h b/google/cloud/speech/v2/internal/speech_tracing_connection.h index bda953b0292c3..173bb373345c5 100644 --- a/google/cloud/speech/v2/internal/speech_tracing_connection.h +++ b/google/cloud/speech/v2/internal/speech_tracing_connection.h @@ -226,6 +226,12 @@ class SpeechTracingConnection : public speech_v2::SpeechConnection { future> UndeletePhraseSet( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/speech/v2/internal/speech_tracing_stub.cc b/google/cloud/speech/v2/internal/speech_tracing_stub.cc index c0f45b78461b6..031bf8f04f32a 100644 --- a/google/cloud/speech/v2/internal/speech_tracing_stub.cc +++ b/google/cloud/speech/v2/internal/speech_tracing_stub.cc @@ -493,6 +493,29 @@ StatusOr SpeechTracingStub::UndeletePhraseSet( context, *span, child_->UndeletePhraseSet(context, options, request)); } +StatusOr +SpeechTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.speech.v2.Speech", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr SpeechTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.speech.v2.Speech", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> SpeechTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/speech/v2/internal/speech_tracing_stub.h b/google/cloud/speech/v2/internal/speech_tracing_stub.h index 43792b5e30ed1..cb18f1a7de557 100644 --- a/google/cloud/speech/v2/internal/speech_tracing_stub.h +++ b/google/cloud/speech/v2/internal/speech_tracing_stub.h @@ -238,6 +238,14 @@ class SpeechTracingStub : public SpeechStub { google::cloud::speech::v2::UndeletePhraseSetRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/speech/v2/mocks/mock_speech_connection.h b/google/cloud/speech/v2/mocks/mock_speech_connection.h index 087649bf15ec1..392d05aefe071 100644 --- a/google/cloud/speech/v2/mocks/mock_speech_connection.h +++ b/google/cloud/speech/v2/mocks/mock_speech_connection.h @@ -589,6 +589,14 @@ class MockSpeechConnection : public speech_v2::SpeechConnection { MOCK_METHOD(future>, UndeletePhraseSet, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/speech/v2/speech_client.cc b/google/cloud/speech/v2/speech_client.cc index 6058297886053..e5857967dbf83 100644 --- a/google/cloud/speech/v2/speech_client.cc +++ b/google/cloud/speech/v2/speech_client.cc @@ -745,6 +745,18 @@ SpeechClient::UndeletePhraseSet(google::longrunning::Operation const& operation, return connection_->UndeletePhraseSet(operation); } +StreamRange SpeechClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr SpeechClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace speech_v2 } // namespace cloud diff --git a/google/cloud/speech/v2/speech_client.h b/google/cloud/speech/v2/speech_client.h index 0a8895c71fe42..9e3d66fb6ec87 100644 --- a/google/cloud/speech/v2/speech_client.h +++ b/google/cloud/speech/v2/speech_client.h @@ -2296,6 +2296,76 @@ class SpeechClient { future> UndeletePhraseSet( google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/speech/v2/speech_connection.cc b/google/cloud/speech/v2/speech_connection.cc index 09f18cb34bc1f..21d27d7f0d5e3 100644 --- a/google/cloud/speech/v2/speech_connection.cc +++ b/google/cloud/speech/v2/speech_connection.cc @@ -378,6 +378,18 @@ SpeechConnection::UndeletePhraseSet(google::longrunning::Operation const&) { Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange SpeechConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr SpeechConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeSpeechConnection( std::string const& location, Options options) { internal::CheckExpectedOptions #include #include #include @@ -358,6 +359,12 @@ class SpeechConnection { virtual future> UndeletePhraseSet(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/speech/v2/speech_connection_idempotency_policy.cc b/google/cloud/speech/v2/speech_connection_idempotency_policy.cc index 4019bc83c1816..1ac7d288a7932 100644 --- a/google/cloud/speech/v2/speech_connection_idempotency_policy.cc +++ b/google/cloud/speech/v2/speech_connection_idempotency_policy.cc @@ -144,6 +144,16 @@ Idempotency SpeechConnectionIdempotencyPolicy::UndeletePhraseSet( return Idempotency::kNonIdempotent; } +Idempotency SpeechConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency SpeechConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultSpeechConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/speech/v2/speech_connection_idempotency_policy.h b/google/cloud/speech/v2/speech_connection_idempotency_policy.h index 487f8a71ed592..43dedf6b9223a 100644 --- a/google/cloud/speech/v2/speech_connection_idempotency_policy.h +++ b/google/cloud/speech/v2/speech_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -101,6 +102,12 @@ class SpeechConnectionIdempotencyPolicy { virtual google::cloud::Idempotency UndeletePhraseSet( google::cloud::speech::v2::UndeletePhraseSetRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/sql/BUILD.bazel b/google/cloud/sql/BUILD.bazel index 31e9574a1bcbf..874eceed86a41 100644 --- a/google/cloud/sql/BUILD.bazel +++ b/google/cloud/sql/BUILD.bazel @@ -64,6 +64,8 @@ cc_library( "//google/cloud:google_cloud_cpp_rest_internal", "//google/cloud:google_cloud_cpp_rest_protobuf_internal", "@com_google_googleapis//google/cloud/sql/v1:sql_cc_proto", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ], ) diff --git a/google/cloud/sql/v1/internal/sql_available_database_versions_rest_stub.h b/google/cloud/sql/v1/internal/sql_available_database_versions_rest_stub.h index d18301da99b19..53c2ec7332024 100644 --- a/google/cloud/sql/v1/internal/sql_available_database_versions_rest_stub.h +++ b/google/cloud/sql/v1/internal/sql_available_database_versions_rest_stub.h @@ -24,6 +24,7 @@ #include "google/cloud/internal/rest_context.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/internal/sql_backup_runs_rest_stub.h b/google/cloud/sql/v1/internal/sql_backup_runs_rest_stub.h index 2a247f5705d13..a659ff46312bf 100644 --- a/google/cloud/sql/v1/internal/sql_backup_runs_rest_stub.h +++ b/google/cloud/sql/v1/internal/sql_backup_runs_rest_stub.h @@ -24,6 +24,7 @@ #include "google/cloud/internal/rest_context.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/internal/sql_connect_rest_stub.h b/google/cloud/sql/v1/internal/sql_connect_rest_stub.h index f5be5b26a5f34..e20c639f7de1a 100644 --- a/google/cloud/sql/v1/internal/sql_connect_rest_stub.h +++ b/google/cloud/sql/v1/internal/sql_connect_rest_stub.h @@ -24,6 +24,7 @@ #include "google/cloud/internal/rest_context.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/internal/sql_databases_rest_stub.h b/google/cloud/sql/v1/internal/sql_databases_rest_stub.h index da73cf3ac4ef3..931c2c4678573 100644 --- a/google/cloud/sql/v1/internal/sql_databases_rest_stub.h +++ b/google/cloud/sql/v1/internal/sql_databases_rest_stub.h @@ -24,6 +24,7 @@ #include "google/cloud/internal/rest_context.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/internal/sql_events_rest_stub.h b/google/cloud/sql/v1/internal/sql_events_rest_stub.h index 9b248e611c6a6..62e496e9c5438 100644 --- a/google/cloud/sql/v1/internal/sql_events_rest_stub.h +++ b/google/cloud/sql/v1/internal/sql_events_rest_stub.h @@ -24,6 +24,7 @@ #include "google/cloud/internal/rest_context.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/internal/sql_flags_rest_stub.h b/google/cloud/sql/v1/internal/sql_flags_rest_stub.h index ea7834f9150fb..0cf94b0a97454 100644 --- a/google/cloud/sql/v1/internal/sql_flags_rest_stub.h +++ b/google/cloud/sql/v1/internal/sql_flags_rest_stub.h @@ -24,6 +24,7 @@ #include "google/cloud/internal/rest_context.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/internal/sql_iam_policies_rest_stub.h b/google/cloud/sql/v1/internal/sql_iam_policies_rest_stub.h index 6f040aa856fa2..03e9ae3a549d0 100644 --- a/google/cloud/sql/v1/internal/sql_iam_policies_rest_stub.h +++ b/google/cloud/sql/v1/internal/sql_iam_policies_rest_stub.h @@ -24,6 +24,7 @@ #include "google/cloud/internal/rest_context.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/internal/sql_instance_names_rest_stub.h b/google/cloud/sql/v1/internal/sql_instance_names_rest_stub.h index 51ab64014eaea..79fa830c48456 100644 --- a/google/cloud/sql/v1/internal/sql_instance_names_rest_stub.h +++ b/google/cloud/sql/v1/internal/sql_instance_names_rest_stub.h @@ -24,6 +24,7 @@ #include "google/cloud/internal/rest_context.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/internal/sql_instances_rest_stub.h b/google/cloud/sql/v1/internal/sql_instances_rest_stub.h index 1547f912dbd60..f027fc1d6f089 100644 --- a/google/cloud/sql/v1/internal/sql_instances_rest_stub.h +++ b/google/cloud/sql/v1/internal/sql_instances_rest_stub.h @@ -24,6 +24,7 @@ #include "google/cloud/internal/rest_context.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/internal/sql_operations_rest_stub.h b/google/cloud/sql/v1/internal/sql_operations_rest_stub.h index 1db82f215bc3b..84cec2d9696eb 100644 --- a/google/cloud/sql/v1/internal/sql_operations_rest_stub.h +++ b/google/cloud/sql/v1/internal/sql_operations_rest_stub.h @@ -24,6 +24,7 @@ #include "google/cloud/internal/rest_context.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/internal/sql_regions_rest_stub.h b/google/cloud/sql/v1/internal/sql_regions_rest_stub.h index 40f0e34688fb5..e3a94fff8b929 100644 --- a/google/cloud/sql/v1/internal/sql_regions_rest_stub.h +++ b/google/cloud/sql/v1/internal/sql_regions_rest_stub.h @@ -24,6 +24,7 @@ #include "google/cloud/internal/rest_context.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/internal/sql_ssl_certs_rest_stub.h b/google/cloud/sql/v1/internal/sql_ssl_certs_rest_stub.h index dfa852015f200..7aa46f045495d 100644 --- a/google/cloud/sql/v1/internal/sql_ssl_certs_rest_stub.h +++ b/google/cloud/sql/v1/internal/sql_ssl_certs_rest_stub.h @@ -24,6 +24,7 @@ #include "google/cloud/internal/rest_context.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/internal/sql_tiers_rest_stub.h b/google/cloud/sql/v1/internal/sql_tiers_rest_stub.h index 58960bd4a13a6..16d7d6f2d5d76 100644 --- a/google/cloud/sql/v1/internal/sql_tiers_rest_stub.h +++ b/google/cloud/sql/v1/internal/sql_tiers_rest_stub.h @@ -24,6 +24,7 @@ #include "google/cloud/internal/rest_context.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/internal/sql_users_rest_stub.h b/google/cloud/sql/v1/internal/sql_users_rest_stub.h index 965a9cd3454f4..5fac117bec530 100644 --- a/google/cloud/sql/v1/internal/sql_users_rest_stub.h +++ b/google/cloud/sql/v1/internal/sql_users_rest_stub.h @@ -24,6 +24,7 @@ #include "google/cloud/internal/rest_context.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/sql_available_database_versions_connection.h b/google/cloud/sql/v1/sql_available_database_versions_connection.h index 6576fac464dec..b0bc11c0d5535 100644 --- a/google/cloud/sql/v1/sql_available_database_versions_connection.h +++ b/google/cloud/sql/v1/sql_available_database_versions_connection.h @@ -26,6 +26,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/sql_backup_runs_connection.h b/google/cloud/sql/v1/sql_backup_runs_connection.h index efcd57cd843fd..a2f240765c951 100644 --- a/google/cloud/sql/v1/sql_backup_runs_connection.h +++ b/google/cloud/sql/v1/sql_backup_runs_connection.h @@ -26,6 +26,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/sql_connect_connection.h b/google/cloud/sql/v1/sql_connect_connection.h index 774ae47a898d4..f3102ed5d618c 100644 --- a/google/cloud/sql/v1/sql_connect_connection.h +++ b/google/cloud/sql/v1/sql_connect_connection.h @@ -26,6 +26,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/sql_databases_connection.h b/google/cloud/sql/v1/sql_databases_connection.h index 504b9dca07ae0..450508ff7dc4a 100644 --- a/google/cloud/sql/v1/sql_databases_connection.h +++ b/google/cloud/sql/v1/sql_databases_connection.h @@ -26,6 +26,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/sql_events_connection.h b/google/cloud/sql/v1/sql_events_connection.h index 722f9fa85596f..bec631e234105 100644 --- a/google/cloud/sql/v1/sql_events_connection.h +++ b/google/cloud/sql/v1/sql_events_connection.h @@ -26,6 +26,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/sql_flags_connection.h b/google/cloud/sql/v1/sql_flags_connection.h index 1f43563e386af..40dd4be51449b 100644 --- a/google/cloud/sql/v1/sql_flags_connection.h +++ b/google/cloud/sql/v1/sql_flags_connection.h @@ -26,6 +26,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/sql_iam_policies_connection.h b/google/cloud/sql/v1/sql_iam_policies_connection.h index 4e3bb2d488d49..1b2902d3e40d7 100644 --- a/google/cloud/sql/v1/sql_iam_policies_connection.h +++ b/google/cloud/sql/v1/sql_iam_policies_connection.h @@ -26,6 +26,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/sql_instance_names_connection.h b/google/cloud/sql/v1/sql_instance_names_connection.h index c9886606e6633..6837fa933db9a 100644 --- a/google/cloud/sql/v1/sql_instance_names_connection.h +++ b/google/cloud/sql/v1/sql_instance_names_connection.h @@ -26,6 +26,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/sql_instances_connection.h b/google/cloud/sql/v1/sql_instances_connection.h index f60d5e083112b..73682d36c9bde 100644 --- a/google/cloud/sql/v1/sql_instances_connection.h +++ b/google/cloud/sql/v1/sql_instances_connection.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/stream_range.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/sql_operations_connection.h b/google/cloud/sql/v1/sql_operations_connection.h index 308c5c0d0a6dc..6a3f7f2ab4ac9 100644 --- a/google/cloud/sql/v1/sql_operations_connection.h +++ b/google/cloud/sql/v1/sql_operations_connection.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/stream_range.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/sql_regions_connection.h b/google/cloud/sql/v1/sql_regions_connection.h index 49a891c1ba1d6..d39e6c0fb6a65 100644 --- a/google/cloud/sql/v1/sql_regions_connection.h +++ b/google/cloud/sql/v1/sql_regions_connection.h @@ -26,6 +26,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/sql_ssl_certs_connection.h b/google/cloud/sql/v1/sql_ssl_certs_connection.h index 72c02c2404fdc..f8e5b0a27cdbb 100644 --- a/google/cloud/sql/v1/sql_ssl_certs_connection.h +++ b/google/cloud/sql/v1/sql_ssl_certs_connection.h @@ -26,6 +26,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/sql_tiers_connection.h b/google/cloud/sql/v1/sql_tiers_connection.h index 2f911d7176dd2..56b7a5b37110c 100644 --- a/google/cloud/sql/v1/sql_tiers_connection.h +++ b/google/cloud/sql/v1/sql_tiers_connection.h @@ -26,6 +26,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/sql/v1/sql_users_connection.h b/google/cloud/sql/v1/sql_users_connection.h index c46c470fe8d31..a38174cc7e307 100644 --- a/google/cloud/sql/v1/sql_users_connection.h +++ b/google/cloud/sql/v1/sql_users_connection.h @@ -26,6 +26,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/storageinsights/BUILD.bazel b/google/cloud/storageinsights/BUILD.bazel index eef854b92b79e..f163a9e0e4db5 100644 --- a/google/cloud/storageinsights/BUILD.bazel +++ b/google/cloud/storageinsights/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/storageinsights/v1:storageinsights_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/storageinsights/v1/internal/storage_insights_auth_decorator.cc b/google/cloud/storageinsights/v1/internal/storage_insights_auth_decorator.cc index 6027280a8b8c3..f0de5483f324b 100644 --- a/google/cloud/storageinsights/v1/internal/storage_insights_auth_decorator.cc +++ b/google/cloud/storageinsights/v1/internal/storage_insights_auth_decorator.cc @@ -98,6 +98,23 @@ StorageInsightsAuth::GetReportDetail( return child_->GetReportDetail(context, options, request); } +StatusOr +StorageInsightsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr StorageInsightsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storageinsights_v1_internal } // namespace cloud diff --git a/google/cloud/storageinsights/v1/internal/storage_insights_auth_decorator.h b/google/cloud/storageinsights/v1/internal/storage_insights_auth_decorator.h index c5b8c08f04f47..f31ffa263ab6b 100644 --- a/google/cloud/storageinsights/v1/internal/storage_insights_auth_decorator.h +++ b/google/cloud/storageinsights/v1/internal/storage_insights_auth_decorator.h @@ -75,6 +75,14 @@ class StorageInsightsAuth : public StorageInsightsStub { google::cloud::storageinsights::v1::GetReportDetailRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/storageinsights/v1/internal/storage_insights_connection_impl.cc b/google/cloud/storageinsights/v1/internal/storage_insights_connection_impl.cc index ae31760062d73..3d76b4e1d2d40 100644 --- a/google/cloud/storageinsights/v1/internal/storage_insights_connection_impl.cc +++ b/google/cloud/storageinsights/v1/internal/storage_insights_connection_impl.cc @@ -212,6 +212,54 @@ StorageInsightsConnectionImpl::GetReportDetail( *current, request, __func__); } +StreamRange +StorageInsightsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +StorageInsightsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storageinsights_v1_internal } // namespace cloud diff --git a/google/cloud/storageinsights/v1/internal/storage_insights_connection_impl.h b/google/cloud/storageinsights/v1/internal/storage_insights_connection_impl.h index 55fe64c5a7602..be948cbf1b910 100644 --- a/google/cloud/storageinsights/v1/internal/storage_insights_connection_impl.h +++ b/google/cloud/storageinsights/v1/internal/storage_insights_connection_impl.h @@ -77,6 +77,12 @@ class StorageInsightsConnectionImpl google::cloud::storageinsights::v1::GetReportDetailRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/storageinsights/v1/internal/storage_insights_logging_decorator.cc b/google/cloud/storageinsights/v1/internal/storage_insights_logging_decorator.cc index 96e10383b81cd..d5cdf62bd14e4 100644 --- a/google/cloud/storageinsights/v1/internal/storage_insights_logging_decorator.cc +++ b/google/cloud/storageinsights/v1/internal/storage_insights_logging_decorator.cc @@ -133,6 +133,29 @@ StorageInsightsLogging::GetReportDetail( context, options, request, __func__, tracing_options_); } +StatusOr +StorageInsightsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr StorageInsightsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storageinsights_v1_internal } // namespace cloud diff --git a/google/cloud/storageinsights/v1/internal/storage_insights_logging_decorator.h b/google/cloud/storageinsights/v1/internal/storage_insights_logging_decorator.h index 49575dbfef1cc..e071b6afd464d 100644 --- a/google/cloud/storageinsights/v1/internal/storage_insights_logging_decorator.h +++ b/google/cloud/storageinsights/v1/internal/storage_insights_logging_decorator.h @@ -75,6 +75,14 @@ class StorageInsightsLogging : public StorageInsightsStub { google::cloud::storageinsights::v1::GetReportDetailRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/storageinsights/v1/internal/storage_insights_metadata_decorator.cc b/google/cloud/storageinsights/v1/internal/storage_insights_metadata_decorator.cc index 8906398bfbc68..f87bf50e4cb0f 100644 --- a/google/cloud/storageinsights/v1/internal/storage_insights_metadata_decorator.cc +++ b/google/cloud/storageinsights/v1/internal/storage_insights_metadata_decorator.cc @@ -113,6 +113,24 @@ StorageInsightsMetadata::GetReportDetail( return child_->GetReportDetail(context, options, request); } +StatusOr +StorageInsightsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +StorageInsightsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void StorageInsightsMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/storageinsights/v1/internal/storage_insights_metadata_decorator.h b/google/cloud/storageinsights/v1/internal/storage_insights_metadata_decorator.h index e53375f8f2086..03978c18e5d08 100644 --- a/google/cloud/storageinsights/v1/internal/storage_insights_metadata_decorator.h +++ b/google/cloud/storageinsights/v1/internal/storage_insights_metadata_decorator.h @@ -76,6 +76,14 @@ class StorageInsightsMetadata : public StorageInsightsStub { google::cloud::storageinsights::v1::GetReportDetailRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/storageinsights/v1/internal/storage_insights_stub.cc b/google/cloud/storageinsights/v1/internal/storage_insights_stub.cc index f60d1f6af4a35..d82816e5bb0a5 100644 --- a/google/cloud/storageinsights/v1/internal/storage_insights_stub.cc +++ b/google/cloud/storageinsights/v1/internal/storage_insights_stub.cc @@ -118,6 +118,30 @@ DefaultStorageInsightsStub::GetReportDetail( return response; } +StatusOr +DefaultStorageInsightsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultStorageInsightsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storageinsights_v1_internal } // namespace cloud diff --git a/google/cloud/storageinsights/v1/internal/storage_insights_stub.h b/google/cloud/storageinsights/v1/internal/storage_insights_stub.h index efb3f63d2a567..5e67d4de061c8 100644 --- a/google/cloud/storageinsights/v1/internal/storage_insights_stub.h +++ b/google/cloud/storageinsights/v1/internal/storage_insights_stub.h @@ -22,6 +22,8 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include #include @@ -77,6 +79,15 @@ class StorageInsightsStub { grpc::ClientContext& context, Options const& options, google::cloud::storageinsights::v1::GetReportDetailRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultStorageInsightsStub : public StorageInsightsStub { @@ -84,8 +95,11 @@ class DefaultStorageInsightsStub : public StorageInsightsStub { explicit DefaultStorageInsightsStub( std::unique_ptr< google::cloud::storageinsights::v1::StorageInsights::StubInterface> - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListReportConfigs( @@ -124,10 +138,20 @@ class DefaultStorageInsightsStub : public StorageInsightsStub { google::cloud::storageinsights::v1::GetReportDetailRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr< google::cloud::storageinsights::v1::StorageInsights::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/storageinsights/v1/internal/storage_insights_stub_factory.cc b/google/cloud/storageinsights/v1/internal/storage_insights_stub_factory.cc index e09c3756dc473..a17a56147957d 100644 --- a/google/cloud/storageinsights/v1/internal/storage_insights_stub_factory.cc +++ b/google/cloud/storageinsights/v1/internal/storage_insights_stub_factory.cc @@ -28,6 +28,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultStorageInsightsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::storageinsights::v1::StorageInsights::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub)); + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = diff --git a/google/cloud/storageinsights/v1/internal/storage_insights_tracing_connection.cc b/google/cloud/storageinsights/v1/internal/storage_insights_tracing_connection.cc index f46575cfeb381..5f7b9136dbf57 100644 --- a/google/cloud/storageinsights/v1/internal/storage_insights_tracing_connection.cc +++ b/google/cloud/storageinsights/v1/internal/storage_insights_tracing_connection.cc @@ -104,6 +104,26 @@ StorageInsightsTracingConnection::GetReportDetail( return internal::EndSpan(*span, child_->GetReportDetail(request)); } +StreamRange +StorageInsightsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "storageinsights_v1::StorageInsightsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +StorageInsightsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "storageinsights_v1::StorageInsightsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/storageinsights/v1/internal/storage_insights_tracing_connection.h b/google/cloud/storageinsights/v1/internal/storage_insights_tracing_connection.h index a08062628c9fe..2da307bace234 100644 --- a/google/cloud/storageinsights/v1/internal/storage_insights_tracing_connection.h +++ b/google/cloud/storageinsights/v1/internal/storage_insights_tracing_connection.h @@ -68,6 +68,12 @@ class StorageInsightsTracingConnection google::cloud::storageinsights::v1::GetReportDetailRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/storageinsights/v1/internal/storage_insights_tracing_stub.cc b/google/cloud/storageinsights/v1/internal/storage_insights_tracing_stub.cc index bcfe4ad9701f8..7f986121eeaf8 100644 --- a/google/cloud/storageinsights/v1/internal/storage_insights_tracing_stub.cc +++ b/google/cloud/storageinsights/v1/internal/storage_insights_tracing_stub.cc @@ -120,6 +120,30 @@ StorageInsightsTracingStub::GetReportDetail( child_->GetReportDetail(context, options, request)); } +StatusOr +StorageInsightsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.storageinsights.v1.StorageInsights", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +StorageInsightsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.storageinsights.v1.StorageInsights", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeStorageInsightsTracingStub( diff --git a/google/cloud/storageinsights/v1/internal/storage_insights_tracing_stub.h b/google/cloud/storageinsights/v1/internal/storage_insights_tracing_stub.h index 9f69b46c21a7f..c8483676f763c 100644 --- a/google/cloud/storageinsights/v1/internal/storage_insights_tracing_stub.h +++ b/google/cloud/storageinsights/v1/internal/storage_insights_tracing_stub.h @@ -76,6 +76,14 @@ class StorageInsightsTracingStub : public StorageInsightsStub { google::cloud::storageinsights::v1::GetReportDetailRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/storageinsights/v1/mocks/mock_storage_insights_connection.h b/google/cloud/storageinsights/v1/mocks/mock_storage_insights_connection.h index 7a0dcfa288645..074d6647f521e 100644 --- a/google/cloud/storageinsights/v1/mocks/mock_storage_insights_connection.h +++ b/google/cloud/storageinsights/v1/mocks/mock_storage_insights_connection.h @@ -90,6 +90,14 @@ class MockStorageInsightsConnection (google::cloud::storageinsights::v1::GetReportDetailRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/storageinsights/v1/storage_insights_client.cc b/google/cloud/storageinsights/v1/storage_insights_client.cc index ad6a6c87be003..9beb0450582af 100644 --- a/google/cloud/storageinsights/v1/storage_insights_client.cc +++ b/google/cloud/storageinsights/v1/storage_insights_client.cc @@ -155,6 +155,19 @@ StorageInsightsClient::GetReportDetail( return connection_->GetReportDetail(request); } +StreamRange +StorageInsightsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr StorageInsightsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storageinsights_v1 } // namespace cloud diff --git a/google/cloud/storageinsights/v1/storage_insights_client.h b/google/cloud/storageinsights/v1/storage_insights_client.h index 143a2edd1602c..b371c0e5b8600 100644 --- a/google/cloud/storageinsights/v1/storage_insights_client.h +++ b/google/cloud/storageinsights/v1/storage_insights_client.h @@ -521,6 +521,76 @@ class StorageInsightsClient { google::cloud::storageinsights::v1::GetReportDetailRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/storageinsights/v1/storage_insights_connection.cc b/google/cloud/storageinsights/v1/storage_insights_connection.cc index 45eb641883b25..1269edefdff58 100644 --- a/google/cloud/storageinsights/v1/storage_insights_connection.cc +++ b/google/cloud/storageinsights/v1/storage_insights_connection.cc @@ -83,6 +83,20 @@ StorageInsightsConnection::GetReportDetail( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +StorageInsightsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +StorageInsightsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeStorageInsightsConnection( Options options) { internal::CheckExpectedOptions #include #include @@ -214,6 +215,12 @@ class StorageInsightsConnection { GetReportDetail( google::cloud::storageinsights::v1::GetReportDetailRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/storageinsights/v1/storage_insights_connection_idempotency_policy.cc b/google/cloud/storageinsights/v1/storage_insights_connection_idempotency_policy.cc index 78255de5d42ba..da3045c55206d 100644 --- a/google/cloud/storageinsights/v1/storage_insights_connection_idempotency_policy.cc +++ b/google/cloud/storageinsights/v1/storage_insights_connection_idempotency_policy.cc @@ -69,6 +69,16 @@ Idempotency StorageInsightsConnectionIdempotencyPolicy::GetReportDetail( return Idempotency::kIdempotent; } +Idempotency StorageInsightsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency StorageInsightsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultStorageInsightsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/storageinsights/v1/storage_insights_connection_idempotency_policy.h b/google/cloud/storageinsights/v1/storage_insights_connection_idempotency_policy.h index c667f5c0c3966..77452810e7d64 100644 --- a/google/cloud/storageinsights/v1/storage_insights_connection_idempotency_policy.h +++ b/google/cloud/storageinsights/v1/storage_insights_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -62,6 +63,12 @@ class StorageInsightsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GetReportDetail( google::cloud::storageinsights::v1::GetReportDetailRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/tasks/BUILD.bazel b/google/cloud/tasks/BUILD.bazel index 2d17e94b56491..3752182bb8249 100644 --- a/google/cloud/tasks/BUILD.bazel +++ b/google/cloud/tasks/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/tasks/v2:tasks_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/tasks/v2/cloud_tasks_client.cc b/google/cloud/tasks/v2/cloud_tasks_client.cc index f7ce55d7734e2..bf38ab97e36e5 100644 --- a/google/cloud/tasks/v2/cloud_tasks_client.cc +++ b/google/cloud/tasks/v2/cloud_tasks_client.cc @@ -302,6 +302,18 @@ StatusOr CloudTasksClient::RunTask( return connection_->RunTask(request); } +StreamRange CloudTasksClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr CloudTasksClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace tasks_v2 } // namespace cloud diff --git a/google/cloud/tasks/v2/cloud_tasks_client.h b/google/cloud/tasks/v2/cloud_tasks_client.h index f1caf9f9a5a35..b3299c4853782 100644 --- a/google/cloud/tasks/v2/cloud_tasks_client.h +++ b/google/cloud/tasks/v2/cloud_tasks_client.h @@ -27,6 +27,7 @@ #include "google/cloud/polling_policy.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include @@ -259,6 +260,7 @@ class CloudTasksClient { /// [`future`]: @ref google::cloud::future /// [`StatusOr`]: @ref google::cloud::StatusOr /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.Locations.ListLocations]: @googleapis_reference_link{google/cloud/location/locations.proto#L37} /// [google.cloud.tasks.v2.CreateQueueRequest]: @googleapis_reference_link{google/cloud/tasks/v2/cloudtasks.proto#L393} /// [google.cloud.tasks.v2.Queue]: @googleapis_reference_link{google/cloud/tasks/v2/queue.proto#L32} /// [google.cloud.tasks.v2.Queue.name]: @googleapis_reference_link{google/cloud/tasks/v2/queue.proto#L95} @@ -1369,6 +1371,76 @@ class CloudTasksClient { google::cloud::tasks::v2::RunTaskRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/tasks/v2/cloud_tasks_connection.cc b/google/cloud/tasks/v2/cloud_tasks_connection.cc index f3a14cfff96b8..e70d2db59c15d 100644 --- a/google/cloud/tasks/v2/cloud_tasks_connection.cc +++ b/google/cloud/tasks/v2/cloud_tasks_connection.cc @@ -123,6 +123,19 @@ StatusOr CloudTasksConnection::RunTask( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +CloudTasksConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr CloudTasksConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeCloudTasksConnection( Options options) { internal::CheckExpectedOptions #include #include @@ -230,6 +231,12 @@ class CloudTasksConnection { virtual StatusOr RunTask( google::cloud::tasks::v2::RunTaskRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/tasks/v2/cloud_tasks_connection_idempotency_policy.cc b/google/cloud/tasks/v2/cloud_tasks_connection_idempotency_policy.cc index 77bcf8b4b16db..0e1801fd4aa72 100644 --- a/google/cloud/tasks/v2/cloud_tasks_connection_idempotency_policy.cc +++ b/google/cloud/tasks/v2/cloud_tasks_connection_idempotency_policy.cc @@ -115,6 +115,16 @@ Idempotency CloudTasksConnectionIdempotencyPolicy::RunTask( return Idempotency::kNonIdempotent; } +Idempotency CloudTasksConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CloudTasksConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultCloudTasksConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/tasks/v2/cloud_tasks_connection_idempotency_policy.h b/google/cloud/tasks/v2/cloud_tasks_connection_idempotency_policy.h index d9a5427ebc850..4ce4d88c19b6a 100644 --- a/google/cloud/tasks/v2/cloud_tasks_connection_idempotency_policy.h +++ b/google/cloud/tasks/v2/cloud_tasks_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -83,6 +84,12 @@ class CloudTasksConnectionIdempotencyPolicy { virtual google::cloud::Idempotency RunTask( google::cloud::tasks::v2::RunTaskRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/tasks/v2/internal/cloud_tasks_auth_decorator.cc b/google/cloud/tasks/v2/internal/cloud_tasks_auth_decorator.cc index e23386dccf370..77f731171dd11 100644 --- a/google/cloud/tasks/v2/internal/cloud_tasks_auth_decorator.cc +++ b/google/cloud/tasks/v2/internal/cloud_tasks_auth_decorator.cc @@ -161,6 +161,23 @@ StatusOr CloudTasksAuth::RunTask( return child_->RunTask(context, options, request); } +StatusOr +CloudTasksAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr CloudTasksAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace tasks_v2_internal } // namespace cloud diff --git a/google/cloud/tasks/v2/internal/cloud_tasks_auth_decorator.h b/google/cloud/tasks/v2/internal/cloud_tasks_auth_decorator.h index ac8f807f34a08..017294421db79 100644 --- a/google/cloud/tasks/v2/internal/cloud_tasks_auth_decorator.h +++ b/google/cloud/tasks/v2/internal/cloud_tasks_auth_decorator.h @@ -102,6 +102,14 @@ class CloudTasksAuth : public CloudTasksStub { grpc::ClientContext& context, Options const& options, google::cloud::tasks::v2::RunTaskRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr auth_; std::shared_ptr child_; diff --git a/google/cloud/tasks/v2/internal/cloud_tasks_connection_impl.cc b/google/cloud/tasks/v2/internal/cloud_tasks_connection_impl.cc index fe34d83c27758..90700f036de05 100644 --- a/google/cloud/tasks/v2/internal/cloud_tasks_connection_impl.cc +++ b/google/cloud/tasks/v2/internal/cloud_tasks_connection_impl.cc @@ -303,6 +303,54 @@ StatusOr CloudTasksConnectionImpl::RunTask( *current, request, __func__); } +StreamRange +CloudTasksConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +CloudTasksConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace tasks_v2_internal } // namespace cloud diff --git a/google/cloud/tasks/v2/internal/cloud_tasks_connection_impl.h b/google/cloud/tasks/v2/internal/cloud_tasks_connection_impl.h index abe668a6a39c2..b4376755a1f57 100644 --- a/google/cloud/tasks/v2/internal/cloud_tasks_connection_impl.h +++ b/google/cloud/tasks/v2/internal/cloud_tasks_connection_impl.h @@ -95,6 +95,12 @@ class CloudTasksConnectionImpl : public tasks_v2::CloudTasksConnection { StatusOr RunTask( google::cloud::tasks::v2::RunTaskRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/tasks/v2/internal/cloud_tasks_logging_decorator.cc b/google/cloud/tasks/v2/internal/cloud_tasks_logging_decorator.cc index 433cb82cf9ec7..a55ee017dc797 100644 --- a/google/cloud/tasks/v2/internal/cloud_tasks_logging_decorator.cc +++ b/google/cloud/tasks/v2/internal/cloud_tasks_logging_decorator.cc @@ -214,6 +214,29 @@ StatusOr CloudTasksLogging::RunTask( context, options, request, __func__, tracing_options_); } +StatusOr +CloudTasksLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr CloudTasksLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace tasks_v2_internal } // namespace cloud diff --git a/google/cloud/tasks/v2/internal/cloud_tasks_logging_decorator.h b/google/cloud/tasks/v2/internal/cloud_tasks_logging_decorator.h index ba82e8a931a63..788e19752d643 100644 --- a/google/cloud/tasks/v2/internal/cloud_tasks_logging_decorator.h +++ b/google/cloud/tasks/v2/internal/cloud_tasks_logging_decorator.h @@ -102,6 +102,14 @@ class CloudTasksLogging : public CloudTasksStub { grpc::ClientContext& context, Options const& options, google::cloud::tasks::v2::RunTaskRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; TracingOptions tracing_options_; diff --git a/google/cloud/tasks/v2/internal/cloud_tasks_metadata_decorator.cc b/google/cloud/tasks/v2/internal/cloud_tasks_metadata_decorator.cc index 45bd04f59d291..1a3cfdd3397cd 100644 --- a/google/cloud/tasks/v2/internal/cloud_tasks_metadata_decorator.cc +++ b/google/cloud/tasks/v2/internal/cloud_tasks_metadata_decorator.cc @@ -179,6 +179,23 @@ StatusOr CloudTasksMetadata::RunTask( return child_->RunTask(context, options, request); } +StatusOr +CloudTasksMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr CloudTasksMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + void CloudTasksMetadata::SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params) { diff --git a/google/cloud/tasks/v2/internal/cloud_tasks_metadata_decorator.h b/google/cloud/tasks/v2/internal/cloud_tasks_metadata_decorator.h index 79c4338641603..626a35bdeec57 100644 --- a/google/cloud/tasks/v2/internal/cloud_tasks_metadata_decorator.h +++ b/google/cloud/tasks/v2/internal/cloud_tasks_metadata_decorator.h @@ -102,6 +102,14 @@ class CloudTasksMetadata : public CloudTasksStub { grpc::ClientContext& context, Options const& options, google::cloud::tasks::v2::RunTaskRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: void SetMetadata(grpc::ClientContext& context, Options const& options, std::string const& request_params); diff --git a/google/cloud/tasks/v2/internal/cloud_tasks_stub.cc b/google/cloud/tasks/v2/internal/cloud_tasks_stub.cc index 478c10e2d4a93..c7a73208b91c4 100644 --- a/google/cloud/tasks/v2/internal/cloud_tasks_stub.cc +++ b/google/cloud/tasks/v2/internal/cloud_tasks_stub.cc @@ -209,6 +209,29 @@ StatusOr DefaultCloudTasksStub::RunTask( return response; } +StatusOr +DefaultCloudTasksStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultCloudTasksStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace tasks_v2_internal } // namespace cloud diff --git a/google/cloud/tasks/v2/internal/cloud_tasks_stub.h b/google/cloud/tasks/v2/internal/cloud_tasks_stub.h index fa102837d59b2..74066cc764163 100644 --- a/google/cloud/tasks/v2/internal/cloud_tasks_stub.h +++ b/google/cloud/tasks/v2/internal/cloud_tasks_stub.h @@ -22,6 +22,8 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include #include @@ -99,14 +101,26 @@ class CloudTasksStub { virtual StatusOr RunTask( grpc::ClientContext& context, Options const& options, google::cloud::tasks::v2::RunTaskRequest const& request) = 0; + + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; }; class DefaultCloudTasksStub : public CloudTasksStub { public: explicit DefaultCloudTasksStub( std::unique_ptr - grpc_stub) - : grpc_stub_(std::move(grpc_stub)) {} + grpc_stub, + std::unique_ptr + locations_stub) + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)) {} StatusOr ListQueues( grpc::ClientContext& context, Options const& options, @@ -172,9 +186,19 @@ class DefaultCloudTasksStub : public CloudTasksStub { grpc::ClientContext& context, Options const& options, google::cloud::tasks::v2::RunTaskRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/tasks/v2/internal/cloud_tasks_stub_factory.cc b/google/cloud/tasks/v2/internal/cloud_tasks_stub_factory.cc index 2d6df9d891fe9..dbbd6afdf312a 100644 --- a/google/cloud/tasks/v2/internal/cloud_tasks_stub_factory.cc +++ b/google/cloud/tasks/v2/internal/cloud_tasks_stub_factory.cc @@ -28,6 +28,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -44,8 +45,11 @@ std::shared_ptr CreateDefaultCloudTasksStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::tasks::v2::CloudTasks::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = - std::make_shared(std::move(service_grpc_stub)); + std::make_shared( + std::move(service_grpc_stub), std::move(service_locations_stub)); if (auth->RequiresConfigureContext()) { stub = std::make_shared(std::move(auth), std::move(stub)); diff --git a/google/cloud/tasks/v2/internal/cloud_tasks_tracing_connection.cc b/google/cloud/tasks/v2/internal/cloud_tasks_tracing_connection.cc index b746368a0a4dc..b6883c748253e 100644 --- a/google/cloud/tasks/v2/internal/cloud_tasks_tracing_connection.cc +++ b/google/cloud/tasks/v2/internal/cloud_tasks_tracing_connection.cc @@ -161,6 +161,25 @@ StatusOr CloudTasksTracingConnection::RunTask( return internal::EndSpan(*span, child_->RunTask(request)); } +StreamRange +CloudTasksTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("tasks_v2::CloudTasksConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CloudTasksTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan("tasks_v2::CloudTasksConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeCloudTasksTracingConnection( diff --git a/google/cloud/tasks/v2/internal/cloud_tasks_tracing_connection.h b/google/cloud/tasks/v2/internal/cloud_tasks_tracing_connection.h index cfcc38034b4e1..2fa5dd5501dee 100644 --- a/google/cloud/tasks/v2/internal/cloud_tasks_tracing_connection.h +++ b/google/cloud/tasks/v2/internal/cloud_tasks_tracing_connection.h @@ -87,6 +87,12 @@ class CloudTasksTracingConnection : public tasks_v2::CloudTasksConnection { StatusOr RunTask( google::cloud::tasks::v2::RunTaskRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/tasks/v2/internal/cloud_tasks_tracing_stub.cc b/google/cloud/tasks/v2/internal/cloud_tasks_tracing_stub.cc index 4805b1d0e6f99..89dd0cab8d078 100644 --- a/google/cloud/tasks/v2/internal/cloud_tasks_tracing_stub.cc +++ b/google/cloud/tasks/v2/internal/cloud_tasks_tracing_stub.cc @@ -211,6 +211,29 @@ StatusOr CloudTasksTracingStub::RunTask( child_->RunTask(context, options, request)); } +StatusOr +CloudTasksTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.tasks.v2.CloudTasks", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr CloudTasksTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.tasks.v2.CloudTasks", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeCloudTasksTracingStub( diff --git a/google/cloud/tasks/v2/internal/cloud_tasks_tracing_stub.h b/google/cloud/tasks/v2/internal/cloud_tasks_tracing_stub.h index d425a174deca1..a66d4c13de48a 100644 --- a/google/cloud/tasks/v2/internal/cloud_tasks_tracing_stub.h +++ b/google/cloud/tasks/v2/internal/cloud_tasks_tracing_stub.h @@ -102,6 +102,14 @@ class CloudTasksTracingStub : public CloudTasksStub { grpc::ClientContext& context, Options const& options, google::cloud::tasks::v2::RunTaskRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; std::shared_ptr diff --git a/google/cloud/tasks/v2/mocks/mock_cloud_tasks_connection.h b/google/cloud/tasks/v2/mocks/mock_cloud_tasks_connection.h index 204592bb9c3fe..a59628bda6142 100644 --- a/google/cloud/tasks/v2/mocks/mock_cloud_tasks_connection.h +++ b/google/cloud/tasks/v2/mocks/mock_cloud_tasks_connection.h @@ -109,6 +109,14 @@ class MockCloudTasksConnection : public tasks_v2::CloudTasksConnection { MOCK_METHOD(StatusOr, RunTask, (google::cloud::tasks::v2::RunTaskRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/telcoautomation/BUILD.bazel b/google/cloud/telcoautomation/BUILD.bazel index 4cdc3d8937fb6..cf03b04c3ada2 100644 --- a/google/cloud/telcoautomation/BUILD.bazel +++ b/google/cloud/telcoautomation/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/telcoautomation/v1:telcoautomation_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/telcoautomation/v1/internal/telco_automation_auth_decorator.cc b/google/cloud/telcoautomation/v1/internal/telco_automation_auth_decorator.cc index 66a358409ed6a..a93da366afad8 100644 --- a/google/cloud/telcoautomation/v1/internal/telco_automation_auth_decorator.cc +++ b/google/cloud/telcoautomation/v1/internal/telco_automation_auth_decorator.cc @@ -456,6 +456,23 @@ TelcoAutomationAuth::ApplyHydratedDeployment( return child_->ApplyHydratedDeployment(context, options, request); } +StatusOr +TelcoAutomationAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr TelcoAutomationAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> TelcoAutomationAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/telcoautomation/v1/internal/telco_automation_auth_decorator.h b/google/cloud/telcoautomation/v1/internal/telco_automation_auth_decorator.h index a246874567572..a2eac5a67c153 100644 --- a/google/cloud/telcoautomation/v1/internal/telco_automation_auth_decorator.h +++ b/google/cloud/telcoautomation/v1/internal/telco_automation_auth_decorator.h @@ -268,6 +268,14 @@ class TelcoAutomationAuth : public TelcoAutomationStub { google::cloud::telcoautomation::v1::ApplyHydratedDeploymentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/telcoautomation/v1/internal/telco_automation_connection_impl.cc b/google/cloud/telcoautomation/v1/internal/telco_automation_connection_impl.cc index eac648b60a75b..2436d0e14731e 100644 --- a/google/cloud/telcoautomation/v1/internal/telco_automation_connection_impl.cc +++ b/google/cloud/telcoautomation/v1/internal/telco_automation_connection_impl.cc @@ -1153,6 +1153,54 @@ TelcoAutomationConnectionImpl::ApplyHydratedDeployment( *current, request, __func__); } +StreamRange +TelcoAutomationConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +TelcoAutomationConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace telcoautomation_v1_internal } // namespace cloud diff --git a/google/cloud/telcoautomation/v1/internal/telco_automation_connection_impl.h b/google/cloud/telcoautomation/v1/internal/telco_automation_connection_impl.h index 7b1e4c9924d3a..ab1a5b812a290 100644 --- a/google/cloud/telcoautomation/v1/internal/telco_automation_connection_impl.h +++ b/google/cloud/telcoautomation/v1/internal/telco_automation_connection_impl.h @@ -246,6 +246,12 @@ class TelcoAutomationConnectionImpl google::cloud::telcoautomation::v1::ApplyHydratedDeploymentRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/telcoautomation/v1/internal/telco_automation_logging_decorator.cc b/google/cloud/telcoautomation/v1/internal/telco_automation_logging_decorator.cc index c1aca05d50d8c..b8b67f786a331 100644 --- a/google/cloud/telcoautomation/v1/internal/telco_automation_logging_decorator.cc +++ b/google/cloud/telcoautomation/v1/internal/telco_automation_logging_decorator.cc @@ -603,6 +603,29 @@ TelcoAutomationLogging::ApplyHydratedDeployment( context, options, request, __func__, tracing_options_); } +StatusOr +TelcoAutomationLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr TelcoAutomationLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> TelcoAutomationLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/telcoautomation/v1/internal/telco_automation_logging_decorator.h b/google/cloud/telcoautomation/v1/internal/telco_automation_logging_decorator.h index 5c0da6fdb34b7..fdedeb4d93bcb 100644 --- a/google/cloud/telcoautomation/v1/internal/telco_automation_logging_decorator.h +++ b/google/cloud/telcoautomation/v1/internal/telco_automation_logging_decorator.h @@ -268,6 +268,14 @@ class TelcoAutomationLogging : public TelcoAutomationStub { google::cloud::telcoautomation::v1::ApplyHydratedDeploymentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/telcoautomation/v1/internal/telco_automation_metadata_decorator.cc b/google/cloud/telcoautomation/v1/internal/telco_automation_metadata_decorator.cc index c1b62c8010da0..f8e56be868d7c 100644 --- a/google/cloud/telcoautomation/v1/internal/telco_automation_metadata_decorator.cc +++ b/google/cloud/telcoautomation/v1/internal/telco_automation_metadata_decorator.cc @@ -441,6 +441,24 @@ TelcoAutomationMetadata::ApplyHydratedDeployment( return child_->ApplyHydratedDeployment(context, options, request); } +StatusOr +TelcoAutomationMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +TelcoAutomationMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> TelcoAutomationMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/telcoautomation/v1/internal/telco_automation_metadata_decorator.h b/google/cloud/telcoautomation/v1/internal/telco_automation_metadata_decorator.h index ff9c9d0f81644..2d865f6ea9d5b 100644 --- a/google/cloud/telcoautomation/v1/internal/telco_automation_metadata_decorator.h +++ b/google/cloud/telcoautomation/v1/internal/telco_automation_metadata_decorator.h @@ -269,6 +269,14 @@ class TelcoAutomationMetadata : public TelcoAutomationStub { google::cloud::telcoautomation::v1::ApplyHydratedDeploymentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/telcoautomation/v1/internal/telco_automation_stub.cc b/google/cloud/telcoautomation/v1/internal/telco_automation_stub.cc index 268e9b47d2510..4542a18496249 100644 --- a/google/cloud/telcoautomation/v1/internal/telco_automation_stub.cc +++ b/google/cloud/telcoautomation/v1/internal/telco_automation_stub.cc @@ -580,6 +580,30 @@ DefaultTelcoAutomationStub::ApplyHydratedDeployment( return response; } +StatusOr +DefaultTelcoAutomationStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultTelcoAutomationStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultTelcoAutomationStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/telcoautomation/v1/internal/telco_automation_stub.h b/google/cloud/telcoautomation/v1/internal/telco_automation_stub.h index f95dcb24b19fe..49ef2be3d9ef8 100644 --- a/google/cloud/telcoautomation/v1/internal/telco_automation_stub.h +++ b/google/cloud/telcoautomation/v1/internal/telco_automation_stub.h @@ -24,6 +24,8 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include #include @@ -283,6 +285,15 @@ class TelcoAutomationStub { google::cloud::telcoautomation::v1::ApplyHydratedDeploymentRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -302,9 +313,13 @@ class DefaultTelcoAutomationStub : public TelcoAutomationStub { std::unique_ptr< google::cloud::telcoautomation::v1::TelcoAutomation::StubInterface> grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr< google::cloud::telcoautomation::v1::ListOrchestrationClustersResponse> @@ -535,6 +550,14 @@ class DefaultTelcoAutomationStub : public TelcoAutomationStub { google::cloud::telcoautomation::v1::ApplyHydratedDeploymentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -551,6 +574,8 @@ class DefaultTelcoAutomationStub : public TelcoAutomationStub { std::unique_ptr< google::cloud::telcoautomation::v1::TelcoAutomation::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/telcoautomation/v1/internal/telco_automation_stub_factory.cc b/google/cloud/telcoautomation/v1/internal/telco_automation_stub_factory.cc index 6142cd17c59db..5215cc8279b5a 100644 --- a/google/cloud/telcoautomation/v1/internal/telco_automation_stub_factory.cc +++ b/google/cloud/telcoautomation/v1/internal/telco_automation_stub_factory.cc @@ -28,6 +28,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultTelcoAutomationStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::telcoautomation::v1::TelcoAutomation::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/telcoautomation/v1/internal/telco_automation_tracing_connection.cc b/google/cloud/telcoautomation/v1/internal/telco_automation_tracing_connection.cc index 0223f3ec588e4..1710713742865 100644 --- a/google/cloud/telcoautomation/v1/internal/telco_automation_tracing_connection.cc +++ b/google/cloud/telcoautomation/v1/internal/telco_automation_tracing_connection.cc @@ -501,6 +501,26 @@ TelcoAutomationTracingConnection::ApplyHydratedDeployment( return internal::EndSpan(*span, child_->ApplyHydratedDeployment(request)); } +StreamRange +TelcoAutomationTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "telcoautomation_v1::TelcoAutomationConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +TelcoAutomationTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "telcoautomation_v1::TelcoAutomationConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/telcoautomation/v1/internal/telco_automation_tracing_connection.h b/google/cloud/telcoautomation/v1/internal/telco_automation_tracing_connection.h index 04fadf8cf784d..846e9b98c76f8 100644 --- a/google/cloud/telcoautomation/v1/internal/telco_automation_tracing_connection.h +++ b/google/cloud/telcoautomation/v1/internal/telco_automation_tracing_connection.h @@ -234,6 +234,12 @@ class TelcoAutomationTracingConnection google::cloud::telcoautomation::v1::ApplyHydratedDeploymentRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/telcoautomation/v1/internal/telco_automation_tracing_stub.cc b/google/cloud/telcoautomation/v1/internal/telco_automation_tracing_stub.cc index 362b826301b0b..0a9bdb0a4f3d2 100644 --- a/google/cloud/telcoautomation/v1/internal/telco_automation_tracing_stub.cc +++ b/google/cloud/telcoautomation/v1/internal/telco_automation_tracing_stub.cc @@ -577,6 +577,30 @@ TelcoAutomationTracingStub::ApplyHydratedDeployment( child_->ApplyHydratedDeployment(context, options, request)); } +StatusOr +TelcoAutomationTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.telcoautomation.v1.TelcoAutomation", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +TelcoAutomationTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.telcoautomation.v1.TelcoAutomation", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> TelcoAutomationTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/telcoautomation/v1/internal/telco_automation_tracing_stub.h b/google/cloud/telcoautomation/v1/internal/telco_automation_tracing_stub.h index 2c6e005f0b925..6e59cb5b0d3df 100644 --- a/google/cloud/telcoautomation/v1/internal/telco_automation_tracing_stub.h +++ b/google/cloud/telcoautomation/v1/internal/telco_automation_tracing_stub.h @@ -268,6 +268,14 @@ class TelcoAutomationTracingStub : public TelcoAutomationStub { google::cloud::telcoautomation::v1::ApplyHydratedDeploymentRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/telcoautomation/v1/mocks/mock_telco_automation_connection.h b/google/cloud/telcoautomation/v1/mocks/mock_telco_automation_connection.h index 6ee170017629f..67f9a944659b6 100644 --- a/google/cloud/telcoautomation/v1/mocks/mock_telco_automation_connection.h +++ b/google/cloud/telcoautomation/v1/mocks/mock_telco_automation_connection.h @@ -418,6 +418,14 @@ class MockTelcoAutomationConnection (google::cloud::telcoautomation::v1::ApplyHydratedDeploymentRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/telcoautomation/v1/telco_automation_client.cc b/google/cloud/telcoautomation/v1/telco_automation_client.cc index 525f3e7e7eb29..c83627c15eafe 100644 --- a/google/cloud/telcoautomation/v1/telco_automation_client.cc +++ b/google/cloud/telcoautomation/v1/telco_automation_client.cc @@ -781,6 +781,19 @@ TelcoAutomationClient::ApplyHydratedDeployment( return connection_->ApplyHydratedDeployment(request); } +StreamRange +TelcoAutomationClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr TelcoAutomationClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace telcoautomation_v1 } // namespace cloud diff --git a/google/cloud/telcoautomation/v1/telco_automation_client.h b/google/cloud/telcoautomation/v1/telco_automation_client.h index 92c7d28216578..edf60a57f3754 100644 --- a/google/cloud/telcoautomation/v1/telco_automation_client.h +++ b/google/cloud/telcoautomation/v1/telco_automation_client.h @@ -2640,6 +2640,76 @@ class TelcoAutomationClient { request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/telcoautomation/v1/telco_automation_connection.cc b/google/cloud/telcoautomation/v1/telco_automation_connection.cc index 38d6c1e68ebb2..41c56496deae0 100644 --- a/google/cloud/telcoautomation/v1/telco_automation_connection.cc +++ b/google/cloud/telcoautomation/v1/telco_automation_connection.cc @@ -348,6 +348,20 @@ TelcoAutomationConnection::ApplyHydratedDeployment( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +TelcoAutomationConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +TelcoAutomationConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeTelcoAutomationConnection( Options options) { internal::CheckExpectedOptions #include #include #include @@ -389,6 +390,12 @@ class TelcoAutomationConnection { ApplyHydratedDeployment( google::cloud::telcoautomation::v1::ApplyHydratedDeploymentRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/telcoautomation/v1/telco_automation_connection_idempotency_policy.cc b/google/cloud/telcoautomation/v1/telco_automation_connection_idempotency_policy.cc index 736001b0651f3..20a4c3e69e308 100644 --- a/google/cloud/telcoautomation/v1/telco_automation_connection_idempotency_policy.cc +++ b/google/cloud/telcoautomation/v1/telco_automation_connection_idempotency_policy.cc @@ -232,6 +232,16 @@ Idempotency TelcoAutomationConnectionIdempotencyPolicy::ApplyHydratedDeployment( return Idempotency::kNonIdempotent; } +Idempotency TelcoAutomationConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency TelcoAutomationConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultTelcoAutomationConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/telcoautomation/v1/telco_automation_connection_idempotency_policy.h b/google/cloud/telcoautomation/v1/telco_automation_connection_idempotency_policy.h index f5a250d99cb16..a7d8463339f8e 100644 --- a/google/cloud/telcoautomation/v1/telco_automation_connection_idempotency_policy.h +++ b/google/cloud/telcoautomation/v1/telco_automation_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -171,6 +172,12 @@ class TelcoAutomationConnectionIdempotencyPolicy { virtual google::cloud::Idempotency ApplyHydratedDeployment( google::cloud::telcoautomation::v1::ApplyHydratedDeploymentRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/timeseriesinsights/BUILD.bazel b/google/cloud/timeseriesinsights/BUILD.bazel index dc294a941059d..f0972546d62a1 100644 --- a/google/cloud/timeseriesinsights/BUILD.bazel +++ b/google/cloud/timeseriesinsights/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/timeseriesinsights/v1:timeseriesinsights_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/timeseriesinsights/v1/internal/timeseries_insights_controller_stub.h b/google/cloud/timeseriesinsights/v1/internal/timeseries_insights_controller_stub.h index 888df3a1ee540..749d22784c17b 100644 --- a/google/cloud/timeseriesinsights/v1/internal/timeseries_insights_controller_stub.h +++ b/google/cloud/timeseriesinsights/v1/internal/timeseries_insights_controller_stub.h @@ -22,6 +22,7 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include #include #include diff --git a/google/cloud/timeseriesinsights/v1/timeseries_insights_controller_connection.h b/google/cloud/timeseriesinsights/v1/timeseries_insights_controller_connection.h index 69fd5b335f1b0..65125c89af321 100644 --- a/google/cloud/timeseriesinsights/v1/timeseries_insights_controller_connection.h +++ b/google/cloud/timeseriesinsights/v1/timeseries_insights_controller_connection.h @@ -27,6 +27,7 @@ #include "google/cloud/status_or.h" #include "google/cloud/stream_range.h" #include "google/cloud/version.h" +#include #include #include diff --git a/google/cloud/tpu/BUILD.bazel b/google/cloud/tpu/BUILD.bazel index 2c84443519e07..86a9a8017c61b 100644 --- a/google/cloud/tpu/BUILD.bazel +++ b/google/cloud/tpu/BUILD.bazel @@ -27,6 +27,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/tpu/v1:tpu_cc_grpc", "@com_google_googleapis//google/cloud/tpu/v2:tpu_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/tpu/v1/internal/tpu_auth_decorator.cc b/google/cloud/tpu/v1/internal/tpu_auth_decorator.cc index db740ba37f7f6..b5e04b0dfe130 100644 --- a/google/cloud/tpu/v1/internal/tpu_auth_decorator.cc +++ b/google/cloud/tpu/v1/internal/tpu_auth_decorator.cc @@ -217,6 +217,22 @@ StatusOr TpuAuth::GetAcceleratorType( return child_->GetAcceleratorType(context, options, request); } +StatusOr TpuAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr TpuAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> TpuAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/tpu/v1/internal/tpu_auth_decorator.h b/google/cloud/tpu/v1/internal/tpu_auth_decorator.h index dc884e8104d4e..faa2a3d7e3da1 100644 --- a/google/cloud/tpu/v1/internal/tpu_auth_decorator.h +++ b/google/cloud/tpu/v1/internal/tpu_auth_decorator.h @@ -119,6 +119,14 @@ class TpuAuth : public TpuStub { google::cloud::tpu::v1::GetAcceleratorTypeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/tpu/v1/internal/tpu_connection_impl.cc b/google/cloud/tpu/v1/internal/tpu_connection_impl.cc index 1e65824e1dec7..91a33e8040a1d 100644 --- a/google/cloud/tpu/v1/internal/tpu_connection_impl.cc +++ b/google/cloud/tpu/v1/internal/tpu_connection_impl.cc @@ -624,6 +624,51 @@ TpuConnectionImpl::GetAcceleratorType( *current, request, __func__); } +StreamRange TpuConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr(retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr TpuConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace tpu_v1_internal } // namespace cloud diff --git a/google/cloud/tpu/v1/internal/tpu_connection_impl.h b/google/cloud/tpu/v1/internal/tpu_connection_impl.h index 0b249274b189b..9d626d611f516 100644 --- a/google/cloud/tpu/v1/internal/tpu_connection_impl.h +++ b/google/cloud/tpu/v1/internal/tpu_connection_impl.h @@ -120,6 +120,12 @@ class TpuConnectionImpl : public tpu_v1::TpuConnection { google::cloud::tpu::v1::GetAcceleratorTypeRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/tpu/v1/internal/tpu_logging_decorator.cc b/google/cloud/tpu/v1/internal/tpu_logging_decorator.cc index a1520aff6cb54..3c0007ac5eb80 100644 --- a/google/cloud/tpu/v1/internal/tpu_logging_decorator.cc +++ b/google/cloud/tpu/v1/internal/tpu_logging_decorator.cc @@ -248,6 +248,29 @@ TpuLogging::GetAcceleratorType( context, options, request, __func__, tracing_options_); } +StatusOr +TpuLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr TpuLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> TpuLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/tpu/v1/internal/tpu_logging_decorator.h b/google/cloud/tpu/v1/internal/tpu_logging_decorator.h index 68269174b7a88..d5b82725e6a94 100644 --- a/google/cloud/tpu/v1/internal/tpu_logging_decorator.h +++ b/google/cloud/tpu/v1/internal/tpu_logging_decorator.h @@ -118,6 +118,14 @@ class TpuLogging : public TpuStub { google::cloud::tpu::v1::GetAcceleratorTypeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/tpu/v1/internal/tpu_metadata_decorator.cc b/google/cloud/tpu/v1/internal/tpu_metadata_decorator.cc index 987698676024a..7659975394c55 100644 --- a/google/cloud/tpu/v1/internal/tpu_metadata_decorator.cc +++ b/google/cloud/tpu/v1/internal/tpu_metadata_decorator.cc @@ -190,6 +190,23 @@ TpuMetadata::GetAcceleratorType( return child_->GetAcceleratorType(context, options, request); } +StatusOr +TpuMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr TpuMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> TpuMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/tpu/v1/internal/tpu_metadata_decorator.h b/google/cloud/tpu/v1/internal/tpu_metadata_decorator.h index 46a8e099c7297..91c42bc7be023 100644 --- a/google/cloud/tpu/v1/internal/tpu_metadata_decorator.h +++ b/google/cloud/tpu/v1/internal/tpu_metadata_decorator.h @@ -119,6 +119,14 @@ class TpuMetadata : public TpuStub { google::cloud::tpu::v1::GetAcceleratorTypeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/tpu/v1/internal/tpu_stub.cc b/google/cloud/tpu/v1/internal/tpu_stub.cc index 3d78c143304ea..a4ff1847ce8dc 100644 --- a/google/cloud/tpu/v1/internal/tpu_stub.cc +++ b/google/cloud/tpu/v1/internal/tpu_stub.cc @@ -240,6 +240,29 @@ DefaultTpuStub::GetAcceleratorType( return response; } +StatusOr +DefaultTpuStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultTpuStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultTpuStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/tpu/v1/internal/tpu_stub.h b/google/cloud/tpu/v1/internal/tpu_stub.h index ebaebf3eed0ee..7c571828fa3a8 100644 --- a/google/cloud/tpu/v1/internal/tpu_stub.h +++ b/google/cloud/tpu/v1/internal/tpu_stub.h @@ -24,6 +24,8 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include #include @@ -115,6 +117,15 @@ class TpuStub { grpc::ClientContext& context, Options const& options, google::cloud::tpu::v1::GetAcceleratorTypeRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -132,9 +143,13 @@ class DefaultTpuStub : public TpuStub { public: DefaultTpuStub( std::unique_ptr grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListNodes( grpc::ClientContext& context, Options const& options, @@ -216,6 +231,14 @@ class DefaultTpuStub : public TpuStub { google::cloud::tpu::v1::GetAcceleratorTypeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -230,6 +253,8 @@ class DefaultTpuStub : public TpuStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/tpu/v1/internal/tpu_stub_factory.cc b/google/cloud/tpu/v1/internal/tpu_stub_factory.cc index ba8ca56dae170..0e0485f21f0dd 100644 --- a/google/cloud/tpu/v1/internal/tpu_stub_factory.cc +++ b/google/cloud/tpu/v1/internal/tpu_stub_factory.cc @@ -28,6 +28,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -43,8 +44,10 @@ std::shared_ptr CreateDefaultTpuStub( auto channel = auth->CreateChannel(options.get(), internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::tpu::v1::Tpu::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/tpu/v1/internal/tpu_tracing_connection.cc b/google/cloud/tpu/v1/internal/tpu_tracing_connection.cc index 45d66246098c3..e5a82861a78b5 100644 --- a/google/cloud/tpu/v1/internal/tpu_tracing_connection.cc +++ b/google/cloud/tpu/v1/internal/tpu_tracing_connection.cc @@ -194,6 +194,23 @@ TpuTracingConnection::GetAcceleratorType( return internal::EndSpan(*span, child_->GetAcceleratorType(request)); } +StreamRange +TpuTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan("tpu_v1::TpuConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr TpuTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan("tpu_v1::TpuConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeTpuTracingConnection( diff --git a/google/cloud/tpu/v1/internal/tpu_tracing_connection.h b/google/cloud/tpu/v1/internal/tpu_tracing_connection.h index 70bf173450b8e..70edf9c652e09 100644 --- a/google/cloud/tpu/v1/internal/tpu_tracing_connection.h +++ b/google/cloud/tpu/v1/internal/tpu_tracing_connection.h @@ -108,6 +108,12 @@ class TpuTracingConnection : public tpu_v1::TpuConnection { google::cloud::tpu::v1::GetAcceleratorTypeRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/tpu/v1/internal/tpu_tracing_stub.cc b/google/cloud/tpu/v1/internal/tpu_tracing_stub.cc index e0b74b31fec47..8a7b74bf6de52 100644 --- a/google/cloud/tpu/v1/internal/tpu_tracing_stub.cc +++ b/google/cloud/tpu/v1/internal/tpu_tracing_stub.cc @@ -213,6 +213,28 @@ TpuTracingStub::GetAcceleratorType( context, *span, child_->GetAcceleratorType(context, options, request)); } +StatusOr +TpuTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.tpu.v1.Tpu", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr TpuTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.tpu.v1.Tpu", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> TpuTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/tpu/v1/internal/tpu_tracing_stub.h b/google/cloud/tpu/v1/internal/tpu_tracing_stub.h index 808e4b3e484f1..dd9ba187ed4a8 100644 --- a/google/cloud/tpu/v1/internal/tpu_tracing_stub.h +++ b/google/cloud/tpu/v1/internal/tpu_tracing_stub.h @@ -118,6 +118,14 @@ class TpuTracingStub : public TpuStub { google::cloud::tpu::v1::GetAcceleratorTypeRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/tpu/v1/mocks/mock_tpu_connection.h b/google/cloud/tpu/v1/mocks/mock_tpu_connection.h index 810c163875b7d..42b904a19c3a1 100644 --- a/google/cloud/tpu/v1/mocks/mock_tpu_connection.h +++ b/google/cloud/tpu/v1/mocks/mock_tpu_connection.h @@ -243,6 +243,14 @@ class MockTpuConnection : public tpu_v1::TpuConnection { StatusOr, GetAcceleratorType, (google::cloud::tpu::v1::GetAcceleratorTypeRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/tpu/v1/tpu_client.cc b/google/cloud/tpu/v1/tpu_client.cc index 07c9f9f5063e3..aa238d80d2a54 100644 --- a/google/cloud/tpu/v1/tpu_client.cc +++ b/google/cloud/tpu/v1/tpu_client.cc @@ -255,6 +255,18 @@ StatusOr TpuClient::GetAcceleratorType( return connection_->GetAcceleratorType(request); } +StreamRange TpuClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr TpuClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace tpu_v1 } // namespace cloud diff --git a/google/cloud/tpu/v1/tpu_client.h b/google/cloud/tpu/v1/tpu_client.h index 03f72380d6729..3020fed160c78 100644 --- a/google/cloud/tpu/v1/tpu_client.h +++ b/google/cloud/tpu/v1/tpu_client.h @@ -899,6 +899,76 @@ class TpuClient { google::cloud::tpu::v1::GetAcceleratorTypeRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/tpu/v1/tpu_connection.cc b/google/cloud/tpu/v1/tpu_connection.cc index 61bec4ef29baf..29d7dc4603c77 100644 --- a/google/cloud/tpu/v1/tpu_connection.cc +++ b/google/cloud/tpu/v1/tpu_connection.cc @@ -178,6 +178,18 @@ TpuConnection::GetAcceleratorType( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange TpuConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr TpuConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeTpuConnection(Options options) { internal::CheckExpectedOptions #include #include #include @@ -247,6 +248,12 @@ class TpuConnection { virtual StatusOr GetAcceleratorType( google::cloud::tpu::v1::GetAcceleratorTypeRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/tpu/v1/tpu_connection_idempotency_policy.cc b/google/cloud/tpu/v1/tpu_connection_idempotency_policy.cc index 63aebaa757152..e1e0f2f4f6a07 100644 --- a/google/cloud/tpu/v1/tpu_connection_idempotency_policy.cc +++ b/google/cloud/tpu/v1/tpu_connection_idempotency_policy.cc @@ -88,6 +88,16 @@ Idempotency TpuConnectionIdempotencyPolicy::GetAcceleratorType( return Idempotency::kIdempotent; } +Idempotency TpuConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency TpuConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultTpuConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/tpu/v1/tpu_connection_idempotency_policy.h b/google/cloud/tpu/v1/tpu_connection_idempotency_policy.h index 3cd88fe7c0542..91211fba1ec14 100644 --- a/google/cloud/tpu/v1/tpu_connection_idempotency_policy.h +++ b/google/cloud/tpu/v1/tpu_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -68,6 +69,12 @@ class TpuConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GetAcceleratorType( google::cloud::tpu::v1::GetAcceleratorTypeRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/tpu/v2/internal/tpu_auth_decorator.cc b/google/cloud/tpu/v2/internal/tpu_auth_decorator.cc index 76f58a2ab6b57..cbfb1038a78fd 100644 --- a/google/cloud/tpu/v2/internal/tpu_auth_decorator.cc +++ b/google/cloud/tpu/v2/internal/tpu_auth_decorator.cc @@ -234,6 +234,22 @@ TpuAuth::GetGuestAttributes( return child_->GetGuestAttributes(context, options, request); } +StatusOr TpuAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr TpuAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> TpuAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/tpu/v2/internal/tpu_auth_decorator.h b/google/cloud/tpu/v2/internal/tpu_auth_decorator.h index d02c7ea49bfaa..cdaa033727a41 100644 --- a/google/cloud/tpu/v2/internal/tpu_auth_decorator.h +++ b/google/cloud/tpu/v2/internal/tpu_auth_decorator.h @@ -128,6 +128,14 @@ class TpuAuth : public TpuStub { google::cloud::tpu::v2::GetGuestAttributesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/tpu/v2/internal/tpu_connection_impl.cc b/google/cloud/tpu/v2/internal/tpu_connection_impl.cc index 4ce5b77d09320..03d8922394c69 100644 --- a/google/cloud/tpu/v2/internal/tpu_connection_impl.cc +++ b/google/cloud/tpu/v2/internal/tpu_connection_impl.cc @@ -652,6 +652,51 @@ TpuConnectionImpl::GetGuestAttributes( *current, request, __func__); } +StreamRange TpuConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr(retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr TpuConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace tpu_v2_internal } // namespace cloud diff --git a/google/cloud/tpu/v2/internal/tpu_connection_impl.h b/google/cloud/tpu/v2/internal/tpu_connection_impl.h index 09f6f777ed16a..79ed79c1fab70 100644 --- a/google/cloud/tpu/v2/internal/tpu_connection_impl.h +++ b/google/cloud/tpu/v2/internal/tpu_connection_impl.h @@ -128,6 +128,12 @@ class TpuConnectionImpl : public tpu_v2::TpuConnection { GetGuestAttributes(google::cloud::tpu::v2::GetGuestAttributesRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/tpu/v2/internal/tpu_logging_decorator.cc b/google/cloud/tpu/v2/internal/tpu_logging_decorator.cc index 96c91b6084447..ef73ef82b6745 100644 --- a/google/cloud/tpu/v2/internal/tpu_logging_decorator.cc +++ b/google/cloud/tpu/v2/internal/tpu_logging_decorator.cc @@ -271,6 +271,29 @@ TpuLogging::GetGuestAttributes( context, options, request, __func__, tracing_options_); } +StatusOr +TpuLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr TpuLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> TpuLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/tpu/v2/internal/tpu_logging_decorator.h b/google/cloud/tpu/v2/internal/tpu_logging_decorator.h index b4eaf20bc651f..658988757f804 100644 --- a/google/cloud/tpu/v2/internal/tpu_logging_decorator.h +++ b/google/cloud/tpu/v2/internal/tpu_logging_decorator.h @@ -127,6 +127,14 @@ class TpuLogging : public TpuStub { google::cloud::tpu::v2::GetGuestAttributesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/tpu/v2/internal/tpu_metadata_decorator.cc b/google/cloud/tpu/v2/internal/tpu_metadata_decorator.cc index 167b5434444f5..9e9bcb740f008 100644 --- a/google/cloud/tpu/v2/internal/tpu_metadata_decorator.cc +++ b/google/cloud/tpu/v2/internal/tpu_metadata_decorator.cc @@ -209,6 +209,23 @@ TpuMetadata::GetGuestAttributes( return child_->GetGuestAttributes(context, options, request); } +StatusOr +TpuMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr TpuMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> TpuMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/tpu/v2/internal/tpu_metadata_decorator.h b/google/cloud/tpu/v2/internal/tpu_metadata_decorator.h index 5ee946efde668..ecfa1d48afa1f 100644 --- a/google/cloud/tpu/v2/internal/tpu_metadata_decorator.h +++ b/google/cloud/tpu/v2/internal/tpu_metadata_decorator.h @@ -128,6 +128,14 @@ class TpuMetadata : public TpuStub { google::cloud::tpu::v2::GetGuestAttributesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/tpu/v2/internal/tpu_stub.cc b/google/cloud/tpu/v2/internal/tpu_stub.cc index 0244644cf6b65..fe24bc5f3e130 100644 --- a/google/cloud/tpu/v2/internal/tpu_stub.cc +++ b/google/cloud/tpu/v2/internal/tpu_stub.cc @@ -264,6 +264,29 @@ DefaultTpuStub::GetGuestAttributes( return response; } +StatusOr +DefaultTpuStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultTpuStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultTpuStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/tpu/v2/internal/tpu_stub.h b/google/cloud/tpu/v2/internal/tpu_stub.h index 18a35b363cafe..8b4328555712b 100644 --- a/google/cloud/tpu/v2/internal/tpu_stub.h +++ b/google/cloud/tpu/v2/internal/tpu_stub.h @@ -24,6 +24,8 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include #include @@ -125,6 +127,15 @@ class TpuStub { grpc::ClientContext& context, Options const& options, google::cloud::tpu::v2::GetGuestAttributesRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -142,9 +153,13 @@ class DefaultTpuStub : public TpuStub { public: DefaultTpuStub( std::unique_ptr grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListNodes( grpc::ClientContext& context, Options const& options, @@ -235,6 +250,14 @@ class DefaultTpuStub : public TpuStub { google::cloud::tpu::v2::GetGuestAttributesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -249,6 +272,8 @@ class DefaultTpuStub : public TpuStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/tpu/v2/internal/tpu_stub_factory.cc b/google/cloud/tpu/v2/internal/tpu_stub_factory.cc index 123ce04fc877e..9089aa57444de 100644 --- a/google/cloud/tpu/v2/internal/tpu_stub_factory.cc +++ b/google/cloud/tpu/v2/internal/tpu_stub_factory.cc @@ -28,6 +28,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -43,8 +44,10 @@ std::shared_ptr CreateDefaultTpuStub( auto channel = auth->CreateChannel(options.get(), internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::tpu::v2::Tpu::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/tpu/v2/internal/tpu_tracing_connection.cc b/google/cloud/tpu/v2/internal/tpu_tracing_connection.cc index 2efabfd2cae94..e6bce4cbfd61c 100644 --- a/google/cloud/tpu/v2/internal/tpu_tracing_connection.cc +++ b/google/cloud/tpu/v2/internal/tpu_tracing_connection.cc @@ -209,6 +209,23 @@ TpuTracingConnection::GetGuestAttributes( return internal::EndSpan(*span, child_->GetGuestAttributes(request)); } +StreamRange +TpuTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan("tpu_v2::TpuConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr TpuTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan("tpu_v2::TpuConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr MakeTpuTracingConnection( diff --git a/google/cloud/tpu/v2/internal/tpu_tracing_connection.h b/google/cloud/tpu/v2/internal/tpu_tracing_connection.h index 05e23c67ef9d7..598638006182b 100644 --- a/google/cloud/tpu/v2/internal/tpu_tracing_connection.h +++ b/google/cloud/tpu/v2/internal/tpu_tracing_connection.h @@ -116,6 +116,12 @@ class TpuTracingConnection : public tpu_v2::TpuConnection { GetGuestAttributes(google::cloud::tpu::v2::GetGuestAttributesRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/tpu/v2/internal/tpu_tracing_stub.cc b/google/cloud/tpu/v2/internal/tpu_tracing_stub.cc index 421dfe7304738..fd470483f0e67 100644 --- a/google/cloud/tpu/v2/internal/tpu_tracing_stub.cc +++ b/google/cloud/tpu/v2/internal/tpu_tracing_stub.cc @@ -237,6 +237,28 @@ TpuTracingStub::GetGuestAttributes( context, *span, child_->GetGuestAttributes(context, options, request)); } +StatusOr +TpuTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.cloud.tpu.v2.Tpu", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr TpuTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.tpu.v2.Tpu", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> TpuTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/tpu/v2/internal/tpu_tracing_stub.h b/google/cloud/tpu/v2/internal/tpu_tracing_stub.h index b3684db55f58c..6982456b1430c 100644 --- a/google/cloud/tpu/v2/internal/tpu_tracing_stub.h +++ b/google/cloud/tpu/v2/internal/tpu_tracing_stub.h @@ -127,6 +127,14 @@ class TpuTracingStub : public TpuStub { google::cloud::tpu::v2::GetGuestAttributesRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/tpu/v2/mocks/mock_tpu_connection.h b/google/cloud/tpu/v2/mocks/mock_tpu_connection.h index e08cd0b49bd8c..13bb17405675c 100644 --- a/google/cloud/tpu/v2/mocks/mock_tpu_connection.h +++ b/google/cloud/tpu/v2/mocks/mock_tpu_connection.h @@ -256,6 +256,14 @@ class MockTpuConnection : public tpu_v2::TpuConnection { GetGuestAttributes, (google::cloud::tpu::v2::GetGuestAttributesRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/tpu/v2/tpu_client.cc b/google/cloud/tpu/v2/tpu_client.cc index 9767e373f8583..77b72d857714a 100644 --- a/google/cloud/tpu/v2/tpu_client.cc +++ b/google/cloud/tpu/v2/tpu_client.cc @@ -291,6 +291,18 @@ TpuClient::GetGuestAttributes( return connection_->GetGuestAttributes(request); } +StreamRange TpuClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr TpuClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace tpu_v2 } // namespace cloud diff --git a/google/cloud/tpu/v2/tpu_client.h b/google/cloud/tpu/v2/tpu_client.h index eb37e1e35b95b..ad601164f9400 100644 --- a/google/cloud/tpu/v2/tpu_client.h +++ b/google/cloud/tpu/v2/tpu_client.h @@ -1014,6 +1014,76 @@ class TpuClient { google::cloud::tpu::v2::GetGuestAttributesRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/tpu/v2/tpu_connection.cc b/google/cloud/tpu/v2/tpu_connection.cc index aa0b1cf603335..9c309c2775960 100644 --- a/google/cloud/tpu/v2/tpu_connection.cc +++ b/google/cloud/tpu/v2/tpu_connection.cc @@ -190,6 +190,18 @@ TpuConnection::GetGuestAttributes( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange TpuConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr TpuConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeTpuConnection(Options options) { internal::CheckExpectedOptions #include #include #include @@ -254,6 +255,12 @@ class TpuConnection { virtual StatusOr GetGuestAttributes( google::cloud::tpu::v2::GetGuestAttributesRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/tpu/v2/tpu_connection_idempotency_policy.cc b/google/cloud/tpu/v2/tpu_connection_idempotency_policy.cc index 251c24c615534..b153bd3af1515 100644 --- a/google/cloud/tpu/v2/tpu_connection_idempotency_policy.cc +++ b/google/cloud/tpu/v2/tpu_connection_idempotency_policy.cc @@ -98,6 +98,16 @@ Idempotency TpuConnectionIdempotencyPolicy::GetGuestAttributes( return Idempotency::kNonIdempotent; } +Idempotency TpuConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency TpuConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultTpuConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/tpu/v2/tpu_connection_idempotency_policy.h b/google/cloud/tpu/v2/tpu_connection_idempotency_policy.h index 34a147cc01617..6b9a8bdd32e0f 100644 --- a/google/cloud/tpu/v2/tpu_connection_idempotency_policy.h +++ b/google/cloud/tpu/v2/tpu_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -74,6 +75,12 @@ class TpuConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GetGuestAttributes( google::cloud::tpu::v2::GetGuestAttributesRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/translate/BUILD.bazel b/google/cloud/translate/BUILD.bazel index 26658ea670c41..064b0b044f45b 100644 --- a/google/cloud/translate/BUILD.bazel +++ b/google/cloud/translate/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/translate/v3:translation_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/translate/v3/internal/translation_auth_decorator.cc b/google/cloud/translate/v3/internal/translation_auth_decorator.cc index ad593b9a5a0d4..2319deb2eb949 100644 --- a/google/cloud/translate/v3/internal/translation_auth_decorator.cc +++ b/google/cloud/translate/v3/internal/translation_auth_decorator.cc @@ -591,6 +591,23 @@ StatusOr TranslationServiceAuth::DeleteModel( return child_->DeleteModel(context, options, request); } +StatusOr +TranslationServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr TranslationServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> TranslationServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/translate/v3/internal/translation_auth_decorator.h b/google/cloud/translate/v3/internal/translation_auth_decorator.h index 0760569d0c075..780000493062c 100644 --- a/google/cloud/translate/v3/internal/translation_auth_decorator.h +++ b/google/cloud/translate/v3/internal/translation_auth_decorator.h @@ -315,6 +315,14 @@ class TranslationServiceAuth : public TranslationServiceStub { google::cloud::translation::v3::DeleteModelRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/translate/v3/internal/translation_connection_impl.cc b/google/cloud/translate/v3/internal/translation_connection_impl.cc index be8be34547c2e..57c75af23a911 100644 --- a/google/cloud/translate/v3/internal/translation_connection_impl.cc +++ b/google/cloud/translate/v3/internal/translation_connection_impl.cc @@ -1656,6 +1656,54 @@ TranslationServiceConnectionImpl::DeleteModel( polling_policy(*current), __func__); } +StreamRange +TranslationServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +TranslationServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace translate_v3_internal } // namespace cloud diff --git a/google/cloud/translate/v3/internal/translation_connection_impl.h b/google/cloud/translate/v3/internal/translation_connection_impl.h index 80c8f8467f597..0588402651391 100644 --- a/google/cloud/translate/v3/internal/translation_connection_impl.h +++ b/google/cloud/translate/v3/internal/translation_connection_impl.h @@ -300,6 +300,12 @@ class TranslationServiceConnectionImpl future> DeleteModel(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/translate/v3/internal/translation_logging_decorator.cc b/google/cloud/translate/v3/internal/translation_logging_decorator.cc index 38938aa22b2e1..c28804a9ec050 100644 --- a/google/cloud/translate/v3/internal/translation_logging_decorator.cc +++ b/google/cloud/translate/v3/internal/translation_logging_decorator.cc @@ -740,6 +740,30 @@ StatusOr TranslationServiceLogging::DeleteModel( context, options, request, __func__, tracing_options_); } +StatusOr +TranslationServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +TranslationServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> TranslationServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/translate/v3/internal/translation_logging_decorator.h b/google/cloud/translate/v3/internal/translation_logging_decorator.h index 76a67e160cf90..263ccb4708c62 100644 --- a/google/cloud/translate/v3/internal/translation_logging_decorator.h +++ b/google/cloud/translate/v3/internal/translation_logging_decorator.h @@ -315,6 +315,14 @@ class TranslationServiceLogging : public TranslationServiceStub { google::cloud::translation::v3::DeleteModelRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/translate/v3/internal/translation_metadata_decorator.cc b/google/cloud/translate/v3/internal/translation_metadata_decorator.cc index 43a192051697f..f237fe803e512 100644 --- a/google/cloud/translate/v3/internal/translation_metadata_decorator.cc +++ b/google/cloud/translate/v3/internal/translation_metadata_decorator.cc @@ -527,6 +527,24 @@ TranslationServiceMetadata::DeleteModel( return child_->DeleteModel(context, options, request); } +StatusOr +TranslationServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +TranslationServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> TranslationServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/translate/v3/internal/translation_metadata_decorator.h b/google/cloud/translate/v3/internal/translation_metadata_decorator.h index cb240d0d7092a..578312383dcc1 100644 --- a/google/cloud/translate/v3/internal/translation_metadata_decorator.h +++ b/google/cloud/translate/v3/internal/translation_metadata_decorator.h @@ -316,6 +316,14 @@ class TranslationServiceMetadata : public TranslationServiceStub { google::cloud::translation::v3::DeleteModelRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/translate/v3/internal/translation_stub.cc b/google/cloud/translate/v3/internal/translation_stub.cc index 1b69c0269c317..00da737a6e416 100644 --- a/google/cloud/translate/v3/internal/translation_stub.cc +++ b/google/cloud/translate/v3/internal/translation_stub.cc @@ -705,6 +705,30 @@ DefaultTranslationServiceStub::DeleteModel( return response; } +StatusOr +DefaultTranslationServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultTranslationServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultTranslationServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/translate/v3/internal/translation_stub.h b/google/cloud/translate/v3/internal/translation_stub.h index 5540ba1148bd7..a0434c022027e 100644 --- a/google/cloud/translate/v3/internal/translation_stub.h +++ b/google/cloud/translate/v3/internal/translation_stub.h @@ -24,7 +24,10 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include +#include #include #include #include @@ -302,6 +305,15 @@ class TranslationServiceStub { grpc::ClientContext& context, Options options, google::cloud::translation::v3::DeleteModelRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -321,9 +333,13 @@ class DefaultTranslationServiceStub : public TranslationServiceStub { std::unique_ptr< google::cloud::translation::v3::TranslationService::StubInterface> grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr TranslateText( grpc::ClientContext& context, Options const& options, @@ -601,6 +617,14 @@ class DefaultTranslationServiceStub : public TranslationServiceStub { google::cloud::translation::v3::DeleteModelRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -617,6 +641,8 @@ class DefaultTranslationServiceStub : public TranslationServiceStub { std::unique_ptr< google::cloud::translation::v3::TranslationService::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/translate/v3/internal/translation_stub_factory.cc b/google/cloud/translate/v3/internal/translation_stub_factory.cc index 56c20f5b193d9..9770f4f9dd8d6 100644 --- a/google/cloud/translate/v3/internal/translation_stub_factory.cc +++ b/google/cloud/translate/v3/internal/translation_stub_factory.cc @@ -28,6 +28,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultTranslationServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::translation::v3::TranslationService::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/translate/v3/internal/translation_tracing_connection.cc b/google/cloud/translate/v3/internal/translation_tracing_connection.cc index a4c9488d8ae63..37c2cb9e9330b 100644 --- a/google/cloud/translate/v3/internal/translation_tracing_connection.cc +++ b/google/cloud/translate/v3/internal/translation_tracing_connection.cc @@ -618,6 +618,26 @@ TranslationServiceTracingConnection::DeleteModel( return internal::EndSpan(std::move(span), child_->DeleteModel(operation)); } +StreamRange +TranslationServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "translate_v3::TranslationServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +TranslationServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "translate_v3::TranslationServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/translate/v3/internal/translation_tracing_connection.h b/google/cloud/translate/v3/internal/translation_tracing_connection.h index e3fe69b8c233b..00176480ddeac 100644 --- a/google/cloud/translate/v3/internal/translation_tracing_connection.h +++ b/google/cloud/translate/v3/internal/translation_tracing_connection.h @@ -288,6 +288,12 @@ class TranslationServiceTracingConnection future> DeleteModel(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/translate/v3/internal/translation_tracing_stub.cc b/google/cloud/translate/v3/internal/translation_tracing_stub.cc index 7108e2d93a2bf..e0881fd4f72fa 100644 --- a/google/cloud/translate/v3/internal/translation_tracing_stub.cc +++ b/google/cloud/translate/v3/internal/translation_tracing_stub.cc @@ -666,6 +666,30 @@ TranslationServiceTracingStub::DeleteModel( child_->DeleteModel(context, options, request)); } +StatusOr +TranslationServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.translation.v3.TranslationService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +TranslationServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.translation.v3.TranslationService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> TranslationServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/translate/v3/internal/translation_tracing_stub.h b/google/cloud/translate/v3/internal/translation_tracing_stub.h index 14081c6964887..4143fc258e367 100644 --- a/google/cloud/translate/v3/internal/translation_tracing_stub.h +++ b/google/cloud/translate/v3/internal/translation_tracing_stub.h @@ -315,6 +315,14 @@ class TranslationServiceTracingStub : public TranslationServiceStub { google::cloud::translation::v3::DeleteModelRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/translate/v3/mocks/mock_translation_connection.h b/google/cloud/translate/v3/mocks/mock_translation_connection.h index 576009a2dc174..897c74ec2bdc1 100644 --- a/google/cloud/translate/v3/mocks/mock_translation_connection.h +++ b/google/cloud/translate/v3/mocks/mock_translation_connection.h @@ -641,6 +641,14 @@ class MockTranslationServiceConnection future>, DeleteModel, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/translate/v3/translation_client.cc b/google/cloud/translate/v3/translation_client.cc index 5ed3cad73d350..3f9b66c946c79 100644 --- a/google/cloud/translate/v3/translation_client.cc +++ b/google/cloud/translate/v3/translation_client.cc @@ -1001,6 +1001,20 @@ TranslationServiceClient::DeleteModel( return connection_->DeleteModel(operation); } +StreamRange +TranslationServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +TranslationServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace translate_v3 } // namespace cloud diff --git a/google/cloud/translate/v3/translation_client.h b/google/cloud/translate/v3/translation_client.h index 236b624517688..186c072671b61 100644 --- a/google/cloud/translate/v3/translation_client.h +++ b/google/cloud/translate/v3/translation_client.h @@ -3205,6 +3205,76 @@ class TranslationServiceClient { DeleteModel(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/translate/v3/translation_connection.cc b/google/cloud/translate/v3/translation_connection.cc index f3f20900b2e46..9dca7c5963308 100644 --- a/google/cloud/translate/v3/translation_connection.cc +++ b/google/cloud/translate/v3/translation_connection.cc @@ -468,6 +468,20 @@ TranslationServiceConnection::DeleteModel( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +TranslationServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +TranslationServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeTranslationServiceConnection( Options options) { internal::CheckExpectedOptions #include +#include #include #include @@ -424,6 +426,12 @@ class TranslationServiceConnection { virtual future> DeleteModel(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/translate/v3/translation_connection_idempotency_policy.cc b/google/cloud/translate/v3/translation_connection_idempotency_policy.cc index 331ff19b12093..a70ecf99cfdb6 100644 --- a/google/cloud/translate/v3/translation_connection_idempotency_policy.cc +++ b/google/cloud/translate/v3/translation_connection_idempotency_policy.cc @@ -230,6 +230,16 @@ Idempotency TranslationServiceConnectionIdempotencyPolicy::DeleteModel( return Idempotency::kNonIdempotent; } +Idempotency TranslationServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency TranslationServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultTranslationServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/translate/v3/translation_connection_idempotency_policy.h b/google/cloud/translate/v3/translation_connection_idempotency_policy.h index ea137ca41381b..c368dbbf7f1a2 100644 --- a/google/cloud/translate/v3/translation_connection_idempotency_policy.h +++ b/google/cloud/translate/v3/translation_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -161,6 +162,12 @@ class TranslationServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteModel( google::cloud::translation::v3::DeleteModelRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/video/BUILD.bazel b/google/cloud/video/BUILD.bazel index 0645dff9ae20b..ed5931b093118 100644 --- a/google/cloud/video/BUILD.bazel +++ b/google/cloud/video/BUILD.bazel @@ -29,6 +29,8 @@ googleapis_deps = [ "@com_google_googleapis//google/cloud/video/livestream/v1:livestream_cc_grpc", "@com_google_googleapis//google/cloud/video/stitcher/v1:stitcher_cc_grpc", "@com_google_googleapis//google/cloud/video/transcoder/v1:transcoder_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/video/livestream/v1/internal/livestream_auth_decorator.cc b/google/cloud/video/livestream/v1/internal/livestream_auth_decorator.cc index 841605153297b..e97cfc0ec3459 100644 --- a/google/cloud/video/livestream/v1/internal/livestream_auth_decorator.cc +++ b/google/cloud/video/livestream/v1/internal/livestream_auth_decorator.cc @@ -511,6 +511,23 @@ StatusOr LivestreamServiceAuth::UpdatePool( return child_->UpdatePool(context, options, request); } +StatusOr +LivestreamServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr LivestreamServiceAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> LivestreamServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/video/livestream/v1/internal/livestream_auth_decorator.h b/google/cloud/video/livestream/v1/internal/livestream_auth_decorator.h index b1a34dac74dc4..af1d3c87d77c2 100644 --- a/google/cloud/video/livestream/v1/internal/livestream_auth_decorator.h +++ b/google/cloud/video/livestream/v1/internal/livestream_auth_decorator.h @@ -260,6 +260,14 @@ class LivestreamServiceAuth : public LivestreamServiceStub { google::cloud::video::livestream::v1::UpdatePoolRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/video/livestream/v1/internal/livestream_connection_impl.cc b/google/cloud/video/livestream/v1/internal/livestream_connection_impl.cc index 01293167f2e0a..3984127720a4e 100644 --- a/google/cloud/video/livestream/v1/internal/livestream_connection_impl.cc +++ b/google/cloud/video/livestream/v1/internal/livestream_connection_impl.cc @@ -1591,6 +1591,55 @@ LivestreamServiceConnectionImpl::UpdatePool( polling_policy(*current), __func__); } +StreamRange +LivestreamServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = + std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +LivestreamServiceConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace video_livestream_v1_internal } // namespace cloud diff --git a/google/cloud/video/livestream/v1/internal/livestream_connection_impl.h b/google/cloud/video/livestream/v1/internal/livestream_connection_impl.h index 089a6024dd4b0..1d5d7de7a1ef0 100644 --- a/google/cloud/video/livestream/v1/internal/livestream_connection_impl.h +++ b/google/cloud/video/livestream/v1/internal/livestream_connection_impl.h @@ -261,6 +261,12 @@ class LivestreamServiceConnectionImpl future> UpdatePool( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/video/livestream/v1/internal/livestream_logging_decorator.cc b/google/cloud/video/livestream/v1/internal/livestream_logging_decorator.cc index 63a008b302193..f5ff69a9ab9f6 100644 --- a/google/cloud/video/livestream/v1/internal/livestream_logging_decorator.cc +++ b/google/cloud/video/livestream/v1/internal/livestream_logging_decorator.cc @@ -609,6 +609,30 @@ StatusOr LivestreamServiceLogging::UpdatePool( context, options, request, __func__, tracing_options_); } +StatusOr +LivestreamServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +LivestreamServiceLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> LivestreamServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/video/livestream/v1/internal/livestream_logging_decorator.h b/google/cloud/video/livestream/v1/internal/livestream_logging_decorator.h index 57235b96445db..78cbeea44b214 100644 --- a/google/cloud/video/livestream/v1/internal/livestream_logging_decorator.h +++ b/google/cloud/video/livestream/v1/internal/livestream_logging_decorator.h @@ -260,6 +260,14 @@ class LivestreamServiceLogging : public LivestreamServiceStub { google::cloud::video::livestream::v1::UpdatePoolRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/video/livestream/v1/internal/livestream_metadata_decorator.cc b/google/cloud/video/livestream/v1/internal/livestream_metadata_decorator.cc index 320352099e8e8..0eb50248373c0 100644 --- a/google/cloud/video/livestream/v1/internal/livestream_metadata_decorator.cc +++ b/google/cloud/video/livestream/v1/internal/livestream_metadata_decorator.cc @@ -430,6 +430,24 @@ StatusOr LivestreamServiceMetadata::UpdatePool( return child_->UpdatePool(context, options, request); } +StatusOr +LivestreamServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr +LivestreamServiceMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> LivestreamServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/video/livestream/v1/internal/livestream_metadata_decorator.h b/google/cloud/video/livestream/v1/internal/livestream_metadata_decorator.h index a4f1a1feb6eba..943fc74b8e803 100644 --- a/google/cloud/video/livestream/v1/internal/livestream_metadata_decorator.h +++ b/google/cloud/video/livestream/v1/internal/livestream_metadata_decorator.h @@ -261,6 +261,14 @@ class LivestreamServiceMetadata : public LivestreamServiceStub { google::cloud::video::livestream::v1::UpdatePoolRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/video/livestream/v1/internal/livestream_stub.cc b/google/cloud/video/livestream/v1/internal/livestream_stub.cc index 20c2abbf3f896..6a09babc97544 100644 --- a/google/cloud/video/livestream/v1/internal/livestream_stub.cc +++ b/google/cloud/video/livestream/v1/internal/livestream_stub.cc @@ -589,6 +589,30 @@ DefaultLivestreamServiceStub::UpdatePool( return response; } +StatusOr +DefaultLivestreamServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultLivestreamServiceStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultLivestreamServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/video/livestream/v1/internal/livestream_stub.h b/google/cloud/video/livestream/v1/internal/livestream_stub.h index 3dbba18a4fcbd..447ba30cc5eb9 100644 --- a/google/cloud/video/livestream/v1/internal/livestream_stub.h +++ b/google/cloud/video/livestream/v1/internal/livestream_stub.h @@ -24,6 +24,8 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include #include @@ -254,6 +256,15 @@ class LivestreamServiceStub { google::cloud::video::livestream::v1::UpdatePoolRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -273,9 +284,13 @@ class DefaultLivestreamServiceStub : public LivestreamServiceStub { std::unique_ptr grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateChannel( google::cloud::CompletionQueue& cq, @@ -498,6 +513,14 @@ class DefaultLivestreamServiceStub : public LivestreamServiceStub { google::cloud::video::livestream::v1::UpdatePoolRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -514,6 +537,8 @@ class DefaultLivestreamServiceStub : public LivestreamServiceStub { std::unique_ptr< google::cloud::video::livestream::v1::LivestreamService::StubInterface> grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/video/livestream/v1/internal/livestream_stub_factory.cc b/google/cloud/video/livestream/v1/internal/livestream_stub_factory.cc index 34f785b6ef7a7..c7f1c33fba587 100644 --- a/google/cloud/video/livestream/v1/internal/livestream_stub_factory.cc +++ b/google/cloud/video/livestream/v1/internal/livestream_stub_factory.cc @@ -28,6 +28,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultLivestreamServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::video::livestream::v1::LivestreamService::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/video/livestream/v1/internal/livestream_tracing_connection.cc b/google/cloud/video/livestream/v1/internal/livestream_tracing_connection.cc index 336d9ddb3d2b0..176e9812cfe55 100644 --- a/google/cloud/video/livestream/v1/internal/livestream_tracing_connection.cc +++ b/google/cloud/video/livestream/v1/internal/livestream_tracing_connection.cc @@ -528,6 +528,26 @@ LivestreamServiceTracingConnection::UpdatePool( return internal::EndSpan(std::move(span), child_->UpdatePool(operation)); } +StreamRange +LivestreamServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "video_livestream_v1::LivestreamServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +LivestreamServiceTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "video_livestream_v1::LivestreamServiceConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/video/livestream/v1/internal/livestream_tracing_connection.h b/google/cloud/video/livestream/v1/internal/livestream_tracing_connection.h index a756666e3eceb..5b3b8d806f841 100644 --- a/google/cloud/video/livestream/v1/internal/livestream_tracing_connection.h +++ b/google/cloud/video/livestream/v1/internal/livestream_tracing_connection.h @@ -249,6 +249,12 @@ class LivestreamServiceTracingConnection future> UpdatePool( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/video/livestream/v1/internal/livestream_tracing_stub.cc b/google/cloud/video/livestream/v1/internal/livestream_tracing_stub.cc index a609ba2049486..2da9cb55c9447 100644 --- a/google/cloud/video/livestream/v1/internal/livestream_tracing_stub.cc +++ b/google/cloud/video/livestream/v1/internal/livestream_tracing_stub.cc @@ -525,6 +525,30 @@ LivestreamServiceTracingStub::UpdatePool( child_->UpdatePool(context, options, request)); } +StatusOr +LivestreamServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.video.livestream.v1.LivestreamService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +LivestreamServiceTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.video.livestream.v1.LivestreamService", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> LivestreamServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/video/livestream/v1/internal/livestream_tracing_stub.h b/google/cloud/video/livestream/v1/internal/livestream_tracing_stub.h index 16e275d1f2bb7..5f9bfbd674acf 100644 --- a/google/cloud/video/livestream/v1/internal/livestream_tracing_stub.h +++ b/google/cloud/video/livestream/v1/internal/livestream_tracing_stub.h @@ -260,6 +260,14 @@ class LivestreamServiceTracingStub : public LivestreamServiceStub { google::cloud::video::livestream::v1::UpdatePoolRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/video/livestream/v1/livestream_client.cc b/google/cloud/video/livestream/v1/livestream_client.cc index 935315b3e44a2..25e914df4d080 100644 --- a/google/cloud/video/livestream/v1/livestream_client.cc +++ b/google/cloud/video/livestream/v1/livestream_client.cc @@ -802,6 +802,20 @@ LivestreamServiceClient::UpdatePool( return connection_->UpdatePool(operation); } +StreamRange +LivestreamServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr +LivestreamServiceClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace video_livestream_v1 } // namespace cloud diff --git a/google/cloud/video/livestream/v1/livestream_client.h b/google/cloud/video/livestream/v1/livestream_client.h index b831e108bc0eb..386fd42f55e22 100644 --- a/google/cloud/video/livestream/v1/livestream_client.h +++ b/google/cloud/video/livestream/v1/livestream_client.h @@ -2499,6 +2499,76 @@ class LivestreamServiceClient { future> UpdatePool( google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/video/livestream/v1/livestream_connection.cc b/google/cloud/video/livestream/v1/livestream_connection.cc index 22e505772130c..603e8a5ee2021 100644 --- a/google/cloud/video/livestream/v1/livestream_connection.cc +++ b/google/cloud/video/livestream/v1/livestream_connection.cc @@ -434,6 +434,20 @@ LivestreamServiceConnection::UpdatePool(google::longrunning::Operation const&) { Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +LivestreamServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr +LivestreamServiceConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeLivestreamServiceConnection( Options options) { internal::CheckExpectedOptions #include #include #include @@ -388,6 +389,12 @@ class LivestreamServiceConnection { virtual future> UpdatePool(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/video/livestream/v1/livestream_connection_idempotency_policy.cc b/google/cloud/video/livestream/v1/livestream_connection_idempotency_policy.cc index c9a26a2fa30b1..46550139d1fbe 100644 --- a/google/cloud/video/livestream/v1/livestream_connection_idempotency_policy.cc +++ b/google/cloud/video/livestream/v1/livestream_connection_idempotency_policy.cc @@ -164,6 +164,16 @@ Idempotency LivestreamServiceConnectionIdempotencyPolicy::UpdatePool( return Idempotency::kNonIdempotent; } +Idempotency LivestreamServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency LivestreamServiceConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultLivestreamServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/video/livestream/v1/livestream_connection_idempotency_policy.h b/google/cloud/video/livestream/v1/livestream_connection_idempotency_policy.h index 1f370fdacd6d0..eae069055814b 100644 --- a/google/cloud/video/livestream/v1/livestream_connection_idempotency_policy.h +++ b/google/cloud/video/livestream/v1/livestream_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -117,6 +118,12 @@ class LivestreamServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency UpdatePool( google::cloud::video::livestream::v1::UpdatePoolRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/video/livestream/v1/mocks/mock_livestream_connection.h b/google/cloud/video/livestream/v1/mocks/mock_livestream_connection.h index 5c620a097b5ac..a55783d2222c4 100644 --- a/google/cloud/video/livestream/v1/mocks/mock_livestream_connection.h +++ b/google/cloud/video/livestream/v1/mocks/mock_livestream_connection.h @@ -629,6 +629,14 @@ class MockLivestreamServiceConnection MOCK_METHOD(future>, UpdatePool, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/vmmigration/BUILD.bazel b/google/cloud/vmmigration/BUILD.bazel index 1ab07a796fff6..7bdaafc406d4d 100644 --- a/google/cloud/vmmigration/BUILD.bazel +++ b/google/cloud/vmmigration/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/vmmigration/v1:vmmigration_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/vmmigration/v1/internal/vm_migration_auth_decorator.cc b/google/cloud/vmmigration/v1/internal/vm_migration_auth_decorator.cc index 30b85caaa73f6..bd6a38f809472 100644 --- a/google/cloud/vmmigration/v1/internal/vm_migration_auth_decorator.cc +++ b/google/cloud/vmmigration/v1/internal/vm_migration_auth_decorator.cc @@ -974,6 +974,23 @@ VmMigrationAuth::GetReplicationCycle( return child_->GetReplicationCycle(context, options, request); } +StatusOr +VmMigrationAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr VmMigrationAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> VmMigrationAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/vmmigration/v1/internal/vm_migration_auth_decorator.h b/google/cloud/vmmigration/v1/internal/vm_migration_auth_decorator.h index 05898b5596b2d..140593795fe0d 100644 --- a/google/cloud/vmmigration/v1/internal/vm_migration_auth_decorator.h +++ b/google/cloud/vmmigration/v1/internal/vm_migration_auth_decorator.h @@ -466,6 +466,14 @@ class VmMigrationAuth : public VmMigrationStub { google::cloud::vmmigration::v1::GetReplicationCycleRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/vmmigration/v1/internal/vm_migration_connection_impl.cc b/google/cloud/vmmigration/v1/internal/vm_migration_connection_impl.cc index d2bf3b269237a..4cac9c299abd2 100644 --- a/google/cloud/vmmigration/v1/internal/vm_migration_connection_impl.cc +++ b/google/cloud/vmmigration/v1/internal/vm_migration_connection_impl.cc @@ -3037,6 +3037,54 @@ VmMigrationConnectionImpl::GetReplicationCycle( *current, request, __func__); } +StreamRange +VmMigrationConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +VmMigrationConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace vmmigration_v1_internal } // namespace cloud diff --git a/google/cloud/vmmigration/v1/internal/vm_migration_connection_impl.h b/google/cloud/vmmigration/v1/internal/vm_migration_connection_impl.h index d9f68d9d1ad2a..fbf29feea7ae3 100644 --- a/google/cloud/vmmigration/v1/internal/vm_migration_connection_impl.h +++ b/google/cloud/vmmigration/v1/internal/vm_migration_connection_impl.h @@ -470,6 +470,12 @@ class VmMigrationConnectionImpl : public vmmigration_v1::VmMigrationConnection { google::cloud::vmmigration::v1::GetReplicationCycleRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/vmmigration/v1/internal/vm_migration_logging_decorator.cc b/google/cloud/vmmigration/v1/internal/vm_migration_logging_decorator.cc index b0a311546cd4e..dfa262a70151f 100644 --- a/google/cloud/vmmigration/v1/internal/vm_migration_logging_decorator.cc +++ b/google/cloud/vmmigration/v1/internal/vm_migration_logging_decorator.cc @@ -1144,6 +1144,29 @@ VmMigrationLogging::GetReplicationCycle( context, options, request, __func__, tracing_options_); } +StatusOr +VmMigrationLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr VmMigrationLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> VmMigrationLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/vmmigration/v1/internal/vm_migration_logging_decorator.h b/google/cloud/vmmigration/v1/internal/vm_migration_logging_decorator.h index 50c6b724039eb..0729709f2d6bf 100644 --- a/google/cloud/vmmigration/v1/internal/vm_migration_logging_decorator.h +++ b/google/cloud/vmmigration/v1/internal/vm_migration_logging_decorator.h @@ -466,6 +466,14 @@ class VmMigrationLogging : public VmMigrationStub { google::cloud::vmmigration::v1::GetReplicationCycleRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/vmmigration/v1/internal/vm_migration_metadata_decorator.cc b/google/cloud/vmmigration/v1/internal/vm_migration_metadata_decorator.cc index aa47c84da838a..a819903b707cf 100644 --- a/google/cloud/vmmigration/v1/internal/vm_migration_metadata_decorator.cc +++ b/google/cloud/vmmigration/v1/internal/vm_migration_metadata_decorator.cc @@ -798,6 +798,23 @@ VmMigrationMetadata::GetReplicationCycle( return child_->GetReplicationCycle(context, options, request); } +StatusOr +VmMigrationMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr VmMigrationMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> VmMigrationMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/vmmigration/v1/internal/vm_migration_metadata_decorator.h b/google/cloud/vmmigration/v1/internal/vm_migration_metadata_decorator.h index eef4f2d9b365e..d53bcff959b6e 100644 --- a/google/cloud/vmmigration/v1/internal/vm_migration_metadata_decorator.h +++ b/google/cloud/vmmigration/v1/internal/vm_migration_metadata_decorator.h @@ -466,6 +466,14 @@ class VmMigrationMetadata : public VmMigrationStub { google::cloud::vmmigration::v1::GetReplicationCycleRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/vmmigration/v1/internal/vm_migration_stub.cc b/google/cloud/vmmigration/v1/internal/vm_migration_stub.cc index 6f656134759b1..21e7a3ca3c84b 100644 --- a/google/cloud/vmmigration/v1/internal/vm_migration_stub.cc +++ b/google/cloud/vmmigration/v1/internal/vm_migration_stub.cc @@ -1104,6 +1104,29 @@ DefaultVmMigrationStub::GetReplicationCycle( return response; } +StatusOr +DefaultVmMigrationStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultVmMigrationStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultVmMigrationStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/vmmigration/v1/internal/vm_migration_stub.h b/google/cloud/vmmigration/v1/internal/vm_migration_stub.h index bafaf7bc4a2cc..e91e817208e3f 100644 --- a/google/cloud/vmmigration/v1/internal/vm_migration_stub.h +++ b/google/cloud/vmmigration/v1/internal/vm_migration_stub.h @@ -24,7 +24,10 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include +#include #include #include #include @@ -460,6 +463,15 @@ class VmMigrationStub { google::cloud::vmmigration::v1::GetReplicationCycleRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -479,9 +491,13 @@ class DefaultVmMigrationStub : public VmMigrationStub { std::unique_ptr< google::cloud::vmmigration::v1::VmMigration::StubInterface> grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListSources( grpc::ClientContext& context, Options const& options, @@ -910,6 +926,14 @@ class DefaultVmMigrationStub : public VmMigrationStub { google::cloud::vmmigration::v1::GetReplicationCycleRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -925,6 +949,8 @@ class DefaultVmMigrationStub : public VmMigrationStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/vmmigration/v1/internal/vm_migration_stub_factory.cc b/google/cloud/vmmigration/v1/internal/vm_migration_stub_factory.cc index fa7e7945c8ab4..638a75a7f0935 100644 --- a/google/cloud/vmmigration/v1/internal/vm_migration_stub_factory.cc +++ b/google/cloud/vmmigration/v1/internal/vm_migration_stub_factory.cc @@ -28,6 +28,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultVmMigrationStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::vmmigration::v1::VmMigration::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/vmmigration/v1/internal/vm_migration_tracing_connection.cc b/google/cloud/vmmigration/v1/internal/vm_migration_tracing_connection.cc index 33c1601b336e9..e407d512ae873 100644 --- a/google/cloud/vmmigration/v1/internal/vm_migration_tracing_connection.cc +++ b/google/cloud/vmmigration/v1/internal/vm_migration_tracing_connection.cc @@ -1041,6 +1041,26 @@ VmMigrationTracingConnection::GetReplicationCycle( return internal::EndSpan(*span, child_->GetReplicationCycle(request)); } +StreamRange +VmMigrationTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "vmmigration_v1::VmMigrationConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +VmMigrationTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("vmmigration_v1::VmMigrationConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/vmmigration/v1/internal/vm_migration_tracing_connection.h b/google/cloud/vmmigration/v1/internal/vm_migration_tracing_connection.h index 4c3f06e3b7343..80fd97f6f4ebf 100644 --- a/google/cloud/vmmigration/v1/internal/vm_migration_tracing_connection.h +++ b/google/cloud/vmmigration/v1/internal/vm_migration_tracing_connection.h @@ -459,6 +459,12 @@ class VmMigrationTracingConnection google::cloud::vmmigration::v1::GetReplicationCycleRequest const& request) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/vmmigration/v1/internal/vm_migration_tracing_stub.cc b/google/cloud/vmmigration/v1/internal/vm_migration_tracing_stub.cc index 2ea7c99245aac..66d14471678dd 100644 --- a/google/cloud/vmmigration/v1/internal/vm_migration_tracing_stub.cc +++ b/google/cloud/vmmigration/v1/internal/vm_migration_tracing_stub.cc @@ -995,6 +995,29 @@ VmMigrationTracingStub::GetReplicationCycle( context, *span, child_->GetReplicationCycle(context, options, request)); } +StatusOr +VmMigrationTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.vmmigration.v1.VmMigration", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr VmMigrationTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.vmmigration.v1.VmMigration", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> VmMigrationTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/vmmigration/v1/internal/vm_migration_tracing_stub.h b/google/cloud/vmmigration/v1/internal/vm_migration_tracing_stub.h index 1c485ae934289..be6a3ad36d661 100644 --- a/google/cloud/vmmigration/v1/internal/vm_migration_tracing_stub.h +++ b/google/cloud/vmmigration/v1/internal/vm_migration_tracing_stub.h @@ -465,6 +465,14 @@ class VmMigrationTracingStub : public VmMigrationStub { google::cloud::vmmigration::v1::GetReplicationCycleRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/vmmigration/v1/mocks/mock_vm_migration_connection.h b/google/cloud/vmmigration/v1/mocks/mock_vm_migration_connection.h index 23a95c51de9e4..2799adcfc16a2 100644 --- a/google/cloud/vmmigration/v1/mocks/mock_vm_migration_connection.h +++ b/google/cloud/vmmigration/v1/mocks/mock_vm_migration_connection.h @@ -1238,6 +1238,14 @@ class MockVmMigrationConnection : public vmmigration_v1::VmMigrationConnection { (google::cloud::vmmigration::v1::GetReplicationCycleRequest const& request), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/vmmigration/v1/vm_migration_client.cc b/google/cloud/vmmigration/v1/vm_migration_client.cc index 8a21a06487a0d..e64cc108ffef8 100644 --- a/google/cloud/vmmigration/v1/vm_migration_client.cc +++ b/google/cloud/vmmigration/v1/vm_migration_client.cc @@ -1461,6 +1461,18 @@ VmMigrationClient::GetReplicationCycle( return connection_->GetReplicationCycle(request); } +StreamRange VmMigrationClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr VmMigrationClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace vmmigration_v1 } // namespace cloud diff --git a/google/cloud/vmmigration/v1/vm_migration_client.h b/google/cloud/vmmigration/v1/vm_migration_client.h index f0c58eab3801f..77c585c285b3a 100644 --- a/google/cloud/vmmigration/v1/vm_migration_client.h +++ b/google/cloud/vmmigration/v1/vm_migration_client.h @@ -4410,6 +4410,76 @@ class VmMigrationClient { google::cloud::vmmigration::v1::GetReplicationCycleRequest const& request, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/vmmigration/v1/vm_migration_connection.cc b/google/cloud/vmmigration/v1/vm_migration_connection.cc index 4d0475118f6bf..a08e38b972612 100644 --- a/google/cloud/vmmigration/v1/vm_migration_connection.cc +++ b/google/cloud/vmmigration/v1/vm_migration_connection.cc @@ -781,6 +781,19 @@ VmMigrationConnection::GetReplicationCycle( return Status(StatusCode::kUnimplemented, "not implemented"); } +StreamRange +VmMigrationConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr VmMigrationConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeVmMigrationConnection( Options options) { internal::CheckExpectedOptions #include +#include #include #include @@ -582,6 +584,12 @@ class VmMigrationConnection { GetReplicationCycle( google::cloud::vmmigration::v1::GetReplicationCycleRequest const& request); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/vmmigration/v1/vm_migration_connection_idempotency_policy.cc b/google/cloud/vmmigration/v1/vm_migration_connection_idempotency_policy.cc index bdb2a355fb22a..7fd11e3e26b90 100644 --- a/google/cloud/vmmigration/v1/vm_migration_connection_idempotency_policy.cc +++ b/google/cloud/vmmigration/v1/vm_migration_connection_idempotency_policy.cc @@ -265,6 +265,16 @@ Idempotency VmMigrationConnectionIdempotencyPolicy::GetReplicationCycle( return Idempotency::kIdempotent; } +Idempotency VmMigrationConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency VmMigrationConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultVmMigrationConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/vmmigration/v1/vm_migration_connection_idempotency_policy.h b/google/cloud/vmmigration/v1/vm_migration_connection_idempotency_policy.h index de05d36706435..02107f96616c0 100644 --- a/google/cloud/vmmigration/v1/vm_migration_connection_idempotency_policy.h +++ b/google/cloud/vmmigration/v1/vm_migration_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -184,6 +185,12 @@ class VmMigrationConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GetReplicationCycle( google::cloud::vmmigration::v1::GetReplicationCycleRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/vmwareengine/BUILD.bazel b/google/cloud/vmwareengine/BUILD.bazel index afeffa991623b..a38c4262e832e 100644 --- a/google/cloud/vmwareengine/BUILD.bazel +++ b/google/cloud/vmwareengine/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/vmwareengine/v1:vmwareengine_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/vmwareengine/v1/internal/vmware_engine_auth_decorator.cc b/google/cloud/vmwareengine/v1/internal/vmware_engine_auth_decorator.cc index f81a7d6fd59b0..e28aef1c8dff6 100644 --- a/google/cloud/vmwareengine/v1/internal/vmware_engine_auth_decorator.cc +++ b/google/cloud/vmwareengine/v1/internal/vmware_engine_auth_decorator.cc @@ -1538,6 +1538,48 @@ VmwareEngineAuth::RevokeDnsBindPermission( return child_->RevokeDnsBindPermission(context, options, request); } +StatusOr +VmwareEngineAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr VmwareEngineAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + +StatusOr VmwareEngineAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr VmwareEngineAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +VmwareEngineAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> VmwareEngineAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/vmwareengine/v1/internal/vmware_engine_auth_decorator.h b/google/cloud/vmwareengine/v1/internal/vmware_engine_auth_decorator.h index 2f3a85f8aed6a..eaa5bfe8127f9 100644 --- a/google/cloud/vmwareengine/v1/internal/vmware_engine_auth_decorator.h +++ b/google/cloud/vmwareengine/v1/internal/vmware_engine_auth_decorator.h @@ -713,6 +713,26 @@ class VmwareEngineAuth : public VmwareEngineStub { google::cloud::vmwareengine::v1::RevokeDnsBindPermissionRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/vmwareengine/v1/internal/vmware_engine_connection_impl.cc b/google/cloud/vmwareengine/v1/internal/vmware_engine_connection_impl.cc index d06a2dbbbd27d..cfd49a29a9b3e 100644 --- a/google/cloud/vmwareengine/v1/internal/vmware_engine_connection_impl.cc +++ b/google/cloud/vmwareengine/v1/internal/vmware_engine_connection_impl.cc @@ -4643,6 +4643,94 @@ VmwareEngineConnectionImpl::RevokeDnsBindPermission( polling_policy(*current), __func__); } +StreamRange +VmwareEngineConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +VmwareEngineConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + +StatusOr VmwareEngineConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr VmwareEngineConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +VmwareEngineConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace vmwareengine_v1_internal } // namespace cloud diff --git a/google/cloud/vmwareengine/v1/internal/vmware_engine_connection_impl.h b/google/cloud/vmwareengine/v1/internal/vmware_engine_connection_impl.h index 6bab8b55c4b79..248017059fa4b 100644 --- a/google/cloud/vmwareengine/v1/internal/vmware_engine_connection_impl.h +++ b/google/cloud/vmwareengine/v1/internal/vmware_engine_connection_impl.h @@ -730,6 +730,21 @@ class VmwareEngineConnectionImpl RevokeDnsBindPermission( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/vmwareengine/v1/internal/vmware_engine_logging_decorator.cc b/google/cloud/vmwareengine/v1/internal/vmware_engine_logging_decorator.cc index 8fc6becb63db8..3a2b1415de1d7 100644 --- a/google/cloud/vmwareengine/v1/internal/vmware_engine_logging_decorator.cc +++ b/google/cloud/vmwareengine/v1/internal/vmware_engine_logging_decorator.cc @@ -1846,6 +1846,63 @@ VmwareEngineLogging::RevokeDnsBindPermission( context, options, request, __func__, tracing_options_); } +StatusOr +VmwareEngineLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr VmwareEngineLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr VmwareEngineLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr VmwareEngineLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +VmwareEngineLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> VmwareEngineLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/vmwareengine/v1/internal/vmware_engine_logging_decorator.h b/google/cloud/vmwareengine/v1/internal/vmware_engine_logging_decorator.h index fee29d6b394a1..f54ee3eaeaf5a 100644 --- a/google/cloud/vmwareengine/v1/internal/vmware_engine_logging_decorator.h +++ b/google/cloud/vmwareengine/v1/internal/vmware_engine_logging_decorator.h @@ -713,6 +713,26 @@ class VmwareEngineLogging : public VmwareEngineStub { google::cloud::vmwareengine::v1::RevokeDnsBindPermissionRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/vmwareengine/v1/internal/vmware_engine_metadata_decorator.cc b/google/cloud/vmwareengine/v1/internal/vmware_engine_metadata_decorator.cc index 262452043411b..d2c0a1c3fc188 100644 --- a/google/cloud/vmwareengine/v1/internal/vmware_engine_metadata_decorator.cc +++ b/google/cloud/vmwareengine/v1/internal/vmware_engine_metadata_decorator.cc @@ -1307,6 +1307,51 @@ VmwareEngineMetadata::RevokeDnsBindPermission( return child_->RevokeDnsBindPermission(context, options, request); } +StatusOr +VmwareEngineMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr VmwareEngineMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + +StatusOr VmwareEngineMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr VmwareEngineMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +VmwareEngineMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> VmwareEngineMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/vmwareengine/v1/internal/vmware_engine_metadata_decorator.h b/google/cloud/vmwareengine/v1/internal/vmware_engine_metadata_decorator.h index 3d21901ee3e0e..7d39df2b001e4 100644 --- a/google/cloud/vmwareengine/v1/internal/vmware_engine_metadata_decorator.h +++ b/google/cloud/vmwareengine/v1/internal/vmware_engine_metadata_decorator.h @@ -713,6 +713,26 @@ class VmwareEngineMetadata : public VmwareEngineStub { google::cloud::vmwareengine::v1::RevokeDnsBindPermissionRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/vmwareengine/v1/internal/vmware_engine_stub.cc b/google/cloud/vmwareengine/v1/internal/vmware_engine_stub.cc index 08add9b9680b2..2c10417130d9e 100644 --- a/google/cloud/vmwareengine/v1/internal/vmware_engine_stub.cc +++ b/google/cloud/vmwareengine/v1/internal/vmware_engine_stub.cc @@ -1782,6 +1782,65 @@ DefaultVmwareEngineStub::RevokeDnsBindPermission( return response; } +StatusOr +DefaultVmwareEngineStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultVmwareEngineStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultVmwareEngineStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultVmwareEngineStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultVmwareEngineStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultVmwareEngineStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/vmwareengine/v1/internal/vmware_engine_stub.h b/google/cloud/vmwareengine/v1/internal/vmware_engine_stub.h index f7444e35bfdcb..f0e141aa0b693 100644 --- a/google/cloud/vmwareengine/v1/internal/vmware_engine_stub.h +++ b/google/cloud/vmwareengine/v1/internal/vmware_engine_stub.h @@ -24,7 +24,11 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include +#include +#include #include #include #include @@ -742,6 +746,28 @@ class VmwareEngineStub { google::cloud::vmwareengine::v1::RevokeDnsBindPermissionRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -761,9 +787,15 @@ class DefaultVmwareEngineStub : public VmwareEngineStub { std::unique_ptr< google::cloud::vmwareengine::v1::VmwareEngine::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListPrivateClouds( @@ -1439,6 +1471,26 @@ class DefaultVmwareEngineStub : public VmwareEngineStub { google::cloud::vmwareengine::v1::RevokeDnsBindPermissionRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -1454,6 +1506,9 @@ class DefaultVmwareEngineStub : public VmwareEngineStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/vmwareengine/v1/internal/vmware_engine_stub_factory.cc b/google/cloud/vmwareengine/v1/internal/vmware_engine_stub_factory.cc index 2c3d81ec08666..15a7ed074971a 100644 --- a/google/cloud/vmwareengine/v1/internal/vmware_engine_stub_factory.cc +++ b/google/cloud/vmwareengine/v1/internal/vmware_engine_stub_factory.cc @@ -28,7 +28,9 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include +#include #include #include @@ -44,9 +46,13 @@ std::shared_ptr CreateDefaultVmwareEngineStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::vmwareengine::v1::VmwareEngine::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), + std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/vmwareengine/v1/internal/vmware_engine_tracing_connection.cc b/google/cloud/vmwareengine/v1/internal/vmware_engine_tracing_connection.cc index c945893afd3da..851097ef1234a 100644 --- a/google/cloud/vmwareengine/v1/internal/vmware_engine_tracing_connection.cc +++ b/google/cloud/vmwareengine/v1/internal/vmware_engine_tracing_connection.cc @@ -1677,6 +1677,51 @@ VmwareEngineTracingConnection::RevokeDnsBindPermission( child_->RevokeDnsBindPermission(operation)); } +StreamRange +VmwareEngineTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "vmwareengine_v1::VmwareEngineConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +VmwareEngineTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan( + "vmwareengine_v1::VmwareEngineConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StatusOr VmwareEngineTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "vmwareengine_v1::VmwareEngineConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr VmwareEngineTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "vmwareengine_v1::VmwareEngineConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +VmwareEngineTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "vmwareengine_v1::VmwareEngineConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/vmwareengine/v1/internal/vmware_engine_tracing_connection.h b/google/cloud/vmwareengine/v1/internal/vmware_engine_tracing_connection.h index 0aab1339054ec..19de8bbbf9306 100644 --- a/google/cloud/vmwareengine/v1/internal/vmware_engine_tracing_connection.h +++ b/google/cloud/vmwareengine/v1/internal/vmware_engine_tracing_connection.h @@ -718,6 +718,21 @@ class VmwareEngineTracingConnection RevokeDnsBindPermission( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/vmwareengine/v1/internal/vmware_engine_tracing_stub.cc b/google/cloud/vmwareengine/v1/internal/vmware_engine_tracing_stub.cc index 914aa4779500d..babeb9532cd70 100644 --- a/google/cloud/vmwareengine/v1/internal/vmware_engine_tracing_stub.cc +++ b/google/cloud/vmwareengine/v1/internal/vmware_engine_tracing_stub.cc @@ -1618,6 +1618,64 @@ VmwareEngineTracingStub::RevokeDnsBindPermission( child_->RevokeDnsBindPermission(context, options, request)); } +StatusOr +VmwareEngineTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vmwareengine.v1.VmwareEngine", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr +VmwareEngineTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vmwareengine.v1.VmwareEngine", "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + +StatusOr VmwareEngineTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vmwareengine.v1.VmwareEngine", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr VmwareEngineTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vmwareengine.v1.VmwareEngine", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +VmwareEngineTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vmwareengine.v1.VmwareEngine", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> VmwareEngineTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/vmwareengine/v1/internal/vmware_engine_tracing_stub.h b/google/cloud/vmwareengine/v1/internal/vmware_engine_tracing_stub.h index 138cbafe38154..d6f48a04f9798 100644 --- a/google/cloud/vmwareengine/v1/internal/vmware_engine_tracing_stub.h +++ b/google/cloud/vmwareengine/v1/internal/vmware_engine_tracing_stub.h @@ -712,6 +712,26 @@ class VmwareEngineTracingStub : public VmwareEngineStub { google::cloud::vmwareengine::v1::RevokeDnsBindPermissionRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/vmwareengine/v1/mocks/mock_vmware_engine_connection.h b/google/cloud/vmwareengine/v1/mocks/mock_vmware_engine_connection.h index d88194d94b94f..b61033b9eb9ca 100644 --- a/google/cloud/vmwareengine/v1/mocks/mock_vmware_engine_connection.h +++ b/google/cloud/vmwareengine/v1/mocks/mock_vmware_engine_connection.h @@ -1880,6 +1880,27 @@ class MockVmwareEngineConnection future>, RevokeDnsBindPermission, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/vmwareengine/v1/vmware_engine_client.cc b/google/cloud/vmwareengine/v1/vmware_engine_client.cc index 425dd88e5c07a..ee468138a4a2f 100644 --- a/google/cloud/vmwareengine/v1/vmware_engine_client.cc +++ b/google/cloud/vmwareengine/v1/vmware_engine_client.cc @@ -2459,6 +2459,38 @@ VmwareEngineClient::RevokeDnsBindPermission( return connection_->RevokeDnsBindPermission(operation); } +StreamRange +VmwareEngineClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr VmwareEngineClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StatusOr VmwareEngineClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr VmwareEngineClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +VmwareEngineClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace vmwareengine_v1 } // namespace cloud diff --git a/google/cloud/vmwareengine/v1/vmware_engine_client.h b/google/cloud/vmwareengine/v1/vmware_engine_client.h index 7fda1df2c5c92..395abe743b041 100644 --- a/google/cloud/vmwareengine/v1/vmware_engine_client.h +++ b/google/cloud/vmwareengine/v1/vmware_engine_client.h @@ -7721,6 +7721,178 @@ class VmwareEngineClient { RevokeDnsBindPermission(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/vmwareengine/v1/vmware_engine_connection.cc b/google/cloud/vmwareengine/v1/vmware_engine_connection.cc index 4920f69df4866..481f3fabfe8db 100644 --- a/google/cloud/vmwareengine/v1/vmware_engine_connection.cc +++ b/google/cloud/vmwareengine/v1/vmware_engine_connection.cc @@ -1210,6 +1210,35 @@ VmwareEngineConnection::RevokeDnsBindPermission( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +VmwareEngineConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr VmwareEngineConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr VmwareEngineConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr VmwareEngineConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +VmwareEngineConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeVmwareEngineConnection( Options options) { internal::CheckExpectedOptions #include +#include #include #include @@ -838,6 +840,21 @@ class VmwareEngineConnection { virtual future> RevokeDnsBindPermission(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/vmwareengine/v1/vmware_engine_connection_idempotency_policy.cc b/google/cloud/vmwareengine/v1/vmware_engine_connection_idempotency_policy.cc index 748961d822b84..a1f511c12a4d9 100644 --- a/google/cloud/vmwareengine/v1/vmware_engine_connection_idempotency_policy.cc +++ b/google/cloud/vmwareengine/v1/vmware_engine_connection_idempotency_policy.cc @@ -422,6 +422,32 @@ Idempotency VmwareEngineConnectionIdempotencyPolicy::RevokeDnsBindPermission( return Idempotency::kNonIdempotent; } +Idempotency VmwareEngineConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency VmwareEngineConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency VmwareEngineConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency VmwareEngineConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency VmwareEngineConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultVmwareEngineConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/vmwareengine/v1/vmware_engine_connection_idempotency_policy.h b/google/cloud/vmwareengine/v1/vmware_engine_connection_idempotency_policy.h index 078faee86a69a..5eaeee7e221dd 100644 --- a/google/cloud/vmwareengine/v1/vmware_engine_connection_idempotency_policy.h +++ b/google/cloud/vmwareengine/v1/vmware_engine_connection_idempotency_policy.h @@ -21,7 +21,9 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include +#include #include namespace google { @@ -305,6 +307,21 @@ class VmwareEngineConnectionIdempotencyPolicy { virtual google::cloud::Idempotency RevokeDnsBindPermission( google::cloud::vmwareengine::v1::RevokeDnsBindPermissionRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr diff --git a/google/cloud/vpcaccess/BUILD.bazel b/google/cloud/vpcaccess/BUILD.bazel index 9cd861c7e9d8e..596412d1f1968 100644 --- a/google/cloud/vpcaccess/BUILD.bazel +++ b/google/cloud/vpcaccess/BUILD.bazel @@ -25,6 +25,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/vpcaccess/v1:vpcaccess_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/vpcaccess/v1/internal/vpc_access_auth_decorator.cc b/google/cloud/vpcaccess/v1/internal/vpc_access_auth_decorator.cc index 59c6b1779b534..1c25e95b07d99 100644 --- a/google/cloud/vpcaccess/v1/internal/vpc_access_auth_decorator.cc +++ b/google/cloud/vpcaccess/v1/internal/vpc_access_auth_decorator.cc @@ -105,6 +105,15 @@ StatusOr VpcAccessServiceAuth::DeleteConnector( return child_->DeleteConnector(context, options, request); } +StatusOr +VpcAccessServiceAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + future> VpcAccessServiceAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/vpcaccess/v1/internal/vpc_access_auth_decorator.h b/google/cloud/vpcaccess/v1/internal/vpc_access_auth_decorator.h index 8b950576b276d..bf09e81b42996 100644 --- a/google/cloud/vpcaccess/v1/internal/vpc_access_auth_decorator.h +++ b/google/cloud/vpcaccess/v1/internal/vpc_access_auth_decorator.h @@ -73,6 +73,10 @@ class VpcAccessServiceAuth : public VpcAccessServiceStub { google::cloud::vpcaccess::v1::DeleteConnectorRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/vpcaccess/v1/internal/vpc_access_connection_impl.cc b/google/cloud/vpcaccess/v1/internal/vpc_access_connection_impl.cc index 86ba7cdd87289..5e0c777590913 100644 --- a/google/cloud/vpcaccess/v1/internal/vpc_access_connection_impl.cc +++ b/google/cloud/vpcaccess/v1/internal/vpc_access_connection_impl.cc @@ -298,6 +298,40 @@ VpcAccessServiceConnectionImpl::DeleteConnector( polling_policy(*current), __func__); } +StreamRange +VpcAccessServiceConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace vpcaccess_v1_internal } // namespace cloud diff --git a/google/cloud/vpcaccess/v1/internal/vpc_access_connection_impl.h b/google/cloud/vpcaccess/v1/internal/vpc_access_connection_impl.h index dcf5368d3b8da..c859e29b573d4 100644 --- a/google/cloud/vpcaccess/v1/internal/vpc_access_connection_impl.h +++ b/google/cloud/vpcaccess/v1/internal/vpc_access_connection_impl.h @@ -83,6 +83,9 @@ class VpcAccessServiceConnectionImpl future> DeleteConnector(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/vpcaccess/v1/internal/vpc_access_logging_decorator.cc b/google/cloud/vpcaccess/v1/internal/vpc_access_logging_decorator.cc index 0606f4e8f7199..0fe3a5c014d4a 100644 --- a/google/cloud/vpcaccess/v1/internal/vpc_access_logging_decorator.cc +++ b/google/cloud/vpcaccess/v1/internal/vpc_access_logging_decorator.cc @@ -124,6 +124,18 @@ VpcAccessServiceLogging::DeleteConnector( context, options, request, __func__, tracing_options_); } +StatusOr +VpcAccessServiceLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> VpcAccessServiceLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/vpcaccess/v1/internal/vpc_access_logging_decorator.h b/google/cloud/vpcaccess/v1/internal/vpc_access_logging_decorator.h index fcd5197bd3a02..da9dcf95629e2 100644 --- a/google/cloud/vpcaccess/v1/internal/vpc_access_logging_decorator.h +++ b/google/cloud/vpcaccess/v1/internal/vpc_access_logging_decorator.h @@ -73,6 +73,10 @@ class VpcAccessServiceLogging : public VpcAccessServiceStub { google::cloud::vpcaccess::v1::DeleteConnectorRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/vpcaccess/v1/internal/vpc_access_metadata_decorator.cc b/google/cloud/vpcaccess/v1/internal/vpc_access_metadata_decorator.cc index 6237b6502d94b..b63a36138844c 100644 --- a/google/cloud/vpcaccess/v1/internal/vpc_access_metadata_decorator.cc +++ b/google/cloud/vpcaccess/v1/internal/vpc_access_metadata_decorator.cc @@ -104,6 +104,15 @@ VpcAccessServiceMetadata::DeleteConnector( return child_->DeleteConnector(context, options, request); } +StatusOr +VpcAccessServiceMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + future> VpcAccessServiceMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/vpcaccess/v1/internal/vpc_access_metadata_decorator.h b/google/cloud/vpcaccess/v1/internal/vpc_access_metadata_decorator.h index 18a131b05faa4..6674d6ae6f5e8 100644 --- a/google/cloud/vpcaccess/v1/internal/vpc_access_metadata_decorator.h +++ b/google/cloud/vpcaccess/v1/internal/vpc_access_metadata_decorator.h @@ -74,6 +74,10 @@ class VpcAccessServiceMetadata : public VpcAccessServiceStub { google::cloud::vpcaccess::v1::DeleteConnectorRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/vpcaccess/v1/internal/vpc_access_stub.cc b/google/cloud/vpcaccess/v1/internal/vpc_access_stub.cc index bb4d94b9c41a2..63ab8e6b5d326 100644 --- a/google/cloud/vpcaccess/v1/internal/vpc_access_stub.cc +++ b/google/cloud/vpcaccess/v1/internal/vpc_access_stub.cc @@ -117,6 +117,18 @@ DefaultVpcAccessServiceStub::DeleteConnector( return response; } +StatusOr +DefaultVpcAccessServiceStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultVpcAccessServiceStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/vpcaccess/v1/internal/vpc_access_stub.h b/google/cloud/vpcaccess/v1/internal/vpc_access_stub.h index 64188e7f9c096..74ee2f58ef773 100644 --- a/google/cloud/vpcaccess/v1/internal/vpc_access_stub.h +++ b/google/cloud/vpcaccess/v1/internal/vpc_access_stub.h @@ -24,6 +24,8 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include #include @@ -67,6 +69,11 @@ class VpcAccessServiceStub { grpc::ClientContext& context, Options options, google::cloud::vpcaccess::v1::DeleteConnectorRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -86,9 +93,13 @@ class DefaultVpcAccessServiceStub : public VpcAccessServiceStub { std::unique_ptr< google::cloud::vpcaccess::v1::VpcAccessService::StubInterface> grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} future> AsyncCreateConnector( google::cloud::CompletionQueue& cq, @@ -124,6 +135,10 @@ class DefaultVpcAccessServiceStub : public VpcAccessServiceStub { google::cloud::vpcaccess::v1::DeleteConnectorRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -139,6 +154,8 @@ class DefaultVpcAccessServiceStub : public VpcAccessServiceStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/vpcaccess/v1/internal/vpc_access_stub_factory.cc b/google/cloud/vpcaccess/v1/internal/vpc_access_stub_factory.cc index 3cdd4e60fa6e9..2882075ab4ce5 100644 --- a/google/cloud/vpcaccess/v1/internal/vpc_access_stub_factory.cc +++ b/google/cloud/vpcaccess/v1/internal/vpc_access_stub_factory.cc @@ -28,6 +28,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -44,9 +45,11 @@ std::shared_ptr CreateDefaultVpcAccessServiceStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::vpcaccess::v1::VpcAccessService::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/vpcaccess/v1/internal/vpc_access_tracing_connection.cc b/google/cloud/vpcaccess/v1/internal/vpc_access_tracing_connection.cc index 2973915a0c16c..e8fe0a80f55ab 100644 --- a/google/cloud/vpcaccess/v1/internal/vpc_access_tracing_connection.cc +++ b/google/cloud/vpcaccess/v1/internal/vpc_access_tracing_connection.cc @@ -111,6 +111,17 @@ VpcAccessServiceTracingConnection::DeleteConnector( return internal::EndSpan(std::move(span), child_->DeleteConnector(operation)); } +StreamRange +VpcAccessServiceTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan( + "vpcaccess_v1::VpcAccessServiceConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/vpcaccess/v1/internal/vpc_access_tracing_connection.h b/google/cloud/vpcaccess/v1/internal/vpc_access_tracing_connection.h index b6a6a34cb4410..2d3279bc2ef07 100644 --- a/google/cloud/vpcaccess/v1/internal/vpc_access_tracing_connection.h +++ b/google/cloud/vpcaccess/v1/internal/vpc_access_tracing_connection.h @@ -71,6 +71,9 @@ class VpcAccessServiceTracingConnection future> DeleteConnector(google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/vpcaccess/v1/internal/vpc_access_tracing_stub.cc b/google/cloud/vpcaccess/v1/internal/vpc_access_tracing_stub.cc index 9e7cdf4fc4c88..6e2fba26377d3 100644 --- a/google/cloud/vpcaccess/v1/internal/vpc_access_tracing_stub.cc +++ b/google/cloud/vpcaccess/v1/internal/vpc_access_tracing_stub.cc @@ -110,6 +110,18 @@ VpcAccessServiceTracingStub::DeleteConnector( child_->DeleteConnector(context, options, request)); } +StatusOr +VpcAccessServiceTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.vpcaccess.v1.VpcAccessService", "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + future> VpcAccessServiceTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/vpcaccess/v1/internal/vpc_access_tracing_stub.h b/google/cloud/vpcaccess/v1/internal/vpc_access_tracing_stub.h index 8f745e3404b36..eef2805e558a8 100644 --- a/google/cloud/vpcaccess/v1/internal/vpc_access_tracing_stub.h +++ b/google/cloud/vpcaccess/v1/internal/vpc_access_tracing_stub.h @@ -73,6 +73,10 @@ class VpcAccessServiceTracingStub : public VpcAccessServiceStub { google::cloud::vpcaccess::v1::DeleteConnectorRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/vpcaccess/v1/mocks/mock_vpc_access_connection.h b/google/cloud/vpcaccess/v1/mocks/mock_vpc_access_connection.h index b798635b9a749..dfe0758469bc6 100644 --- a/google/cloud/vpcaccess/v1/mocks/mock_vpc_access_connection.h +++ b/google/cloud/vpcaccess/v1/mocks/mock_vpc_access_connection.h @@ -134,6 +134,10 @@ class MockVpcAccessServiceConnection MOCK_METHOD(future>, DeleteConnector, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/vpcaccess/v1/vpc_access_client.cc b/google/cloud/vpcaccess/v1/vpc_access_client.cc index cda14548ba27f..230896e407758 100644 --- a/google/cloud/vpcaccess/v1/vpc_access_client.cc +++ b/google/cloud/vpcaccess/v1/vpc_access_client.cc @@ -153,6 +153,13 @@ VpcAccessServiceClient::DeleteConnector( return connection_->DeleteConnector(operation); } +StreamRange +VpcAccessServiceClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace vpcaccess_v1 } // namespace cloud diff --git a/google/cloud/vpcaccess/v1/vpc_access_client.h b/google/cloud/vpcaccess/v1/vpc_access_client.h index fb0ae93a457d3..167820026062b 100644 --- a/google/cloud/vpcaccess/v1/vpc_access_client.h +++ b/google/cloud/vpcaccess/v1/vpc_access_client.h @@ -457,6 +457,45 @@ class VpcAccessServiceClient { DeleteConnector(google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/vpcaccess/v1/vpc_access_connection.cc b/google/cloud/vpcaccess/v1/vpc_access_connection.cc index ae31d96a55e03..9c8dd6191e130 100644 --- a/google/cloud/vpcaccess/v1/vpc_access_connection.cc +++ b/google/cloud/vpcaccess/v1/vpc_access_connection.cc @@ -98,6 +98,14 @@ VpcAccessServiceConnection::DeleteConnector( Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +VpcAccessServiceConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + std::shared_ptr MakeVpcAccessServiceConnection( Options options) { internal::CheckExpectedOptions #include #include #include @@ -216,6 +217,9 @@ class VpcAccessServiceConnection { virtual future> DeleteConnector(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); }; /** diff --git a/google/cloud/vpcaccess/v1/vpc_access_connection_idempotency_policy.cc b/google/cloud/vpcaccess/v1/vpc_access_connection_idempotency_policy.cc index 217cc66440782..9c2775737e8db 100644 --- a/google/cloud/vpcaccess/v1/vpc_access_connection_idempotency_policy.cc +++ b/google/cloud/vpcaccess/v1/vpc_access_connection_idempotency_policy.cc @@ -54,6 +54,11 @@ Idempotency VpcAccessServiceConnectionIdempotencyPolicy::DeleteConnector( return Idempotency::kNonIdempotent; } +Idempotency VpcAccessServiceConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultVpcAccessServiceConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/vpcaccess/v1/vpc_access_connection_idempotency_policy.h b/google/cloud/vpcaccess/v1/vpc_access_connection_idempotency_policy.h index d75ec4e80d8a1..265e8d194bb77 100644 --- a/google/cloud/vpcaccess/v1/vpc_access_connection_idempotency_policy.h +++ b/google/cloud/vpcaccess/v1/vpc_access_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -48,6 +49,9 @@ class VpcAccessServiceConnectionIdempotencyPolicy { virtual google::cloud::Idempotency DeleteConnector( google::cloud::vpcaccess::v1::DeleteConnectorRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); }; std::unique_ptr diff --git a/google/cloud/workflows/BUILD.bazel b/google/cloud/workflows/BUILD.bazel index 86dd942860f47..2cdf45c36d92b 100644 --- a/google/cloud/workflows/BUILD.bazel +++ b/google/cloud/workflows/BUILD.bazel @@ -27,6 +27,8 @@ service_dirs = [ googleapis_deps = [ "@com_google_googleapis//google/cloud/workflows/executions/v1:executions_cc_grpc", "@com_google_googleapis//google/cloud/workflows/v1:workflows_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/workflows/v1/internal/workflows_auth_decorator.cc b/google/cloud/workflows/v1/internal/workflows_auth_decorator.cc index 6c2f72a75dfa5..1fb53360a93e0 100644 --- a/google/cloud/workflows/v1/internal/workflows_auth_decorator.cc +++ b/google/cloud/workflows/v1/internal/workflows_auth_decorator.cc @@ -132,6 +132,23 @@ StatusOr WorkflowsAuth::UpdateWorkflow( return child_->UpdateWorkflow(context, options, request); } +StatusOr +WorkflowsAuth::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->ListLocations(context, options, request); +} + +StatusOr WorkflowsAuth::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetLocation(context, options, request); +} + future> WorkflowsAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/workflows/v1/internal/workflows_auth_decorator.h b/google/cloud/workflows/v1/internal/workflows_auth_decorator.h index c706d051b3a6d..b56a040536902 100644 --- a/google/cloud/workflows/v1/internal/workflows_auth_decorator.h +++ b/google/cloud/workflows/v1/internal/workflows_auth_decorator.h @@ -84,6 +84,14 @@ class WorkflowsAuth : public WorkflowsStub { google::cloud::workflows::v1::UpdateWorkflowRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/workflows/v1/internal/workflows_connection_impl.cc b/google/cloud/workflows/v1/internal/workflows_connection_impl.cc index 965b2904e043f..cda0bab632975 100644 --- a/google/cloud/workflows/v1/internal/workflows_connection_impl.cc +++ b/google/cloud/workflows/v1/internal/workflows_connection_impl.cc @@ -385,6 +385,54 @@ WorkflowsConnectionImpl::UpdateWorkflow( polling_policy(*current), __func__); } +StreamRange +WorkflowsConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = std::shared_ptr( + retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::internal::RetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +WorkflowsConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace workflows_v1_internal } // namespace cloud diff --git a/google/cloud/workflows/v1/internal/workflows_connection_impl.h b/google/cloud/workflows/v1/internal/workflows_connection_impl.h index 78437a2c7e809..eca2fb2dcdf47 100644 --- a/google/cloud/workflows/v1/internal/workflows_connection_impl.h +++ b/google/cloud/workflows/v1/internal/workflows_connection_impl.h @@ -93,6 +93,12 @@ class WorkflowsConnectionImpl : public workflows_v1::WorkflowsConnection { future> UpdateWorkflow( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/workflows/v1/internal/workflows_logging_decorator.cc b/google/cloud/workflows/v1/internal/workflows_logging_decorator.cc index 6596d6845aaa4..781e51a0ed1d4 100644 --- a/google/cloud/workflows/v1/internal/workflows_logging_decorator.cc +++ b/google/cloud/workflows/v1/internal/workflows_logging_decorator.cc @@ -152,6 +152,29 @@ StatusOr WorkflowsLogging::UpdateWorkflow( context, options, request, __func__, tracing_options_); } +StatusOr +WorkflowsLogging::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr WorkflowsLogging::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> WorkflowsLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/workflows/v1/internal/workflows_logging_decorator.h b/google/cloud/workflows/v1/internal/workflows_logging_decorator.h index 8b0fecdbb5ef1..56cd2e82f174e 100644 --- a/google/cloud/workflows/v1/internal/workflows_logging_decorator.h +++ b/google/cloud/workflows/v1/internal/workflows_logging_decorator.h @@ -84,6 +84,14 @@ class WorkflowsLogging : public WorkflowsStub { google::cloud::workflows::v1::UpdateWorkflowRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/workflows/v1/internal/workflows_metadata_decorator.cc b/google/cloud/workflows/v1/internal/workflows_metadata_decorator.cc index 260940416421e..871fcb047eac1 100644 --- a/google/cloud/workflows/v1/internal/workflows_metadata_decorator.cc +++ b/google/cloud/workflows/v1/internal/workflows_metadata_decorator.cc @@ -123,6 +123,23 @@ StatusOr WorkflowsMetadata::UpdateWorkflow( return child_->UpdateWorkflow(context, options, request); } +StatusOr +WorkflowsMetadata::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->ListLocations(context, options, request); +} + +StatusOr WorkflowsMetadata::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(context, options, + absl::StrCat("name=", internal::UrlEncode(request.name()))); + return child_->GetLocation(context, options, request); +} + future> WorkflowsMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/workflows/v1/internal/workflows_metadata_decorator.h b/google/cloud/workflows/v1/internal/workflows_metadata_decorator.h index ade6a277f246b..b6ef1ddf3487b 100644 --- a/google/cloud/workflows/v1/internal/workflows_metadata_decorator.h +++ b/google/cloud/workflows/v1/internal/workflows_metadata_decorator.h @@ -84,6 +84,14 @@ class WorkflowsMetadata : public WorkflowsStub { google::cloud::workflows::v1::UpdateWorkflowRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/workflows/v1/internal/workflows_stub.cc b/google/cloud/workflows/v1/internal/workflows_stub.cc index b99875a88e08f..e4f1d918fa23f 100644 --- a/google/cloud/workflows/v1/internal/workflows_stub.cc +++ b/google/cloud/workflows/v1/internal/workflows_stub.cc @@ -142,6 +142,29 @@ StatusOr DefaultWorkflowsStub::UpdateWorkflow( return response; } +StatusOr +DefaultWorkflowsStub::ListLocations( + grpc::ClientContext& context, Options const&, + google::cloud::location::ListLocationsRequest const& request) { + google::cloud::location::ListLocationsResponse response; + auto status = locations_stub_->ListLocations(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultWorkflowsStub::GetLocation( + grpc::ClientContext& context, Options const&, + google::cloud::location::GetLocationRequest const& request) { + google::cloud::location::Location response; + auto status = locations_stub_->GetLocation(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultWorkflowsStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/workflows/v1/internal/workflows_stub.h b/google/cloud/workflows/v1/internal/workflows_stub.h index 4602420bcda5e..253f0b90f935a 100644 --- a/google/cloud/workflows/v1/internal/workflows_stub.h +++ b/google/cloud/workflows/v1/internal/workflows_stub.h @@ -24,6 +24,8 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include +#include #include #include #include @@ -77,6 +79,15 @@ class WorkflowsStub { grpc::ClientContext& context, Options options, google::cloud::workflows::v1::UpdateWorkflowRequest const& request) = 0; + virtual StatusOr + ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -95,9 +106,13 @@ class DefaultWorkflowsStub : public WorkflowsStub { DefaultWorkflowsStub( std::unique_ptr grpc_stub, + std::unique_ptr + locations_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + locations_stub_(std::move(locations_stub)), + operations_(std::move(operations)) {} StatusOr ListWorkflows( grpc::ClientContext& context, Options const& options, @@ -144,6 +159,14 @@ class DefaultWorkflowsStub : public WorkflowsStub { google::cloud::workflows::v1::UpdateWorkflowRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -159,6 +182,8 @@ class DefaultWorkflowsStub : public WorkflowsStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr + locations_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/workflows/v1/internal/workflows_stub_factory.cc b/google/cloud/workflows/v1/internal/workflows_stub_factory.cc index 61d2f7ccaec99..418ec4c1215b9 100644 --- a/google/cloud/workflows/v1/internal/workflows_stub_factory.cc +++ b/google/cloud/workflows/v1/internal/workflows_stub_factory.cc @@ -28,6 +28,7 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/log.h" #include "google/cloud/options.h" +#include #include #include #include @@ -44,8 +45,10 @@ std::shared_ptr CreateDefaultWorkflowsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::workflows::v1::Workflows::NewStub(channel); + auto service_locations_stub = + google::cloud::location::Locations::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_locations_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/workflows/v1/internal/workflows_tracing_connection.cc b/google/cloud/workflows/v1/internal/workflows_tracing_connection.cc index 72f6c107bd4e2..331471dbbe377 100644 --- a/google/cloud/workflows/v1/internal/workflows_tracing_connection.cc +++ b/google/cloud/workflows/v1/internal/workflows_tracing_connection.cc @@ -140,6 +140,26 @@ WorkflowsTracingConnection::UpdateWorkflow( return internal::EndSpan(std::move(span), child_->UpdateWorkflow(operation)); } +StreamRange +WorkflowsTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = + internal::MakeSpan("workflows_v1::WorkflowsConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +WorkflowsTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = + internal::MakeSpan("workflows_v1::WorkflowsConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/workflows/v1/internal/workflows_tracing_connection.h b/google/cloud/workflows/v1/internal/workflows_tracing_connection.h index bce326720db9e..3b0fdff1c7f77 100644 --- a/google/cloud/workflows/v1/internal/workflows_tracing_connection.h +++ b/google/cloud/workflows/v1/internal/workflows_tracing_connection.h @@ -81,6 +81,12 @@ class WorkflowsTracingConnection : public workflows_v1::WorkflowsConnection { future> UpdateWorkflow( google::longrunning::Operation const& operation) override; + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/workflows/v1/internal/workflows_tracing_stub.cc b/google/cloud/workflows/v1/internal/workflows_tracing_stub.cc index b0cc49b4a8926..2bfeb4acbc7d6 100644 --- a/google/cloud/workflows/v1/internal/workflows_tracing_stub.cc +++ b/google/cloud/workflows/v1/internal/workflows_tracing_stub.cc @@ -133,6 +133,29 @@ StatusOr WorkflowsTracingStub::UpdateWorkflow( child_->UpdateWorkflow(context, options, request)); } +StatusOr +WorkflowsTracingStub::ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.workflows.v1.Workflows", + "ListLocations"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->ListLocations(context, options, request)); +} + +StatusOr WorkflowsTracingStub::GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpanGrpc("google.cloud.workflows.v1.Workflows", + "GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetLocation(context, options, request)); +} + future> WorkflowsTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/workflows/v1/internal/workflows_tracing_stub.h b/google/cloud/workflows/v1/internal/workflows_tracing_stub.h index b07ce3a06ebea..1cb326188d753 100644 --- a/google/cloud/workflows/v1/internal/workflows_tracing_stub.h +++ b/google/cloud/workflows/v1/internal/workflows_tracing_stub.h @@ -83,6 +83,14 @@ class WorkflowsTracingStub : public WorkflowsStub { google::cloud::workflows::v1::UpdateWorkflowRequest const& request) override; + StatusOr ListLocations( + grpc::ClientContext& context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + grpc::ClientContext& context, Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/workflows/v1/mocks/mock_workflows_connection.h b/google/cloud/workflows/v1/mocks/mock_workflows_connection.h index c45dd1f2b345b..4ef58f29ae614 100644 --- a/google/cloud/workflows/v1/mocks/mock_workflows_connection.h +++ b/google/cloud/workflows/v1/mocks/mock_workflows_connection.h @@ -169,6 +169,14 @@ class MockWorkflowsConnection : public workflows_v1::WorkflowsConnection { MOCK_METHOD(future>, UpdateWorkflow, (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/workflows/v1/workflows_client.cc b/google/cloud/workflows/v1/workflows_client.cc index 83b93a262618c..53b45e8e8cbd9 100644 --- a/google/cloud/workflows/v1/workflows_client.cc +++ b/google/cloud/workflows/v1/workflows_client.cc @@ -193,6 +193,18 @@ WorkflowsClient::UpdateWorkflow(google::longrunning::Operation const& operation, return connection_->UpdateWorkflow(operation); } +StreamRange WorkflowsClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr WorkflowsClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace workflows_v1 } // namespace cloud diff --git a/google/cloud/workflows/v1/workflows_client.h b/google/cloud/workflows/v1/workflows_client.h index e55fbf6b75473..345d430f5a194 100644 --- a/google/cloud/workflows/v1/workflows_client.h +++ b/google/cloud/workflows/v1/workflows_client.h @@ -595,6 +595,76 @@ class WorkflowsClient { future> UpdateWorkflow( google::longrunning::Operation const& operation, Options opts = {}); + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/workflows/v1/workflows_connection.cc b/google/cloud/workflows/v1/workflows_connection.cc index 7ddd49e314ebd..dac337a7149aa 100644 --- a/google/cloud/workflows/v1/workflows_connection.cc +++ b/google/cloud/workflows/v1/workflows_connection.cc @@ -115,6 +115,19 @@ WorkflowsConnection::UpdateWorkflow(google::longrunning::Operation const&) { Status(StatusCode::kUnimplemented, "not implemented")); } +StreamRange +WorkflowsConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr WorkflowsConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeWorkflowsConnection(Options options) { internal::CheckExpectedOptions #include #include #include @@ -223,6 +224,12 @@ class WorkflowsConnection { virtual future> UpdateWorkflow(google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); }; /** diff --git a/google/cloud/workflows/v1/workflows_connection_idempotency_policy.cc b/google/cloud/workflows/v1/workflows_connection_idempotency_policy.cc index cc6cb4ee96b59..692f833e3be50 100644 --- a/google/cloud/workflows/v1/workflows_connection_idempotency_policy.cc +++ b/google/cloud/workflows/v1/workflows_connection_idempotency_policy.cc @@ -59,6 +59,16 @@ Idempotency WorkflowsConnectionIdempotencyPolicy::UpdateWorkflow( return Idempotency::kNonIdempotent; } +Idempotency WorkflowsConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency WorkflowsConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultWorkflowsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/workflows/v1/workflows_connection_idempotency_policy.h b/google/cloud/workflows/v1/workflows_connection_idempotency_policy.h index eadc17708dcdf..ba4bd83f448a1 100644 --- a/google/cloud/workflows/v1/workflows_connection_idempotency_policy.h +++ b/google/cloud/workflows/v1/workflows_connection_idempotency_policy.h @@ -21,6 +21,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" +#include #include #include @@ -50,6 +51,12 @@ class WorkflowsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency UpdateWorkflow( google::cloud::workflows::v1::UpdateWorkflowRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); }; std::unique_ptr diff --git a/google/cloud/workstations/BUILD.bazel b/google/cloud/workstations/BUILD.bazel index 92812cdbf3b8d..d3622ddff434b 100644 --- a/google/cloud/workstations/BUILD.bazel +++ b/google/cloud/workstations/BUILD.bazel @@ -22,6 +22,8 @@ service_dirs = ["v1/"] googleapis_deps = [ "@com_google_googleapis//google/cloud/workstations/v1:workstations_cc_grpc", + "@com_google_googleapis//google/cloud/location:location_cc_grpc", + "@com_google_googleapis//google/iam/v1:iam_cc_grpc", ] cc_gapic_library( diff --git a/google/cloud/workstations/v1/internal/workstations_auth_decorator.cc b/google/cloud/workstations/v1/internal/workstations_auth_decorator.cc index d468d8c95e1bb..943bca163d73e 100644 --- a/google/cloud/workstations/v1/internal/workstations_auth_decorator.cc +++ b/google/cloud/workstations/v1/internal/workstations_auth_decorator.cc @@ -445,6 +445,31 @@ WorkstationsAuth::GenerateAccessToken( return child_->GenerateAccessToken(context, options, request); } +StatusOr WorkstationsAuth::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->SetIamPolicy(context, options, request); +} + +StatusOr WorkstationsAuth::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +WorkstationsAuth::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto status = auth_->ConfigureContext(context); + if (!status.ok()) return status; + return child_->TestIamPermissions(context, options, request); +} + future> WorkstationsAuth::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/workstations/v1/internal/workstations_auth_decorator.h b/google/cloud/workstations/v1/internal/workstations_auth_decorator.h index 549ac143a56b5..c1241f0e1c921 100644 --- a/google/cloud/workstations/v1/internal/workstations_auth_decorator.h +++ b/google/cloud/workstations/v1/internal/workstations_auth_decorator.h @@ -228,6 +228,18 @@ class WorkstationsAuth : public WorkstationsStub { google::cloud::workstations::v1::GenerateAccessTokenRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/workstations/v1/internal/workstations_connection_impl.cc b/google/cloud/workstations/v1/internal/workstations_connection_impl.cc index 759b294b0704f..b54ef397f1b06 100644 --- a/google/cloud/workstations/v1/internal/workstations_connection_impl.cc +++ b/google/cloud/workstations/v1/internal/workstations_connection_impl.cc @@ -1347,6 +1347,46 @@ WorkstationsConnectionImpl::GenerateAccessToken( *current, request, __func__); } +StatusOr WorkstationsConnectionImpl::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->SetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return stub_->SetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr WorkstationsConnectionImpl::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetIamPolicy(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return stub_->GetIamPolicy(context, options, request); + }, + *current, request, __func__); +} + +StatusOr +WorkstationsConnectionImpl::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::internal::RetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->TestIamPermissions(request), + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return stub_->TestIamPermissions(context, options, request); + }, + *current, request, __func__); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace workstations_v1_internal } // namespace cloud diff --git a/google/cloud/workstations/v1/internal/workstations_connection_impl.h b/google/cloud/workstations/v1/internal/workstations_connection_impl.h index 3dac26f51e74b..4816c28def906 100644 --- a/google/cloud/workstations/v1/internal/workstations_connection_impl.h +++ b/google/cloud/workstations/v1/internal/workstations_connection_impl.h @@ -243,6 +243,15 @@ class WorkstationsConnectionImpl google::cloud::workstations::v1::GenerateAccessTokenRequest const& request) override; + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::unique_ptr background_; std::shared_ptr stub_; diff --git a/google/cloud/workstations/v1/internal/workstations_logging_decorator.cc b/google/cloud/workstations/v1/internal/workstations_logging_decorator.cc index bdbff85240947..5c23d3518255d 100644 --- a/google/cloud/workstations/v1/internal/workstations_logging_decorator.cc +++ b/google/cloud/workstations/v1/internal/workstations_logging_decorator.cc @@ -528,6 +528,40 @@ WorkstationsLogging::GenerateAccessToken( context, options, request, __func__, tracing_options_); } +StatusOr WorkstationsLogging::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + return child_->SetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr WorkstationsLogging::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + return child_->GetIamPolicy(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + +StatusOr +WorkstationsLogging::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + return child_->TestIamPermissions(context, options, request); + }, + context, options, request, __func__, tracing_options_); +} + future> WorkstationsLogging::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/workstations/v1/internal/workstations_logging_decorator.h b/google/cloud/workstations/v1/internal/workstations_logging_decorator.h index 8e799b85bca6a..2af232a01ef27 100644 --- a/google/cloud/workstations/v1/internal/workstations_logging_decorator.h +++ b/google/cloud/workstations/v1/internal/workstations_logging_decorator.h @@ -228,6 +228,18 @@ class WorkstationsLogging : public WorkstationsStub { google::cloud::workstations::v1::GenerateAccessTokenRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/workstations/v1/internal/workstations_metadata_decorator.cc b/google/cloud/workstations/v1/internal/workstations_metadata_decorator.cc index 91261582b649b..2f5c7d21f3e7e 100644 --- a/google/cloud/workstations/v1/internal/workstations_metadata_decorator.cc +++ b/google/cloud/workstations/v1/internal/workstations_metadata_decorator.cc @@ -384,6 +384,34 @@ WorkstationsMetadata::GenerateAccessToken( return child_->GenerateAccessToken(context, options, request); } +StatusOr WorkstationsMetadata::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->SetIamPolicy(context, options, request); +} + +StatusOr WorkstationsMetadata::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->GetIamPolicy(context, options, request); +} + +StatusOr +WorkstationsMetadata::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + SetMetadata( + context, options, + absl::StrCat("resource=", internal::UrlEncode(request.resource()))); + return child_->TestIamPermissions(context, options, request); +} + future> WorkstationsMetadata::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/workstations/v1/internal/workstations_metadata_decorator.h b/google/cloud/workstations/v1/internal/workstations_metadata_decorator.h index 3b770d0014a38..8762242812616 100644 --- a/google/cloud/workstations/v1/internal/workstations_metadata_decorator.h +++ b/google/cloud/workstations/v1/internal/workstations_metadata_decorator.h @@ -228,6 +228,18 @@ class WorkstationsMetadata : public WorkstationsStub { google::cloud::workstations::v1::GenerateAccessTokenRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/workstations/v1/internal/workstations_stub.cc b/google/cloud/workstations/v1/internal/workstations_stub.cc index 7d5f3c45792cb..39e2079f72b03 100644 --- a/google/cloud/workstations/v1/internal/workstations_stub.cc +++ b/google/cloud/workstations/v1/internal/workstations_stub.cc @@ -513,6 +513,41 @@ DefaultWorkstationsStub::GenerateAccessToken( return response; } +StatusOr DefaultWorkstationsStub::SetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::SetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->SetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr DefaultWorkstationsStub::GetIamPolicy( + grpc::ClientContext& context, Options const&, + google::iam::v1::GetIamPolicyRequest const& request) { + google::iam::v1::Policy response; + auto status = iampolicy_stub_->GetIamPolicy(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + +StatusOr +DefaultWorkstationsStub::TestIamPermissions( + grpc::ClientContext& context, Options const&, + google::iam::v1::TestIamPermissionsRequest const& request) { + google::iam::v1::TestIamPermissionsResponse response; + auto status = + iampolicy_stub_->TestIamPermissions(&context, request, &response); + if (!status.ok()) { + return google::cloud::MakeStatusFromRpcError(status); + } + return response; +} + future> DefaultWorkstationsStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/workstations/v1/internal/workstations_stub.h b/google/cloud/workstations/v1/internal/workstations_stub.h index 7c54884350526..0064e3f837ddb 100644 --- a/google/cloud/workstations/v1/internal/workstations_stub.h +++ b/google/cloud/workstations/v1/internal/workstations_stub.h @@ -24,7 +24,10 @@ #include "google/cloud/options.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" +#include #include +#include +#include #include #include #include @@ -237,6 +240,19 @@ class WorkstationsStub { google::cloud::workstations::v1::GenerateAccessTokenRequest const& request) = 0; + virtual StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) = 0; + + virtual StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) = 0; + + virtual StatusOr + TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) = 0; + virtual future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -256,9 +272,12 @@ class DefaultWorkstationsStub : public WorkstationsStub { std::unique_ptr< google::cloud::workstations::v1::Workstations::StubInterface> grpc_stub, + std::unique_ptr iampolicy_stub, std::unique_ptr operations) - : grpc_stub_(std::move(grpc_stub)), operations_(std::move(operations)) {} + : grpc_stub_(std::move(grpc_stub)), + iampolicy_stub_(std::move(iampolicy_stub)), + operations_(std::move(operations)) {} StatusOr GetWorkstationCluster( @@ -449,6 +468,18 @@ class DefaultWorkstationsStub : public WorkstationsStub { google::cloud::workstations::v1::GenerateAccessTokenRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, @@ -464,6 +495,7 @@ class DefaultWorkstationsStub : public WorkstationsStub { private: std::unique_ptr grpc_stub_; + std::unique_ptr iampolicy_stub_; std::unique_ptr operations_; }; diff --git a/google/cloud/workstations/v1/internal/workstations_stub_factory.cc b/google/cloud/workstations/v1/internal/workstations_stub_factory.cc index 408ef3ab0afae..80f66f639bb71 100644 --- a/google/cloud/workstations/v1/internal/workstations_stub_factory.cc +++ b/google/cloud/workstations/v1/internal/workstations_stub_factory.cc @@ -29,6 +29,7 @@ #include "google/cloud/log.h" #include "google/cloud/options.h" #include +#include #include #include @@ -44,9 +45,10 @@ std::shared_ptr CreateDefaultWorkstationsStub( internal::MakeChannelArguments(options)); auto service_grpc_stub = google::cloud::workstations::v1::Workstations::NewStub(channel); + auto service_iampolicy_stub = google::iam::v1::IAMPolicy::NewStub(channel); std::shared_ptr stub = std::make_shared( - std::move(service_grpc_stub), + std::move(service_grpc_stub), std::move(service_iampolicy_stub), google::longrunning::Operations::NewStub(channel)); if (auth->RequiresConfigureContext()) { diff --git a/google/cloud/workstations/v1/internal/workstations_tracing_connection.cc b/google/cloud/workstations/v1/internal/workstations_tracing_connection.cc index 5a242b4e0f1b3..f5742d51be7a9 100644 --- a/google/cloud/workstations/v1/internal/workstations_tracing_connection.cc +++ b/google/cloud/workstations/v1/internal/workstations_tracing_connection.cc @@ -480,6 +480,31 @@ WorkstationsTracingConnection::GenerateAccessToken( return internal::EndSpan(*span, child_->GenerateAccessToken(request)); } +StatusOr WorkstationsTracingConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "workstations_v1::WorkstationsConnection::SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->SetIamPolicy(request)); +} + +StatusOr WorkstationsTracingConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpan( + "workstations_v1::WorkstationsConnection::GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetIamPolicy(request)); +} + +StatusOr +WorkstationsTracingConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpan( + "workstations_v1::WorkstationsConnection::TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->TestIamPermissions(request)); +} + #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY std::shared_ptr diff --git a/google/cloud/workstations/v1/internal/workstations_tracing_connection.h b/google/cloud/workstations/v1/internal/workstations_tracing_connection.h index e15b66463c6e5..cbb42f15262c1 100644 --- a/google/cloud/workstations/v1/internal/workstations_tracing_connection.h +++ b/google/cloud/workstations/v1/internal/workstations_tracing_connection.h @@ -231,6 +231,15 @@ class WorkstationsTracingConnection google::cloud::workstations::v1::GenerateAccessTokenRequest const& request) override; + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request) override; + private: std::shared_ptr child_; }; diff --git a/google/cloud/workstations/v1/internal/workstations_tracing_stub.cc b/google/cloud/workstations/v1/internal/workstations_tracing_stub.cc index 04624d6fbedc1..6cf2624f82ee4 100644 --- a/google/cloud/workstations/v1/internal/workstations_tracing_stub.cc +++ b/google/cloud/workstations/v1/internal/workstations_tracing_stub.cc @@ -467,6 +467,40 @@ WorkstationsTracingStub::GenerateAccessToken( context, *span, child_->GenerateAccessToken(context, options, request)); } +StatusOr WorkstationsTracingStub::SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workstations.v1.Workstations", "SetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->SetIamPolicy(context, options, request)); +} + +StatusOr WorkstationsTracingStub::GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workstations.v1.Workstations", "GetIamPolicy"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan(context, *span, + child_->GetIamPolicy(context, options, request)); +} + +StatusOr +WorkstationsTracingStub::TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) { + auto span = internal::MakeSpanGrpc( + "google.cloud.workstations.v1.Workstations", "TestIamPermissions"); + auto scope = opentelemetry::trace::Scope(span); + internal::InjectTraceContext(context, *propagator_); + return internal::EndSpan( + context, *span, child_->TestIamPermissions(context, options, request)); +} + future> WorkstationsTracingStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/workstations/v1/internal/workstations_tracing_stub.h b/google/cloud/workstations/v1/internal/workstations_tracing_stub.h index af3ed9cd9dd4b..47d7f5ae884f7 100644 --- a/google/cloud/workstations/v1/internal/workstations_tracing_stub.h +++ b/google/cloud/workstations/v1/internal/workstations_tracing_stub.h @@ -227,6 +227,18 @@ class WorkstationsTracingStub : public WorkstationsStub { google::cloud::workstations::v1::GenerateAccessTokenRequest const& request) override; + StatusOr SetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::SetIamPolicyRequest const& request) override; + + StatusOr GetIamPolicy( + grpc::ClientContext& context, Options const& options, + google::iam::v1::GetIamPolicyRequest const& request) override; + + StatusOr TestIamPermissions( + grpc::ClientContext& context, Options const& options, + google::iam::v1::TestIamPermissionsRequest const& request) override; + future> AsyncGetOperation( google::cloud::CompletionQueue& cq, std::shared_ptr context, diff --git a/google/cloud/workstations/v1/mocks/mock_workstations_connection.h b/google/cloud/workstations/v1/mocks/mock_workstations_connection.h index cdaac1c8d95ed..e0ce219b76e63 100644 --- a/google/cloud/workstations/v1/mocks/mock_workstations_connection.h +++ b/google/cloud/workstations/v1/mocks/mock_workstations_connection.h @@ -556,6 +556,19 @@ class MockWorkstationsConnection (google::cloud::workstations::v1::GenerateAccessTokenRequest const& request), (override)); + + MOCK_METHOD(StatusOr, SetIamPolicy, + (google::iam::v1::SetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, GetIamPolicy, + (google::iam::v1::GetIamPolicyRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + TestIamPermissions, + (google::iam::v1::TestIamPermissionsRequest const& request), + (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/workstations/v1/workstations_client.cc b/google/cloud/workstations/v1/workstations_client.cc index 52f21cac47872..74c8fc8ccb0e3 100644 --- a/google/cloud/workstations/v1/workstations_client.cc +++ b/google/cloud/workstations/v1/workstations_client.cc @@ -693,6 +693,25 @@ WorkstationsClient::GenerateAccessToken( return connection_->GenerateAccessToken(request); } +StatusOr WorkstationsClient::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->SetIamPolicy(request); +} + +StatusOr WorkstationsClient::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetIamPolicy(request); +} + +StatusOr +WorkstationsClient::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->TestIamPermissions(request); +} + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace workstations_v1 } // namespace cloud diff --git a/google/cloud/workstations/v1/workstations_client.h b/google/cloud/workstations/v1/workstations_client.h index c25e8fcd915a5..068e4e01d2488 100644 --- a/google/cloud/workstations/v1/workstations_client.h +++ b/google/cloud/workstations/v1/workstations_client.h @@ -2013,6 +2013,108 @@ class WorkstationsClient { request, Options opts = {}); + // clang-format off + /// + /// Sets the access control policy on the specified resource. Replaces any + /// existing policy. + /// + /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.SetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// [google.iam.v1.SetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L101} + /// + // clang-format on + StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Gets the access control policy for a resource. + /// Returns an empty policy if the resource exists and does not have a policy + /// set. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.GetIamPolicyRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.Policy]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.GetIamPolicyRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L123} + /// [google.iam.v1.Policy]: @googleapis_reference_link{google/iam/v1/policy.proto#L102} + /// + // clang-format on + StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Returns permissions that a caller has on the specified resource. + /// If the resource does not exist, this will return an empty set of + /// permissions, not a `NOT_FOUND` error. + /// + /// Note: This operation is designed to be used for building permission-aware + /// UIs and command-line tools, not for authorization checking. This operation + /// may "fail open" without warning. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.iam.v1.TestIamPermissionsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.iam.v1.TestIamPermissionsResponse]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.iam.v1.TestIamPermissionsRequest]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L136} + /// [google.iam.v1.TestIamPermissionsResponse]: @googleapis_reference_link{google/iam/v1/iam_policy.proto#L151} + /// + // clang-format on + StatusOr TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request, + Options opts = {}); + private: std::shared_ptr connection_; Options options_; diff --git a/google/cloud/workstations/v1/workstations_connection.cc b/google/cloud/workstations/v1/workstations_connection.cc index 1033fe4843aac..8dbead4b0466d 100644 --- a/google/cloud/workstations/v1/workstations_connection.cc +++ b/google/cloud/workstations/v1/workstations_connection.cc @@ -365,6 +365,22 @@ WorkstationsConnection::GenerateAccessToken( return Status(StatusCode::kUnimplemented, "not implemented"); } +StatusOr WorkstationsConnection::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr WorkstationsConnection::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StatusOr +WorkstationsConnection::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + std::shared_ptr MakeWorkstationsConnection( Options options) { internal::CheckExpectedOptions #include +#include #include #include @@ -357,6 +359,15 @@ class WorkstationsConnection { GenerateAccessToken( google::cloud::workstations::v1::GenerateAccessTokenRequest const& request); + + virtual StatusOr SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual StatusOr GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual StatusOr + TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const& request); }; /** diff --git a/google/cloud/workstations/v1/workstations_connection_idempotency_policy.cc b/google/cloud/workstations/v1/workstations_connection_idempotency_policy.cc index 44be4750cdbdf..644887813bb22 100644 --- a/google/cloud/workstations/v1/workstations_connection_idempotency_policy.cc +++ b/google/cloud/workstations/v1/workstations_connection_idempotency_policy.cc @@ -137,6 +137,22 @@ Idempotency WorkstationsConnectionIdempotencyPolicy::GenerateAccessToken( return Idempotency::kNonIdempotent; } +Idempotency WorkstationsConnectionIdempotencyPolicy::SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request) { + return request.policy().etag().empty() ? Idempotency::kNonIdempotent + : Idempotency::kIdempotent; +} + +Idempotency WorkstationsConnectionIdempotencyPolicy::GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency WorkstationsConnectionIdempotencyPolicy::TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const&) { + return Idempotency::kIdempotent; +} + std::unique_ptr MakeDefaultWorkstationsConnectionIdempotencyPolicy() { return std::make_unique(); diff --git a/google/cloud/workstations/v1/workstations_connection_idempotency_policy.h b/google/cloud/workstations/v1/workstations_connection_idempotency_policy.h index 2e2a146f6b2a7..b6602a39d8696 100644 --- a/google/cloud/workstations/v1/workstations_connection_idempotency_policy.h +++ b/google/cloud/workstations/v1/workstations_connection_idempotency_policy.h @@ -22,6 +22,7 @@ #include "google/cloud/idempotency.h" #include "google/cloud/version.h" #include +#include #include namespace google { @@ -106,6 +107,15 @@ class WorkstationsConnectionIdempotencyPolicy { virtual google::cloud::Idempotency GenerateAccessToken( google::cloud::workstations::v1::GenerateAccessTokenRequest const& request); + + virtual google::cloud::Idempotency SetIamPolicy( + google::iam::v1::SetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency GetIamPolicy( + google::iam::v1::GetIamPolicyRequest const& request); + + virtual google::cloud::Idempotency TestIamPermissions( + google::iam::v1::TestIamPermissionsRequest const& request); }; std::unique_ptr From e09cc9554c29339275da95add2080c07f2a2d7b1 Mon Sep 17 00:00:00 2001 From: Yao Cui Date: Mon, 19 Aug 2024 19:47:12 +0000 Subject: [PATCH 8/8] fix http_option_utils --- generator/internal/descriptor_utils.cc | 5 ++- generator/internal/http_option_utils.cc | 21 +++++++-- generator/internal/http_option_utils.h | 7 ++- generator/internal/http_option_utils_test.cc | 47 +++++++++++--------- 4 files changed, 54 insertions(+), 26 deletions(-) diff --git a/generator/internal/descriptor_utils.cc b/generator/internal/descriptor_utils.cc index 8f3b7d36e95a6..2304315479540 100644 --- a/generator/internal/descriptor_utils.cc +++ b/generator/internal/descriptor_utils.cc @@ -855,7 +855,7 @@ std::map CreateMethodVars( SetLongrunningOperationMethodVars(method, method_vars); AssignPaginationMethodVars(method, method_vars); SetMethodSignatureMethodVars(service, method, omitted_rpcs, method_vars); - auto parsed_http_info = ParseHttpExtension(method); + auto parsed_http_info = ParseHttpExtension(method, service); method_vars["request_resource"] = FormatRequestResource(*method.input_type(), parsed_http_info); SetHttpDerivedMethodVars(parsed_http_info, method, method_vars); @@ -889,7 +889,8 @@ std::map CreateMethodVars( SetLongrunningOperationMethodVars(method, method_vars); AssignPaginationMethodVars(method, method_vars); SetMethodSignatureMethodVars(service, method, omitted_rpcs, method_vars); - auto parsed_http_info = ParseHttpExtension(method, mixin_method.method_override); + auto parsed_http_info = + ParseHttpExtension(method, service, mixin_method.method_override); method_vars["request_resource"] = FormatRequestResource(*method.input_type(), parsed_http_info); SetHttpDerivedMethodVars(parsed_http_info, method, method_vars); diff --git a/generator/internal/http_option_utils.cc b/generator/internal/http_option_utils.cc index 6760ced6caed0..8c5b45fb997fa 100644 --- a/generator/internal/http_option_utils.cc +++ b/generator/internal/http_option_utils.cc @@ -264,6 +264,7 @@ void SetHttpQueryParameters(HttpExtensionInfo const& info, HttpExtensionInfo ParseHttpExtension( google::protobuf::MethodDescriptor const& method, + google::protobuf::ServiceDescriptor const& service, absl::optional method_override) { if (!method.options().HasExtension(google::api::http)) return {}; @@ -329,7 +330,9 @@ HttpExtensionInfo ParseHttpExtension( }; auto api_version_opt = FormatApiVersionFromUrlPattern(url_pattern); - auto api_version = api_version_opt.has_value() ? *api_version_opt : FormatApiVersionFromPackageName(method); + auto api_version = api_version_opt.has_value() + ? *api_version_opt + : FormatApiVersionFromPackageName(service); auto rest_path_visitor = RestPathVisitor(api_version, info.rest_path); for (auto const& s : parsed_http_rule->segments) { @@ -351,7 +354,7 @@ HttpExtensionInfo ParseHttpExtension( } bool HasHttpRoutingHeader(MethodDescriptor const& method) { - auto result = ParseHttpExtension(method); + auto result = ParseHttpExtension(method, *method.service()); return !result.field_substitutions.empty(); } @@ -401,9 +404,21 @@ std::string FormatApiVersionFromPackageName( return {}; // Suppress clang-tidy warnings } +std::string FormatApiVersionFromPackageName( + google::protobuf::ServiceDescriptor const& service) { + std::vector parts = + absl::StrSplit(service.file()->package(), '.'); + if (absl::StartsWith(parts.back(), "v")) return parts.back(); + GCP_LOG(FATAL) << "Unrecognized API version in file: " + << service.file()->name() + << ", package: " << service.file()->package(); + return {}; // Suppress clang-tidy warnings +} + // Generate api version by extracting the version from the url pattern. // In some cases(i.e. location), there is no version in the package name. -absl::optional FormatApiVersionFromUrlPattern(std::string const& url_pattern) { +absl::optional FormatApiVersionFromUrlPattern( + std::string const& url_pattern) { std::vector parts = absl::StrSplit(url_pattern, '/'); static auto const* const kVersion = new std::regex{R"(v\d+)"}; for (auto const& part : parts) { diff --git a/generator/internal/http_option_utils.h b/generator/internal/http_option_utils.h index f345283ac21b1..16286563b39b3 100644 --- a/generator/internal/http_option_utils.h +++ b/generator/internal/http_option_utils.h @@ -44,6 +44,7 @@ struct HttpExtensionInfo { */ HttpExtensionInfo ParseHttpExtension( google::protobuf::MethodDescriptor const& method, + google::protobuf::ServiceDescriptor const& service, absl::optional method_override = absl::nullopt); /** @@ -115,10 +116,14 @@ std::string FormatRequestResource(google::protobuf::Descriptor const& request, std::string FormatApiVersionFromPackageName( google::protobuf::MethodDescriptor const& method); +std::string FormatApiVersionFromPackageName( + google::protobuf::ServiceDescriptor const& service); + /** * Parses the url pattern of the method and returns its API version. */ -absl::optional FormatApiVersionFromUrlPattern(std::string const& url_pattern); +absl::optional FormatApiVersionFromUrlPattern( + std::string const& url_pattern); } // namespace generator_internal } // namespace cloud diff --git a/generator/internal/http_option_utils_test.cc b/generator/internal/http_option_utils_test.cc index 100ccfacf3629..2e5ed4714bfca 100644 --- a/generator/internal/http_option_utils_test.cc +++ b/generator/internal/http_option_utils_test.cc @@ -36,8 +36,8 @@ using ::testing::ElementsAre; using ::testing::Eq; using ::testing::HasSubstr; using ::testing::IsEmpty; -using ::testing::Pair; using ::testing::Optional; +using ::testing::Pair; char const* const kHttpProto = "syntax = \"proto3\";\n" @@ -435,7 +435,7 @@ TEST_F(HttpOptionUtilsTest, ParseHttpExtensionWithPrefixAndSuffix) { pool_.FindFileByName("google/foo/v1/service.proto"); MethodDescriptor const* method = service_file_descriptor->service(0)->method(2); - auto info = ParseHttpExtension(*method); + auto info = ParseHttpExtension(*method, *method->service()); EXPECT_THAT(info.url_path, Eq("/v1/{parent=projects/*/instances/*}/databases")); EXPECT_THAT(info.field_substitutions, @@ -450,7 +450,7 @@ TEST_F(HttpOptionUtilsTest, pool_.FindFileByName("google/foo/v1/service.proto"); MethodDescriptor const* method = service_file_descriptor->service(0)->method(6); - auto info = ParseHttpExtension(*method); + auto info = ParseHttpExtension(*method, *method->service()); EXPECT_THAT(info.url_path, Eq("/v1/projects/{project}/databases")); EXPECT_THAT(info.field_substitutions, ElementsAre(Pair("project", "project"))); @@ -464,7 +464,7 @@ TEST_F(HttpOptionUtilsTest, pool_.FindFileByName("google/foo/v1/service.proto"); MethodDescriptor const* method = service_file_descriptor->service(0)->method(7); - auto info = ParseHttpExtension(*method); + auto info = ParseHttpExtension(*method, *method->service()); EXPECT_THAT(info.url_path, Eq("/v1/projects/{project}/instances/{instance}/databases")); EXPECT_THAT( @@ -479,7 +479,7 @@ TEST_F(HttpOptionUtilsTest, ParseHttpExtensionWithOnlyPrefix) { pool_.FindFileByName("google/foo/v1/service.proto"); MethodDescriptor const* method = service_file_descriptor->service(0)->method(1); - auto info = ParseHttpExtension(*method); + auto info = ParseHttpExtension(*method, *method->service()); EXPECT_THAT(info.url_path, Eq("/v1/{name=projects/*/instances/*/backups/*}")); EXPECT_THAT(info.field_substitutions, ElementsAre(Pair("name", "projects/*/instances/*/backups/*"))); @@ -492,7 +492,7 @@ TEST_F(HttpOptionUtilsTest, ParseHttpExtensionSimple) { pool_.FindFileByName("google/foo/v1/service.proto"); MethodDescriptor const* method = service_file_descriptor->service(0)->method(3); - auto info = ParseHttpExtension(*method); + auto info = ParseHttpExtension(*method, *method->service()); EXPECT_THAT(info.url_path, Eq("/v1/foo")); EXPECT_THAT(info.field_substitutions, IsEmpty()); EXPECT_THAT(info.body, Eq("")); @@ -505,7 +505,7 @@ TEST_F(HttpOptionUtilsTest, pool_.FindFileByName("google/foo/v1/service.proto"); MethodDescriptor const* method = service_file_descriptor->service(0)->method(5); - auto info = ParseHttpExtension(*method); + auto info = ParseHttpExtension(*method, *method->service()); EXPECT_THAT(info.url_path, Eq("/v1/projects/{project=project}/instances/{instance=instance}/" "databases")); @@ -519,7 +519,8 @@ TEST_F(HttpOptionUtilsTest, SetHttpDerivedMethodVarsSimpleInfo) { MethodDescriptor const* method = service_file_descriptor->service(0)->method(0); VarsDictionary vars; - SetHttpDerivedMethodVars(ParseHttpExtension(*method), *method, vars); + SetHttpDerivedMethodVars(ParseHttpExtension(*method, *method->service()), + *method, vars); EXPECT_THAT(vars.at("method_http_verb"), Eq("Delete")); EXPECT_THAT( vars.at("method_rest_path"), @@ -535,7 +536,8 @@ TEST_F(HttpOptionUtilsTest, SetHttpDerivedMethodVarsExtensionInfoSingleParam) { MethodDescriptor const* method = service_file_descriptor->service(0)->method(2); VarsDictionary vars; - SetHttpDerivedMethodVars(ParseHttpExtension(*method), *method, vars); + SetHttpDerivedMethodVars(ParseHttpExtension(*method, *method->service()), + *method, vars); EXPECT_THAT(vars.at("method_request_params"), Eq("\"parent=\", internal::UrlEncode(request.parent())")); EXPECT_THAT(vars.at("method_request_body"), Eq("*")); @@ -555,7 +557,8 @@ TEST_F(HttpOptionUtilsTest, MethodDescriptor const* method = service_file_descriptor->service(0)->method(7); VarsDictionary vars; - SetHttpDerivedMethodVars(ParseHttpExtension(*method), *method, vars); + SetHttpDerivedMethodVars(ParseHttpExtension(*method, *method->service()), + *method, vars); EXPECT_THAT(vars.at("method_request_params"), Eq("\"project=\", internal::UrlEncode(request.project()), " "\"&\",\"instance=\", " @@ -577,7 +580,8 @@ TEST_F(HttpOptionUtilsTest, MethodDescriptor const* method = service_file_descriptor->service(0)->method(5); VarsDictionary vars; - SetHttpDerivedMethodVars(ParseHttpExtension(*method), *method, vars); + SetHttpDerivedMethodVars(ParseHttpExtension(*method, *method->service()), + *method, vars); EXPECT_THAT(vars.at("method_request_body"), Eq("*")); EXPECT_THAT(vars.at("method_http_verb"), Eq("Post")); EXPECT_THAT( @@ -594,7 +598,8 @@ TEST_F(HttpOptionUtilsTest, SetHttpQueryParametersNoParams) { MethodDescriptor const* method = service_file_descriptor->service(0)->method(5); VarsDictionary vars; - SetHttpQueryParameters(ParseHttpExtension(*method), *method, vars); + SetHttpQueryParameters(ParseHttpExtension(*method, *method->service()), + *method, vars); EXPECT_THAT(vars.at("method_http_query_parameters"), Eq("")); } @@ -604,7 +609,8 @@ TEST_F(HttpOptionUtilsTest, SetHttpQueryParametersGetWithParams) { MethodDescriptor const* method = service_file_descriptor->service(0)->method(4); VarsDictionary vars; - SetHttpQueryParameters(ParseHttpExtension(*method), *method, vars); + SetHttpQueryParameters(ParseHttpExtension(*method, *method->service()), + *method, vars); EXPECT_THAT(vars.at("method_http_query_parameters"), Eq("")); } @@ -614,7 +620,8 @@ TEST_F(HttpOptionUtilsTest, SetHttpGetQueryParametersGetPaginated) { MethodDescriptor const* method = service_file_descriptor->service(0)->method(3); VarsDictionary vars; - SetHttpQueryParameters(ParseHttpExtension(*method), *method, vars); + SetHttpQueryParameters(ParseHttpExtension(*method, *method->service()), + *method, vars); EXPECT_THAT(vars, Contains(Pair("method_http_query_parameters", AllOf(HasSubstr("TrimEmptyQueryParameters"), @@ -629,7 +636,8 @@ TEST_F(HttpOptionUtilsTest, MethodDescriptor const* method = service_file_descriptor->service(0)->method(0); VarsDictionary vars; - SetHttpQueryParameters(ParseHttpExtension(*method), *method, vars); + SetHttpQueryParameters(ParseHttpExtension(*method, *method->service()), + *method, vars); EXPECT_THAT( vars, Contains(Pair( @@ -729,7 +737,7 @@ TEST_F(HttpOptionUtilsTest, FormatRequestResourceWholeMessage) { pool_.FindFileByName("google/foo/v1/service.proto"); MethodDescriptor const* method = service_file_descriptor->service(0)->method(2); - auto info = ParseHttpExtension(*method); + auto info = ParseHttpExtension(*method, *method->service()); auto result = FormatRequestResource(*method->input_type(), info); EXPECT_THAT(result, Eq("request")); } @@ -739,7 +747,7 @@ TEST_F(HttpOptionUtilsTest, FormatRequestResourceMessageField) { pool_.FindFileByName("google/foo/v1/service.proto"); MethodDescriptor const* method = service_file_descriptor->service(0)->method(6); - auto info = ParseHttpExtension(*method); + auto info = ParseHttpExtension(*method, *method->service()); auto result = FormatRequestResource(*method->input_type(), info); EXPECT_THAT(result, Eq("request.body()")); } @@ -749,7 +757,7 @@ TEST_F(HttpOptionUtilsTest, FormatRequestResourceAnnotatedRequestField) { pool_.FindFileByName("google/foo/v1/service.proto"); MethodDescriptor const* method = service_file_descriptor->service(0)->method(8); - auto info = ParseHttpExtension(*method); + auto info = ParseHttpExtension(*method, *method->service()); auto result = FormatRequestResource(*method->input_type(), info); EXPECT_THAT(result, Eq("request.namespace_()")); } @@ -784,8 +792,7 @@ TEST_F(HttpOptionUtilsTest, FormatApiVersionFromUrlPattern) { TEST_F(HttpOptionUtilsTest, FormatApiVersionFromUrlPatternNullOptional) { std::string url_pattern = "/foo/bar"; - EXPECT_THAT(FormatApiVersionFromUrlPattern(url_pattern), - Eq(absl::nullopt)); + EXPECT_THAT(FormatApiVersionFromUrlPattern(url_pattern), Eq(absl::nullopt)); } } // namespace